【发布时间】:2021-06-13 00:39:54
【问题描述】:
我不知道我错过了什么,但突变或查询的输入始终为空 当我调试时似乎输入是空对象
这是我的代码:
解析器
@Query(() => String)
async testMutation(@Args('args') args: UpvotePostInput) {
return args.postId;
}
dto
import { InputType, Field } from '@nestjs/graphql';
@InputType()
export class UpvotePostInput {
@Field(() => String)
postId: string;
}
错误
{
"errors": [
{
"message": "Cannot return null for non-nullable field Query.testMutation.",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"testMutation"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"Error: Cannot return null for non-nullable field Query.testMutation.",
" at completeValue (/....js:559:13)",
" at /.....xecute.js:469:16",
" at processTicksAndRejections (internal/process/task_queues.js:97:5)",
" at async Promise.all (index 0)"
]
}
}
}
],
"data": null
}
【问题讨论】:
-
你认为指令语法无关紧要吗?