【问题标题】:Graphql Hasura Update if the field is not null如果字段不为空,Graphql Hasura 更新
【发布时间】:2020-05-01 21:49:33
【问题描述】:

我有一个 graphql 类型,我想根据一列的值对其进行更新。 例如,该类型具有以下列:id、col1、col2、col3,所以我想更新 col3,前提是 col1 有一个值。 我使用 react 作为前端,HASURA 作为后端

【问题讨论】:

    标签: reactjs graphql hasura graphql-mutation


    【解决方案1】:

    您可以使用_is_null 语句来检查列是否有值:

    mutation updateMutation {
      update_myTable(where: {id: {_eq: "id"}, _and: {col_1: {_is_null: false}}}, 
        _set: {col_3: "new value"}) {
        affected_rows
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-10
      • 2016-07-26
      • 2014-03-31
      • 2020-08-23
      • 1970-01-01
      • 2019-09-01
      • 1970-01-01
      相关资源
      最近更新 更多