The session setup has to be done twice and ideally there should be a single point of contact for it.
As of now, there's a session setup for the Dataloader injected in the context and one for the relay connections, e.g.:
# context is expected to have an instance of StrawberrySQLAlchemyLoader
class CustomGraphQLView(GraphQLView):
def get_context(self):
return {
"sqlalchemy_loader": StrawberrySQLAlchemyLoader(bind=YOUR_SESSION),
}
@mapper.type(fruit_table)
class Fruit(relay.Node):
id: relay.NodeID[int]
@strawberry.type
class Query:
fruits: relay.ListConnection[Fruit] = connection(sessionmaker=sessionmaker)
The issue had already been spotted by the author on this comment: #65 (comment) and discussed on a community-chat session.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too