Using SQLAlchemy and my current process of creating database sessions revolve around a context manager and a session factory.
AKA in a RESTful API I would do something like this:
def someroute():
with session_factory() as session:
...do some controller stuff with the session...
return result
Since Graphene/GraphQL seems to wrap a lot of the magic around querying, how do I inject the session I create dynamically on a query/mutation request?
It seems like the model expected here is to have a persistent database session? Am I correct in assuming this?
P.S. I originally opted for this model since I wanted to contain all database side-effecty stuff in one python module instead of having to hook into my backend request teardown loop to handle cleaning up sessions.
Using SQLAlchemy and my current process of creating database sessions revolve around a context manager and a session factory.
AKA in a RESTful API I would do something like this:
Since Graphene/GraphQL seems to wrap a lot of the magic around querying, how do I inject the session I create dynamically on a query/mutation request?
It seems like the model expected here is to have a persistent database session? Am I correct in assuming this?
P.S. I originally opted for this model since I wanted to contain all database side-effecty stuff in one python module instead of having to hook into my backend request teardown loop to handle cleaning up sessions.