Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PubSub is not a constructor apollo server

I am creating a subscription in apollo server. When I try to create a new instance of PubSub. I get an error PubSub is not a constructor.

const {PubSub} = require("apollo-server")
const pubsub =  new PubSub()
like image 508
user12504353 Avatar asked Sep 15 '26 13:09

user12504353


1 Answers

I was able to resolve the issue by installing graphql-subscriptions, then requiring in PubSub from the later like this:

const {PubSub} = require("graphql-subscriptions")
like image 71
user12504353 Avatar answered Sep 17 '26 03:09

user12504353