Skip to content

Commit 8023693

Browse files
committed
docs: logical operators
1 parent c338320 commit 8023693

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

pages/en/querying/graphql-api.mdx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,56 @@ This can be useful if you are looking to fetch only entities whose child-level e
168168
}
169169
```
170170

171+
#### Logical operators
172+
173+
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.
174+
175+
##### `AND` Operator
176+
177+
In the following example, we are filtering for challenges with `outcome` `succeeded` and `number` greater than or equal to `100`.
178+
179+
```graphql
180+
{
181+
challenges(where: { and: [{ number_gte: 100 }, { outcome: "succeeded" }] }) {
182+
challenger
183+
outcome
184+
application {
185+
id
186+
}
187+
}
188+
}
189+
```
190+
191+
> **Syntactic sugar:** You can simplify the above query by removing the `and` operator by passing a sub-expression separated by commas.
192+
>
193+
> ```graphql
194+
> {
195+
> challenges(where: { number_gte: 100, outcome: "succeeded" }) {
196+
> challenger
197+
> outcome
198+
> application {
199+
> id
200+
> }
201+
> }
202+
> }
203+
> ```
204+
205+
##### `OR` Operator
206+
207+
In the following example, we are filtering for challenges with `outcome` `succeeded` or `number` greater than or equal to `100`.
208+
209+
```graphql
210+
{
211+
challenges(where: { or: [{ number_gte: 100 }, { outcome: "succeeded" }] }) {
212+
challenger
213+
outcome
214+
application {
215+
id
216+
}
217+
}
218+
}
219+
```
220+
171221
#### All Filters
172222

173223
Full list of parameter suffixes:

0 commit comments

Comments
 (0)