Graphql-engine: How to do? Or Statement on Same Column

Created on 17 Apr 2020  路  4Comments  路  Source: hasura/graphql-engine

Given query not working

query ances {
  places(where: {_or: {country: {_like: "an%", _like: "an"}}}) {
    id
    country
  }
}

Expected

Place Load (102.6ms)  SELECT "places".* FROM "places" WHERE ("places"."country" LIKE 'an%' OR "places"."country" = 'an')
question

All 4 comments

Try:

query ances {
  places(where: {_or: [{country: {_like: "an%"}}, {country: {_like: "an"}}] }) {
    id
    country
  }
}

Just fyi, in this particular example, your first condition will subsume your second condition i.e. like 'an%' will also match an

@tirumaraiselvan Thank you, it worked. I couldn't find it in the document. Wouldn't it be good to be included in the document?

@fastengineer It is mentioned here: https://hasura.io/docs/1.0/graphql/manual/queries/query-filters.html#using-multiple-filters-in-the-same-query-and-or

You can also use the search bar on the top to search for a query like "multiple or" and the first result is the above.

Closing the issue now.

I can also recommend joining our community on Discord https://discordapp.com/invite/hasura for more syntax related queries.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stereobooster picture stereobooster  路  3Comments

Fortidude picture Fortidude  路  3Comments

egislook picture egislook  路  3Comments

hooopo picture hooopo  路  3Comments

lishine picture lishine  路  3Comments