Skip to content

GraphQL Context within onSubscribe hook #281

Answered by enisdenjo
intellix asked this question in Q&A
Discussion options

You must be logged in to vote

The onSubscribe hook gets called before context. Reason in simple, you might want to have the onSubscribe supply the complete GraphQL execution args (including context, validation, parsing, etc.). GraphQL execution arguments are available only in the onOperation hook that happens after the operation has been executed.

As you suggested with #281 (comment), the first argument of all hooks, the connection context, is what you should use. Since the context hook is only for the GraphQL context, it is not a fitting place for setting up the connection context; however, onConnect, on the other hand, is. Additionally, exactly as you showcased, I'd too recommend putting your extras in the Context.e…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by intellix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants