【发布时间】:2021-02-09 02:05:45
【问题描述】:
我正在尝试将 typegoose 与 graphql 一起使用。我在另一个对象中有一个嵌套对象列表。我定义的类如下
@ObjectType()
export class ChildClass {
@prop()
@Field({ nullable: true })
someField: string;
@prop()
@Field({ nullable: true })
anotherField: string;
}
@ObjectType()
@modelOptions()
export class ParentClass extends Typegoose {
@prop()
@Field(() => String)
someField: string;
@prop()
@Field(() => [ChildClass], { nullable: 'itemsAndList' })
children: ChildClass[];
}
当我调用以下查询时
query {
parentClass {
someField
children {
someField
anotherField
}
}
}
它总是给我null 给孩子们的someField 和anotherField。但是,如果我使用猫鼬而不是 typegoose,它可以正常工作。 MongoDb 在使用 typegoose 时返回正常。它转换为 graphql 很不稳定。
我在这里错过了什么?
【问题讨论】:
标签: mongoose graphql nestjs typegoose