You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, i am trying to access pubSub in middleware but cannot make it work. In documentation, I also did not find anything about it.
Is it possible to access pubSub inside of middleware?
Here is my code
@Injectable()exportclassLogAccessimplementsMiddlewareInterface{constructor(@PubSub()privatepubSub: PubSubEngine){}asyncuse(data: ResolverData,next: NextFn): Promise<any>{console.log({pubSubInMiddleware: this.pubSub});console.log('Middleware');returnnext();}}
@Resolver(String)classCustomUserResolver{
@Query((returns)=>String,{nullable: true})
@UseMiddleware(LogAccess)asyncbestUser(@Ctx(){ prisma }: Context, @PubSub()pubSub: PubSubEngine){// console.log({ pubSub });return'You are the best of the best!!:)))';}}
@Module({imports: [// use the TypeGraphQLModule to expose Prisma by GraphQLTypeGraphQLModule.forRoot({playground: true,introspection: true,
emitSchemaFile,validate: false,context: ()=>({ prisma }),globalMiddlewares: [LogAccess],}),],controllers: [],providers: [CustomUserResolver,LogAccess,PubSubEngineasany],})exportclassAppModule{}
I am trying to use PubSubEngine, but since it is an abstract class, in middleware it is just an empty object :(
The text was updated successfully, but these errors were encountered:
Yep. I just thought maybe there is some common way to access it from middleware and I am doing something wrong.
But this way with custom pubsub it works for sure, of course. Thanks.
Hello, i am trying to access pubSub in middleware but cannot make it work. In documentation, I also did not find anything about it.
Is it possible to access pubSub inside of middleware?
Here is my code
I am trying to use PubSubEngine, but since it is an abstract class, in middleware it is just an empty object :(
The text was updated successfully, but these errors were encountered: