Typescript 类型GraphQL BuildSchemaOptions不接受属性
在Graphql类型中设置自定义日期标量的过程中,我注意到BuildSchemaOptions只允许设置解析器的属性。任何附加属性(如ScalarMap、validate等)都将返回以下错误。当我注意到这个问题时,我正在效仿这个例子Typescript 类型GraphQL BuildSchemaOptions不接受属性,typescript,graphql,typegraphql,Typescript,Graphql,Typegraphql,在Graphql类型中设置自定义日期标量的过程中,我注意到BuildSchemaOptions只允许设置解析器的属性。任何附加属性(如ScalarMap、validate等)都将返回以下错误。当我注意到这个问题时,我正在效仿这个例子 error TS2345: Argument of type '{ resolvers: (typeof ItemResolver | typeof ClassificationResolver | typeof SubclassResolver | typeof
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}]
}),
...
有趣的是,这个项目和另一种类型的graphql项目现在都有相同的问题。以前是否有其他人遇到过此问题?此问题已解决。我将Typescript从3.3.3升级到4.0.3,项目最终构建完成。奇怪的是,这在以前是有效的,我确实试图恢复到3.3.3,看看问题是否仍然存在,但它一定是那个版本