Unlike for http operations, the get_context() handler is set up as a FastAPI dependency for the websocket endpoint on GraphQLRouter
and resolved when the websocket connection is initialized.
So, even though the protocol handler's get_context()
member is evaluated for each subscription, or any other operation, it will ultimately return this single cached value for the duration of the websocket connection.
This may be by design, but it is a bit unexpected and is not mentioned in the documentation. It also means that the dependencies cannot be used via the yield
pattern to acquire and release resources for the operation.
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