我正在使用代码优先方法进行开发 Nestjs 生成的模式忽略了另一个对象类型的 nullable: true
// user.entity.ts
@ObjectType()
export class UserObjectType implements User {
@Field()
id: string;
@Field({ nullable: true})
name: string;
@Field(type => UserServicesObjectType, {
nullable: true, // 👈 here i declare as nullable
})
services: UserServicesObjectType | null;
}
// schema.gql (autogenerated)
type UserObjectType {
id: String!
name: String
services: UserServicesObjectType! // 👈 but the schema is generated as no-null
}
// schema.gql (autogenerated)
type UserObjectType {
id: String!
name: String
services: UserServicesObjectType // 👈 I expected to be nullable (without the !)
}