Tanu
Tanu

Reputation: 1640

Use OR instead of AND in GraphQL boolean expression query

I am populating a table using graph QL query :

The graphql query looks like :

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

Query Variables :

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

How to implement an OR query.

Any guidance is appreciated. Thanks

Upvotes: 0

Views: 1322

Answers (1)

Tanu
Tanu

Reputation: 1640

The correct GraphQL Query Variables is : 

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

Upvotes: 2

Related Questions