且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Nest JS GraphQL“不能为不可为空返回空值"

更新时间:2022-05-23 03:09:20

这是最快的解决方案,只需启动即可.

This is the fastest fix, just to launch.

import { Field, ID, ObjectType } from 'type-graphql';

@ObjectType()
export class Recipe {
  @Field(type => ID, { nullable: true })
  id?: string;

  @Field({ nullable: true })
  title?: string;

  @Field({ nullable: true })
  description?: string;

  @Field({ nullable: true })
  creationDate?: Date;

  @Field(type => [String], { nullable: true })
  ingredients?: string[];
}