Nest JS GraphQL“无法为不可为null的返回null”
我试图解决学习代码中的一个错误,但失败了。然后我只是尝试启动此代码...
和相同的情况...
错误看起来像
{
"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
}
有人有想法吗?
回答如下:使该属性可为空,或确保您不返回null作为值。
Nest JS GraphQL“无法为不可为null的返回null”
我试图解决学习代码中的一个错误,但失败了。然后我只是尝试启动此代码...
和相同的情况...
错误看起来像
{
"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
}
有人有想法吗?
回答如下:使该属性可为空,或确保您不返回null作为值。