-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subscriptions onConnect return value is not appended to context #1597
Comments
Issue is still present in v2.1.0 |
I was able to get
Not sure if this is the correct approach though. |
Nice one @sabith-th. With that being the case, we can simply use the following as a workaround:
|
Just curious if anyone would find this approach helpful or have feedback =) Right now I pass the token in two places: First in the middleware, so that the token is always fresh on each call and allows for using Second, in the connection params so that
|
This is caused by https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-core/src/ApolloServer.ts#L480 overwriting the |
@samalexander the only proper workaround I can see for right now is to fork the |
@sabith-th actually it would be even better to do this:
|
What's the current status on this? This issue is open for over a year now and it's still not working |
Apollo Server no longer has a superficial integration with a subscriptions server. (A future version hopefully will have a deeper subscriptions integration that avoids this issue.) |
According to the docs for subscriptions in apollo-server-express 2.0, the return value of onConnect is appended to the context. However, in practice the return value of onConnect is ignored and only the context returned by the context method of ApolloServer config is available in resolvers.
For example, with this code:
You would expect the context for websockets to be:
{foo: 'bar', hello: 'world'}
But in practice the context will be:
{foo: 'bar'}
I have created a basic reproduction of the issue here.
The text was updated successfully, but these errors were encountered: