我是 GraphQL 的新手,我不知道如何将 TypeScript type
传递给 @Field
装饰器的 ReturnTypeFunction
。
我的代码如下:
export type WorokingHours = [number, number];
// [ [ 8, 13 ], [ 16, 22 ] ]
@Field(() => [WorokingHours], {
nullable: true,
description: storeWorkingHours
})
@prop()
workingHours?: WorokingHours[];
我将收到此错误消息:
'WorokingHours' only refers to a type, but is being used as a value here.ts(2693)
如何解决这个错误?
您是否有任何想法可以实现我的商店在我的数据库中处于事件状态的持续时间?
最佳答案
GraphQL 规范不支持元组,因此您需要使用列表 [Number]
或显式对象类型 { one: number, two: number }
代替。
关于typescript - 在 type-graphql 中传递 typescript 类型问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62446121/