I followed the Nestjs DOCS regarding pubsub/subsciprtions:
According to the examples, pubsub is initialized at the top of a given resolver with:
const pubSub = new PubSub();
later the docs say:
"We used a local PubSub instance here. Instead, we should define PubSub as a provider, inject it through the constructor (using @Inject() decorator), and reuse it among the whole application"
{
provide: 'PUB_SUB',
useValue: new PubSub(),
}
where does this go though?
I.e. what's the syntax/approach for how to provide this in my main app.module so it's available in all other modules?
if i try to provide this as a dependency in a different module i'm getting dependency resolution issues. app.module
providers: [
AppService,
{
provide: APP_FILTER,
useClass: AllExceptionsFilter,
},
{
provide: 'PUB_SUB',
useValue: new PubSub(),
},
some-resolver.js
constructor(
@Inject('PUB_SUB')
private pubSub: PubSub,
gives: Nest can't resolve dependencies of the MyResolver ( MyResolver is provided by MyModule
I can't import appmodule into MyModule or i'll create a circular depenency.
Do i define a new module which just provides a pub_sub instance?