Please don't mark this question as 'duplicate'. I found similar questions elsewhere but couldn't find any proper solution.
When I use the context
inside the GraphQLModule
in Nestjs app configuration I never find the req
. When I console this req
it is undefined. Lot of time spent in this issue but in a vein.
/src/app.module.ts
@Module({
imports: [
ProductModule,
GraphQLModule.forRoot({
debug: true,
typePaths: ["./**/*.gql"],
definitions: {
path: join(process.cwd(), "src/schemas/graphql.d.ts"),
},
installSubscriptionHandlers: true,
context: ({ req }) => {
console.log(req); <======================== undefined !!!!
return {req}
},
}),
MongooseModule.forRoot(MONGO_URI),
AuthModule,
UsersModule,
],
controllers: [AppController],
providers: [AppService],
})
Finally the problem automatically solved after updating the Nest and Graphql packages.
I wondered!
It indicates that sometimes the packages can have any bug in itself.