GQL中省略字段的不良要求

发布于 2025-02-14 00:17:35 字数 1243 浏览 1 评论 0原文

在运行突变时,我会得到带有消息“责任”的“不良请求”响应。我不知道为什么,因为“ 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文