具有实体关系的nestjs graphql-如何装饰它?
我有一个“装饰”类的问题,当我有关系时,这些类应该用作ObejctType和InputType。也可以在其他类中使用关系类 e、 g.带地址的客户,带地址的用户具有实体关系的nestjs graphql-如何装饰它?,graphql,nestjs,Graphql,Nestjs,我有一个“装饰”类的问题,当我有关系时,这些类应该用作ObejctType和InputType。也可以在其他类中使用关系类 e、 g.带地址的客户,带地址的用户 @ObjectType() @InputType() export class Address { @Field() street: string; @Field() city: string; } @ObjectType() @InputType() export class Customer { @Fiel
@ObjectType()
@InputType()
export class Address {
@Field()
street: string;
@Field()
city: string;
}
@ObjectType()
@InputType()
export class Customer {
@Field()
name: string;
@Field(() => Address)
address: Address;
}
@ObjectType()
@InputType()
export class User {
@Field()
name: string;
@Field(() => Address)
address: Address;
}
我想使用Customer和User作为突变的输入参数。但我没有成功。我尝试了InputType和ObjectType的“IsaStract”选项的变体,但我对这个解决方案不满意
你们谁能给我一个提示如何做到这一点。如果您遇到冲突错误,您需要明确指定ObjectTypes和InputTypes的名称 因此,请尝试以下方法:
@ObjectType("AddressType")
@InputType("AddressInput")
export class Address {
@Field()
street: string;
@Field()
city: string;
}
请看此。谢谢您的回答。是的,InputType和ObjectType的“命名”很有效。