【发布时间】:2022-10-02 14:52:41
【问题描述】:
我将 DateTime 实现为一个 nexus 方法,如我的 Next.js 项目中的 docs 所示。
// types/DateTime.ts
import { GraphQLDate, GraphQLDateTime, GraphQLTime } from \'graphql-iso-date\';
import { asNexusMethod } from \'nexus\';
export const GQLDate = asNexusMethod(GraphQLDate, \'date\');
export const GQLTime = asNexusMethod(GraphQLTime, \'time\');
export const GQLDateTime = asNexusMethod(GraphQLDateTime, \'datetime\');
该文件也包含在 GraphQL 模式中的类型中
// Other imports
import * as types from \'./types\';
export const schema = makeSchema({
types: types,
// ...
});
但是,我收到以下 TypeScript 错误:
Argument of type \'GraphQLScalarType\' is not assignable to parameter of type \'GraphQLNamedType\'.
Type \'GraphQLScalarType\' is missing the following properties from type \'GraphQLScalarType<unknown, unknown>\': specifiedByURL, [Symbol.toStringTag]ts(2345)
如何解决此错误?
标签: typescript next.js graphql apollo-server