Open Kasheftin opened 2 years ago
+1 on the lack of typing around graphql-ws
. I actually just had a conversation over in the discussion forum for graphql-ws
about this exact issue before I realized it was a lack of typing on the part of this repo: https://github.com/enisdenjo/graphql-ws/discussions/257#discussioncomment-3665653.
Would you like to create a PR for this issue?
I got it going with the following:
import { Context } from 'apollo-server-core'
import { Context as WSContext } from 'graphql-ws'
{
...,
subscriptions: {
'graphql-ws': {
onConnect: (context: WSContext) => {
return setupContext(context)
},
onDisconnect: (context: WSContext) => {
//
}
}
},
context: async (context: Context<any>) => {
return setupContext(context)
}
}
Then a setupContext function which handles both ws requests and http requests... be aware the Context object is slightly different but the types should help from the imports as shown above
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
I have an issue when trying to set up graphql subscriptions using
graphql-ws
. I need to specify custom port (for being able serving wss/https using nginx) and append context with custom loaders (they useDataLoader
under the hood). However documentation does not say anything about the port.What's more important, the typing in subscriptions configuration section is missing. That's how my
app.module.ts
looks like:Describe the solution you'd like
It would be nice to have type safe in such a critical place as root level set up. Also, since
subscriptions-transport-ws
is going to be deprecated, it would be nice to have the documentation being focused ongraphql-ws
usage overall.Teachability, documentation, adoption, migration strategy
No response
What is the motivation / use case for changing the behavior?
I'm stuck. I can not set up the basic subscription hello world using
graphql-ws
and serve it through wss with nginx.