Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript TypeForm属性可为Null,但接收“;对于不可为null的字段x.x";不能返回null;_Typescript_Graphql_Typeorm_Typegraphql - Fatal编程技术网

Typescript TypeForm属性可为Null,但接收“;对于不可为null的字段x.x";不能返回null;

Typescript TypeForm属性可为Null,但接收“;对于不可为null的字段x.x";不能返回null;,typescript,graphql,typeorm,typegraphql,Typescript,Graphql,Typeorm,Typegraphql,我有一个所有字段都可以为空的数据模型,因为数据集现在不一致,但我仍然希望处理数据 这是模型的一个片段: @ObjectType() @Entity() export class SomeEntity extends BaseEntity { @PrimaryGeneratedColumn({ type: 'bigint', }) @Field() id: number; @Column({ nullable: true,

我有一个所有字段都可以为空的数据模型,因为数据集现在不一致,但我仍然希望处理数据

这是模型的一个片段:

@ObjectType()
@Entity()
export class SomeEntity extends BaseEntity {

    @PrimaryGeneratedColumn({
        type: 'bigint',
    })
    @Field()
    id: number;

    @Column({
        nullable: true,
        type: 'text'
    })
    @Field()
    var1: string


    @Column({
        nullable: true,
        type: 'text'
    })
    @Field()
    var2: string
}
但在执行graphQL查询时,我得到以下错误:

 "message": "Cannot return null for non-nullable field SomeEntity.var1",
该字段为null,因为我可以在数据库中检查它,但鉴于我已将null设置为true,我不希望出现此错误


有人有线索吗?谢谢大家。

提示:TypeORM装饰器与字段的GraphQL类型有什么关系?谢谢朋友!您能否提供生成的架构上的代码段?您还需要将
{nullable:true}
传递给
@Field()
装饰程序。