Replies: 2 comments 1 reply
-
Hey! This looks very contrived. Can you explain why you are unable to open database connection outside of query executor and close it once execution completes? Either way having |
Beta Was this translation helpful? Give feedback.
-
Thanks for getting back. Different branches in the graph could request data from different sources. I do not always need to open a database connection. Opening it beforehand could be waste if it isn't queried anyway. I could create a lazy initializing value holder for the database connection, or gRPC client... Just wondering if others ran in the same situation and it there's a common practice |
Beta Was this translation helpful? Give feedback.
-
Hello all,
The reason I want this is to be able to open a database connection in a resolver, then yield a result and once all its sub fields are resolved I want to close the database connection for example. So:
To this I have overriden the
ExecutionContext
like this:Currently I hacked the GraphQL instance to accept the parameter
execution_context_class
and pass it all the way down. What's best practice here or shall I create a pull request for this?Beta Was this translation helpful? Give feedback.
All reactions