howtographql / graphql-js

https://www.howtographql.com/graphql-js/1-getting-started/
363 stars 126 forks source link

TypeError: PubSub is not a constructor #87

Open luane-aquino opened 2 years ago

luane-aquino commented 2 years ago

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

dhyeythumar commented 2 years ago

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.

dracofulmen commented 2 years ago

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

npm install apollo-server@2.19.0