Just use an external file with declared instance of PubSub
import { PubSub } from 'graphql-subscriptions'; export const pubsub = new PubSub();