你好,我正在尝试为对象数组mutation创建field
。代码如下:
import { Field, InputType } from '@nestjs/graphql';
type ChainToAddress = {
chain: string;
address: string;
};
@InputType()
export class CreateONSInput {
@Field()
ons: string;
@Field(type => [ChainToAddress])
chainAddressess: ChainToAddress;
}
当前正在抛出以下错误:
'ChainToAddress' only refers to a type, but is being used as a value here.
任何如何使其工作的想法,尝试过接口/类型,但不知何故无法管理它
您需要从嵌套接口中创建一个InputType
/ObjectType
才能使其工作。
@InputType()
class ChainToAddress {
@Field()
chain: string;
@Field()
address: string;
};
@InputType()
export class CreateONSInput {
@Field()
ons: string;
@Field(type => [ChainToAddress])
chainAddressess: ChainToAddress[];
}