GQL中省略字段的不良要求
在运行突变时,我会得到带有消息“责任”的“不良请求”响应。我不知道为什么,因为“ Reamid”字段是可选的。
模式
input CustomerUpdateInput {
name: String
roleId: String
}
updateCustomer(customerId: String!, customer: CustomerUpdateInput!): Customer!
突变(误差)
mutation updateCustomer{
updateCustomer(customerId:"62c6d6ba303c734ef44ea4ed",
customer: {name:"Pablo"}
),
{id, name }
}
突变(无误)
mutation updateCustomer{
updateCustomer(customerId:"62c6d6ba303c734ef44ea4ed",
customer: {
name:"Pablo",
roleId:"62c6d64f303c734ef44ea4d8"
}
),
{id, name }
}
误差
{
"errors": [
{
"message": "Bad Request Exception",
"extensions": {
"code": "BAD_USER_INPUT",
"response": {
"statusCode": 400,
"message": [
"roleId must be a string"
],
"error": "Bad Request"
}
}
}
],
"data": null
}
I'm getting "Bad request" response with message "roleId must be a string" when running a mutation. I don't know why since the "roleId" field is optional.
Schema
input CustomerUpdateInput {
name: String
roleId: String
}
updateCustomer(customerId: String!, customer: CustomerUpdateInput!): Customer!
Mutation (ERROR)
mutation updateCustomer{
updateCustomer(customerId:"62c6d6ba303c734ef44ea4ed",
customer: {name:"Pablo"}
),
{id, name }
}
Mutation (WITHOUT ERROR)
mutation updateCustomer{
updateCustomer(customerId:"62c6d6ba303c734ef44ea4ed",
customer: {
name:"Pablo",
roleId:"62c6d64f303c734ef44ea4d8"
}
),
{id, name }
}
Error
{
"errors": [
{
"message": "Bad Request Exception",
"extensions": {
"code": "BAD_USER_INPUT",
"response": {
"statusCode": 400,
"message": [
"roleId must be a string"
],
"error": "Bad Request"
}
}
}
],
"data": null
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论