doc: Subscription example doesn't include connection param
See original GitHub issueHi, query and mutation work perfectly but not working with subscription.
When i try to call ctx.getUser(), ctx.isAuthenticated() or ctx.isUnauthenticated() will get the following errors: Cannot read property ‘user’ of undefined Cannot read property ‘isAuthenticated’ of undefined Cannot read property ‘isUnauthenticated’ of undefined
Also, there is a type errors on createOnConnected() which is
Type ‘(connectionParams: Object, webSocket: WebSocket<Request<ParamsDictionary, any, any, Query>>) => Promise<ReturnOnConnect>’ is not assignable to type ‘(connectionParams: Object, websocket: WebSocket, context: ConnectionContext) => any’. Types of parameters ‘webSocket’ and ‘websocket’ are incompatible. Property ‘upgradeReq’ is missing in type ‘WebSocket’ but required in type ‘WebSocket<Request<ParamsDictionary, any, any, Query>>’.ts(2322) types.d.ts(33, 5): ‘upgradeReq’ is declared here.
here is the server
const server = new ApolloServer({
schema,
context: ({ req, res }) => buildContext({ req, res, prisma, pubsub }),
playground: {
settings: {
"request.credentials": "include",
},
},
subscriptions: {
// @ts-ignore
onConnect: createOnConnect([
sessionMiddleware,
passportMiddleware,
passportSessionMiddleware,
]),
},
});
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5
Top GitHub Comments
Thanks for this issue. Can you reproduce this issue in an example repo or codesandbox? That would be very helpful
Hello! I had the same situation like @raymclee @jkettmann My buildContext had no connection param, that was the problem. I tried it after read your comment and my credentials were loaded successfully.
@raymclee the change must be:
P.S.=Thank you Johannes for this library, and congrats for your great job. Maybe you can add the connection param to the subscription section’s tutorial