【问题标题】:Use OR instead of AND in GraphQL boolean expression query在 GraphQL 布尔表达式查询中使用 OR 而不是 AND
【发布时间】:2019-10-07 03:03:00
【问题描述】:

我正在使用图形 QL 查询填充表:

graphql 查询看起来像:

const DESSERT_QUERY = gql`
    query DESSERT_QUERY($where: dessert_bool_exp) {
      dessert(where: $where) {
        name 
        calories
        fat
        carbs
      }
    }
  `;

查询变量:

{"where": 
    {
    "name": {
      "_in": ["xyz"]
    },
    "calories": {
      "_eq": 1
    },
     "fat": {
      "_eq": 606
    },
    "carbs": {
      "_eq": 1
    },
    } 
}

如何实现 OR 查询。

感谢任何指导。谢谢

【问题讨论】:

    标签: graphql apollo-client hasura


    【解决方案1】:
    The correct GraphQL Query Variables is : 
    
     {"where": 
            {
            "name": {
              "_in": ["xyz"]
            },
            "calories": {
              "_eq": 1
            },
            "_or": [{"fat": {
              "_eq": 606
            }},
             {"carbs": {
              "_eq": 1
            }}] 
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-26
      • 1970-01-01
      • 2021-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多