Skip to content

Commit 6ca8de4

Browse files
committed
review suggestions
1 parent dd9c6bc commit 6ca8de4

File tree

1 file changed

+47
-11
lines changed

1 file changed

+47
-11
lines changed

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

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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 the types in the `where` argument of a query or mutation, allowing you to filter query results.
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 or specify the set of objects a mutation applies to.
77

88
Operators can either be standalone operators (see xref:#_boolean_operators[]) or they are appended to field names (for example, xref:/queries-aggregations/filtering.adoc#_string_comparison[]).
99

@@ -47,6 +47,7 @@ query {
4747
=== Equality operators
4848

4949
All types can be tested for equality or non-equality.
50+
5051
For example:
5152

5253
.Filtering all users named John
@@ -252,8 +253,8 @@ For `ID`:
252253
----
253254
const features = {
254255
filters: {
255-
String: {
256-
ID: true,
256+
ID: {
257+
MATCHES: true,
257258
}
258259
}
259260
};
@@ -263,8 +264,6 @@ const neoSchema = new Neo4jGraphQL({ features, typeDefs, driver });
263264

264265
For both `String` and `ID`:
265266

266-
// Is the following correct? would have expected "filters: { String : { MATCHES: true, ID: true}}" based on the two above
267-
268267
[source, javascript, indent=0]
269268
----
270269
const features = {
@@ -283,17 +282,54 @@ const neoSchema = new Neo4jGraphQL({ features, typeDefs, driver });
283282

284283
=== Array comparison
285284

286-
// We should add examples in this section
285+
Consider the following type definitions:
286+
287+
[source, graphql, indent=0]
288+
----
289+
type Movie {
290+
id: ID!
291+
title: String!
292+
genres: [String!]
293+
year: Int!
294+
actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN)
295+
}
296+
297+
type Actor {
298+
id: ID!
299+
name: String!
300+
movies: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT)
301+
}
302+
----
303+
304+
The `_IN` operator is available on non-array fields, and accepts an array argument:
287305

288-
The following operator is available on non-array fields, and accepts an array argument:
306+
[source, graphql, indent=0]
307+
----
308+
query {
309+
movies(where: { year_IN: [1999, 2000, 2001] }) {
310+
title
311+
year
312+
}
313+
}
314+
----
289315

290-
* `_IN`
316+
The query returns all movies released in the years 1999, 2000 and 2001.
291317

292-
Conversely, the following operator is available on array fields, and accepts a single argument:
318+
Conversely, the `_INCLUDES` operator is available on array fields, and accepts a single argument:
319+
320+
[source, graphql, indent=0]
321+
----
322+
query {
323+
movies(where: { genres_INCLUDES: "Action" }) {
324+
title
325+
genres
326+
}
327+
}
328+
----
293329

294-
* `_INCLUDES`
330+
The query returns all movies which have "Action" as one of their genres.
295331

296-
These operators are available for all types apart from `Boolean`.
332+
`_IN` and `_INCLUDES` are available for all types except `Boolean`.
297333

298334
== Interface filtering
299335

0 commit comments

Comments
 (0)