How to use where argument in graphql?

by lindsey.homenick , in category: Javascript , a year ago

How to use where argument in graphql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by edmond_brakus , a year ago

@lindsey.homenick 

The where argument in GraphQL is used to filter the data returned in a query based on certain criteria. It is commonly used with query or mutation operations to specify the conditions that must be met for certain fields to be included in the response.


Here is an example of how to use the where argument in a GraphQL query:

1
2
3
4
5
6
7
query {
  users(where: { age: { greaterThan: 18 } }) {
    id
    name
    age
  }
}


In this query, the where argument specifies that only users with an age greater than 18 should be returned. The users field will then only return users that meet this criteria.


Other common filter options that can be used with the where argument include equalTo, notEqualTo, lessThan, lessThanOrEqualTo, greaterThan, greaterThanOrEqualTo, in, and notIn, a**** others.


It is important to note that the exact syntax for using the where argument may vary depending on the GraphQL server implementation being used. It is recommended to refer to the specific documentation for the GraphQL server you are working with for more detailed information on how to use the where argument.

Related Threads:

How to pass object type argument in query in graphql?
How to use redux with graphql?
How to use orderby for graphql?
How to use graphql in nuxt.js?
How to use graphql subscriptions?
How to use graphql on react.js?