graphql-js icon indicating copy to clipboard operation
graphql-js copied to clipboard

TypeError: PubSub is not a constructor

Open luane-aquino opened this issue 4 years ago • 2 comments
trafficstars

Hi, I am getting this error TypeError: PubSub is not a constructor when importing PubSub from apollo-server

code snippet: const { PubSub} = require('apollo-server');

const pubsub = new PubSub();

I appreciate any help, thank you

luane-aquino avatar Aug 09 '21 08:08 luane-aquino

Yes this won't work with apollo-server v3. On their docs it says:

Apollo Server 3 removes built-in support for subscriptions.

Check out their docs on how to setup the subscriptions for v3: https://www.apollographql.com/docs/apollo-server/data/subscriptions/

Else you can use the same package version used in this project.

dhyeythumar avatar Aug 11 '21 04:08 dhyeythumar

Use this command to revert to the previous version of apollo-server:

npm install [email protected]

dracofulmen avatar Aug 18 '21 21:08 dracofulmen