You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to understand the best way to inject the database as a dependency for my graphql queries/mutations.
It looks like context is the appropriate way to do so, and based on reviewing other issues raised on the starlette repo encode/starlette#591, it sounds like the problem was never really solved. Given that starlette is deprecating graphql support and this repo appears to be filling in the gaps of that connection, it felt right to ask the question here.
The workaround described in issue 591 mentions adding the db session to the request via injection on the route, however, that appears to require calling execute on the GraphQL app directly, rather than the app.mount() pattern described in ythe README. I wasn't able to find another way attach the GraphQL app to appropriately, so I'm wondering if I'm missing something or if db dependency injection just isn't possible at the moment.
Is this functionality currently possible to manage or is the expectation that the db will be accessed via things like the SQLAlchemy Graphene connection?
The text was updated successfully, but these errors were encountered:
I was then able to use context["foo_resource"] using both ways. Disclaimer: I was using graphene-sqlalchemy, so in actuality I had to use info.context["foo_resource"]. I know you were trying to avoid using the SQLAlchemy Graphene connection but I had to use another client (my foo_resource contacting another server) on top of using graphene-sqlalchemy in my project. I would think having the DB session as foo_resource would work.
I'm trying to understand the best way to inject the database as a dependency for my graphql queries/mutations.
It looks like context is the appropriate way to do so, and based on reviewing other issues raised on the starlette repo encode/starlette#591, it sounds like the problem was never really solved. Given that starlette is deprecating graphql support and this repo appears to be filling in the gaps of that connection, it felt right to ask the question here.
The workaround described in issue 591 mentions adding the db session to the request via injection on the route, however, that appears to require calling execute on the GraphQL app directly, rather than the
app.mount()
pattern described in ythe README. I wasn't able to find another way attach the GraphQL app to appropriately, so I'm wondering if I'm missing something or if db dependency injection just isn't possible at the moment.Is this functionality currently possible to manage or is the expectation that the db will be accessed via things like the SQLAlchemy Graphene connection?
The text was updated successfully, but these errors were encountered: