Subscription - ApolloServer context & Graphql-ws context #7081
Unanswered
RemyMachado
asked this question in
Q&A
Replies: 2 comments 1 reply
-
I found that I can use |
Beta Was this translation helpful? Give feedback.
0 replies
-
You do have to write different code because the data structures are actually different. One represents parsing an HTTP request (based on your favorite web framework such as Request); the other represents parsing the beginning of a Websocket stream. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently setting the apollo server context using an async callback:
Now I'm duplicating the code to give a context to the
graphql-ws
implementation:I didn't succeed to set it up the same way since the signatures are different (how to retrieve the req obj for WS?).
ApolloServer context:
context?: Context | ContextFunction<ContextFunctionParams>;
Graphql-ws context:
context?: GraphQLExecutionContextValue | ((ctx: Context<P, E>, message: SubscribeMessage, args: ExecutionArgs) => Promise<GraphQLExecutionContextValue> | GraphQLExecutionContextValue);
What's the right way to have the same context in both servers?
Any help would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions