无法读取未定义的 属性 'authorization'

Cannot read property 'authorization' of undefined

请不要将此问题标记为 'duplicate'。我在其他地方发现了类似的问题,但找不到任何合适的解决方案。

当我在 Nestjs 应用程序配置中的 GraphQLModule 中使用 context 时,我从未找到 req。当我安慰这个 req 它是未定义的。很多时间花在这个问题上,但一脉相承。

/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],
})

终于更新了Nest和Graphql包后问题自动解决

我想知道!

这表明有时软件包本身可能存在任何错误。