Skip to content

Commit 6234849

Browse files
authored
Merge pull request #4 from mattalbr/master
Support class-style contexts in sqlalchemy mapper, a la fastapi style.
2 parents ba50ae3 + b1f3c57 commit 6234849

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/strawberry_sqlalchemy_mapper/mapper.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,12 @@ async def resolve(self, info: Info):
413413
return []
414414
else:
415415
return None
416+
if isinstance(info.context, dict):
417+
loader = info.context["sqlalchemy_loader"]
418+
else:
419+
loader = info.context.sqlalchemy_loader
416420
related_objects = (
417-
await info.context["sqlalchemy_loader"]
421+
await loader
418422
.loader_for(relationship)
419423
.load(relationship_key)
420424
)

0 commit comments

Comments
 (0)