Skip to content

Commit 5b1c628

Browse files
committed
rephrasing and section shifting
1 parent f83a93b commit 5b1c628

File tree

1 file changed

+49
-36
lines changed

1 file changed

+49
-36
lines changed

modules/ROOT/pages/queries-aggregations/filtering.adoc

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,46 @@
33
:page-aliases: filtering.adoc
44
:description: This page describes filtering operators.
55

6-
When querying for data, a number of operators are available for different types in the `where` argument of a query or mutation.
6+
When querying for data, a number of operators are available for the types in the `where` argument of a query or mutation, allowing you to filter query results.
7+
8+
Operators can either be standalone operators (see xref:#_boolean_operators) or they are appended to field names (for example, xref:/queries-aggregations/filtering.adoc#_boolean_operators[`NOT`]).
9+
10+
All operators can be combined using the Boolean operators `AND`, `OR`, and `NOT`.
11+
12+
== Boolean operators
13+
14+
As standalone operators, Boolean operators accept an array argument with items of the same format as the `where` argument.
15+
This way, they can be nested to form complex Boolean expressions.
16+
17+
For example, if you want to match all actors by the name of either "Keanu" or not belonging to the "Pantoliano" family, who played in "The Matrix" movie, here is how you query that:
18+
19+
[source, graphql, indent=0]
20+
----
21+
query {
22+
actors(where: {
23+
AND: [
24+
{
25+
OR: [
26+
{ name_CONTAINS: "Keanu" },
27+
{ NOT: { name_ENDS_WITH: "Pantoliano" } }
28+
]
29+
},
30+
{
31+
movies_SOME: { title: "The Matrix" }
32+
}
33+
]}
34+
) {
35+
name
36+
movies {
37+
title
38+
}
39+
}
40+
}
41+
----
742

843
== Equality operators
944

10-
All types can be tested for either equality.
11-
For non-equality, you *must* use the xref:/queries-aggregations/filtering.adoc#_logical_operators[`NOT`] logical operator.
45+
All types can be tested for equality or non-equality.
1246
For example:
1347

1448
.Filtering all users named John
@@ -21,6 +55,18 @@ query {
2155
}
2256
----
2357

58+
For non-equality, you must use the xref:/queries-aggregations/filtering.adoc#_boolean_operators[`NOT`] logical operator.
59+
60+
.Filtering all users which are not named John
61+
[source, graphql, indent=0]
62+
----
63+
query {
64+
users(where: { NOT: {name: "John" }})
65+
id
66+
name
67+
}
68+
----
69+
2470
[NOTE]
2571
====
2672
For the `Boolean` type, equality operators are the only ones available.
@@ -52,39 +98,6 @@ query {
5298
Spatial types use numerical filtering differently and they also have additional options.
5399
See xref:filtering.adoc#_filtering_spatial_types[Filtering spatial types] for more information.
54100

55-
== Logical operators
56-
57-
All operators can be combined using the logical operators `AND`, `OR`, and `NOT`.
58-
They can also be standalone operators, which means that they can be used as such and not be appended to field names.
59-
60-
These operators accept an array argument with items of the same format as the `where` argument, which means they can also be nested to form complex combinations.
61-
62-
For example, if you want to match all actors by the name of either "Keanu" or not belonging to the "Pantoliano" family, that played in "The Matrix" movie, here is how you can query that:
63-
64-
[source, graphql, indent=0]
65-
----
66-
query {
67-
actors(where: {
68-
AND: [
69-
{
70-
OR: [
71-
{ name_CONTAINS: "Keanu" },
72-
{ NOT: { name_ENDS_WITH: "Pantoliano" } }
73-
]
74-
},
75-
{
76-
movies_SOME: { title: "The Matrix" }
77-
}
78-
]}
79-
) {
80-
name
81-
movies {
82-
title
83-
}
84-
}
85-
}
86-
----
87-
88101

89102
== String comparison
90103

0 commit comments

Comments
 (0)