我试图解决学习代码中的一个错误,但失败了。然后我就试着启动这段代码。
https://github.com/nestjs/nest/tree/master/sample/23-type-graphql
同样的情况..。
错误看上去
{
"errors": [
{
"message": "Cannot return null for non-nullable field Recipe.id.",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"recipe",
"id"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"Error: Cannot return null for non-nullable field Recipe.id.",
" at completeValue (/home/innistry/Downloads/nest-master/sample/23-type-graphql/node_modules/graphql/execution/execute.js:560:13)",
" at /home/innistry/Downloads/nest-master/sample/23-type-graphql/node_modules/graphql/execution/execute.js:492:16",
" at process._tickCallback (internal/process/next_tick.js:68:7)"
]
}
}
}
],
"data": null
}有人有主意吗?
发布于 2019-09-30 06:01:01
这是最快的修正,刚刚启动。
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[];
}https://stackoverflow.com/questions/58140891
复制相似问题