【问题标题】:Type-GraphQL BuildSchemaOptions not accepting propertiesType-GraphQL BuildSchemaOptions 不接受属性
【发布时间】:2021-01-08 18:18:27
【问题描述】:

在 Type-Graphql 中设置自定义日期标量的过程中,我注意到 BuildSchemaOptions 只允许设置解析器的属性。任何其他属性(例如 scalarsMap、validate 等)都将返回以下错误。当我注意到这个问题时,我正在关注示例 here

error TS2345: Argument of type '{ resolvers: (typeof ItemResolver | typeof ClassificationResolver | typeof SubclassResolver | typeof UserResolver)[]; scalarsMap: { type: DateConstructor; scalar: GraphQLScalarType; }[]; }' is not assignable to parameter of type 'BuildSchemaOptions'.
  Object literal may only specify known properties, and 'scalarsMap' does not exist in type 'BuildSchemaOptions'.

架构设置代码。

  const apolloServer = new ApolloServer({
         playground: true,
         schema: await buildSchema({
             resolvers: [ItemResolver, ClassificationResolver, SubclassResolver, UserResolver],
             scalarsMap: [{type: Date, scalar: dateResolverType}]
         }),
...

有趣的是,这个项目和另一个 type-graphql 项目现在都有同样的问题。有没有其他人遇到过这个问题?

【问题讨论】:

    标签: typescript graphql typegraphql


    【解决方案1】:

    此问题已解决。我把 Typescript 从 3.3.3 升级到了 4.0.3,项目终于建好了。奇怪的是,这在以前是有效的,我确实尝试恢复到 3.3.3 以查看问题是否仍然存在,但它一定是那个版本。

    【讨论】:

      猜你喜欢
      • 2019-03-17
      • 2017-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多