【问题标题】:Cannot read property 'authorization' of undefined无法读取未定义的属性“授权”
【发布时间】:2020-12-24 17:07:10
【问题描述】:

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

当我在 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],
})

【问题讨论】:

标签: graphql nestjs nestjs-config graphql-config


【解决方案1】:

最后更新 Nest 和 Graphql 包后问题自动解决了。

我想知道!

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

【讨论】:

    猜你喜欢
    • 2022-11-03
    • 2017-12-30
    • 2014-08-09
    • 1970-01-01
    • 2019-12-03
    • 1970-01-01
    • 1970-01-01
    • 2018-04-06
    • 1970-01-01
    相关资源
    最近更新 更多