Skip to content

doc: Subscription example doesn't include connection param #30

@raymclee

Description

@raymclee

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,
    ]),  
   },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting helpIssues open to PRs or contributions by othersdocumentationAn issue or PR primarily about updating documentationgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions