【问题标题】:why does this graphql update all records?为什么这个 graphql 会更新所有记录?
【发布时间】:2020-05-27 23:45:45
【问题描述】:
mutation {
  update_orders(where: { status: null }, _set: {status: OPEN } ) {
    returning {
      id
      status
    }
  }
}

这是一个错误,还是我误解了 graphql 中的 null?此查询正在更新所有订单。我只打算更新状态为空的订单。这是怎么回事?

干杯!

【问题讨论】:

  • 不是查询是最重要的-但后端实现-它支持什么参数和如何-检查它(api规范)然后根据需要调整查询,没有通用/标准化语法

标签: graphql hasura


【解决方案1】:
mutation {
  update_orders(where: { status: { _is_null: true } }, _set: { status: OPEN } ) {
    returning {
      id
      status
    }
  }
}

相关文档:https://hasura.io/docs/1.0/graphql/manual/queries/query-filters.html#filter-or-check-for-null-values-is-null

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-23
    • 1970-01-01
    • 2020-08-18
    • 1970-01-01
    相关资源
    最近更新 更多