假设我有一些类型
@ObjectType({ description: "The some other object X ..." })
export class ObjectX{
@Field(()=> ID)
id: string;
@Field()
@Property()
fieldX1: typeX1;
...
@Field()
@Property()
fieldXn: typeXn;
}现在我不想写类似.
@InputType()
export class CreateObjectX {
@Field()
@Property()
fieldX1: typeX1;
...
@Field()
@Property()
fieldXn: typeXn;
}
@InputType()
export class UpdateObjectX {
@Field(()=> ID)
id: string;
@Field({nullable:true})
@Property()
fieldX1: typeX1;
...
@Field({nullable:true})
@Property()
fieldXn: typeXn;
}相反,我想要一个函数,它接受与"ObjectX“类似的任何ObjectX,并返回2派生InputTypes。
所以我得到了以下的schema.gql ..。
type ObjectX {
id: ID!
x1: typeX1!
...:
xn: typeXn!
}
input CreateObjectX {
// id: ID! id would be omitted.
x1: typeX1!
...
xn: typeXn!
}
input UpdateObjectX {
id: ID!
x1?: typeX1 // would be nullable
...
xn?: typeXn // would be nullable
} 我该怎么做?
发布于 2021-07-01 08:36:10
https://stackoverflow.com/questions/68029972
复制相似问题