Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: logical operators #308

Merged
merged 2 commits into from
Mar 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions website/pages/en/querying/graphql-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,56 @@ This can be useful if you are looking to fetch only entities whose child-level e
}
```

#### Logical operators

You can group multiple parameters in the same `where` argument using the `and` or the `or` operators to filter results based on more than one criteria.
saihaj marked this conversation as resolved.
Show resolved Hide resolved

##### `AND` Operator

In the following example, we are filtering for challenges with `outcome` `succeeded` and `number` greater than or equal to `100`.

```graphql
{
challenges(where: { and: [{ number_gte: 100 }, { outcome: "succeeded" }] }) {
challenger
outcome
application {
id
}
}
}
```

> **Syntactic sugar:** You can simplify the above query by removing the `and` operator by passing a sub-expression separated by commas.
>
> ```graphql
> {
> challenges(where: { number_gte: 100, outcome: "succeeded" }) {
> challenger
> outcome
> application {
> id
> }
> }
> }
> ```

##### `OR` Operator

In the following example, we are filtering for challenges with `outcome` `succeeded` or `number` greater than or equal to `100`.

```graphql
{
challenges(where: { or: [{ number_gte: 100 }, { outcome: "succeeded" }] }) {
challenger
outcome
application {
id
}
}
}
```

saihaj marked this conversation as resolved.
Show resolved Hide resolved
#### All Filters

Full list of parameter suffixes:
Expand Down