-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Hi, 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' 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,
]),
},
});