You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -11,7 +11,7 @@ All types can be tested for either equality.
11
11
For non-equality, you *must* use the xref:/queries-aggregations/filtering.adoc#_combining_operators[`NOT`] logical operator.
12
12
For example:
13
13
14
-
.Filtering all Users named John
14
+
.Filtering all users named John
15
15
[source, graphql, indent=0]
16
16
----
17
17
query {
@@ -37,7 +37,7 @@ These are the operators available for numeric (`Int`, `Float`, xref::/types/scal
37
37
38
38
Here is an example of how to use them:
39
39
40
-
.Filtering Users younger than 50 years old
40
+
.Filtering users younger than 50 years old
41
41
[source, graphql, indent=0]
42
42
----
43
43
query {
@@ -50,10 +50,66 @@ query {
50
50
----
51
51
52
52
Spatial types use numerical filtering differently and they also have additional options.
53
-
See xref::/types/spatial.adoc#_filtering[Spatial types filtering] for more information.
53
+
See xref:filtering.adoc#_spatial_types[Spatial types] for more information.
54
54
55
-
These same operators are disabled by default in the case of String comparisons.
56
-
To enable, explicitly add them in the features options:
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
+
88
+
89
+
== String comparison
90
+
91
+
The following case-sensitive comparison operators are only available for use on `String` and `ID` types:
92
+
93
+
* `_STARTS_WITH`
94
+
* `_ENDS_WITH`
95
+
* `_CONTAINS`
96
+
97
+
Here is an example of how to use them:
98
+
99
+
.Filtering users with name starting with "J"
100
+
[source, graphql, indent=0]
101
+
----
102
+
query {
103
+
users(where: { name_STARTS_WITH: "J" }) {
104
+
id
105
+
name
106
+
}
107
+
}
108
+
----
109
+
110
+
Additionally, numerical operators can be used for String comparisons.
111
+
They are disabled default.
112
+
To enable them, add them in the `filters` features options for `String`:
57
113
58
114
[source, javascript, indent=0]
59
115
----
@@ -85,28 +141,6 @@ const features = {
85
141
const neoSchema = new Neo4jGraphQL({ features, typeDefs, driver });
86
142
----
87
143
88
-
89
-
== String comparison
90
-
91
-
The following case-sensitive comparison operators are only available for use on `String` and `ID` types:
92
-
93
-
* `_STARTS_WITH`
94
-
* `_ENDS_WITH`
95
-
* `_CONTAINS`
96
-
97
-
Here is an example of how to use them:
98
-
99
-
.Filtering Users with name starting with "J"
100
-
[source, graphql, indent=0]
101
-
----
102
-
query {
103
-
users(where: { name_STARTS_WITH: "J" }) {
104
-
id
105
-
name
106
-
}
107
-
}
108
-
----
109
-
110
144
== RegEx matching
111
145
112
146
The filter `_MATCHES` is also available for comparison of `String` and `ID` types.
@@ -178,39 +212,67 @@ Conversely, the following operator is available on array fields, and accepts a s
178
212
179
213
These operators are available for all types apart from `Boolean`.
180
214
181
-
== Logical operators
215
+
== Filtering spatial types
182
216
183
-
All operators can be combined using the logical operators `AND`, `OR`, and `NOT`.
184
-
They can also be standalone operators, which means that they can be used as such and not be appended to field names.
217
+
Both the `Point` and the `CartesianPoint` types use xref::queries-aggregations/filtering.adoc#_numerical_operators[numerical operators] and have an additional `_DISTANCE` filter.
218
+
Here is a list of what each filter does for the two types:
185
219
186
-
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.
220
+
* `_LT`: checks if a point is less than the distance in the `distance` field away (in meters) from the point specified by the `point` field.
221
+
* `_LTE`: checks if a point is less than or equal to the distance in the `distance` field away (in meters) from the point specified by the `point` field.
222
+
* `_DISTANCE`: checks if a point is the exact distance in the `distance` field away (in meters) from the point specified by the `point` field.
223
+
* `_GT`: checks if a point is greater than the distance in the `distance` field away (in meters) from the point specified by the `point` field.
224
+
* `_GTE`: checks if a point is greater than or equal to the distance in the `distance` field away (in meters) from the point specified by the `point` field.
187
225
188
-
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:
226
+
For a `Point` type, all filters take the following type as an argument:
189
227
190
228
[source, graphql, indent=0]
191
229
----
192
-
query {
193
-
actors(where: {
194
-
AND: [
195
-
{
196
-
OR: [
197
-
{ name_CONTAINS: "Keanu" },
198
-
{ NOT: { name_ENDS_WITH: "Pantoliano" } }
199
-
]
200
-
},
201
-
{
202
-
movies_SOME: { title: "The Matrix" }
203
-
}
204
-
]}
205
-
) {
230
+
input PointDistance {
231
+
point: Point!
232
+
distance: Float!
233
+
}
234
+
----
235
+
236
+
In practice, you can construct queries like the following, which finds all users within a 5km (5000m) radius of a `Point`:
Copy file name to clipboardExpand all lines: modules/ROOT/pages/types/spatial.adoc
+6-64Lines changed: 6 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ The use of either of these types in a GraphQL schema automatically introduces th
14
14
15
15
The `Point` type is used to describe the two https://neo4j.com/docs/cypher-manual/current/values-and-types/spatial/#spatial-values-crs-geographic[Geographic coordinate reference systems] supported by Neo4j.
16
16
17
-
In order to use it in your schema, you quite simply add a field with a type `Point` to any type or types in schema, like the following:
17
+
In order to use it in your schema, add a field with a type `Point` to any other type(s) in your schema, like the following:
18
18
19
19
[source, graphql, indent=0]
20
20
----
@@ -23,9 +23,9 @@ type TypeWithPoint {
23
23
}
24
24
----
25
25
26
-
Once this has been done, the `Point` type is automatically added to your schema, in addition to all of the input and output types you need to query and manipulate spatial types through your API.
26
+
The `Point` type is automatically added to your schema, in addition to the input and output types that you need to query and manipulate spatial types through your API.
27
27
28
-
These are the automatically generated types and how to use them:
28
+
See xref::queries-aggregations/filtering.adoc#_filtering_spatial_types[Filtering spatial types] for filter options.
Besides the xref::queries-aggregations/filtering.adoc#filtering-numerical-operators[Numerical operators], the `Point` type has an additional `_DISTANCE` filter.
90
-
Here is a list of what each filter does:
91
-
92
-
* `_LT`: checks that the specified `Point` field is less than the `distance` away in meters from the `Point` being compared against.
93
-
* `_LTE`: checks that the specified `Point` field is less than or equal to the `distance` away in meters from the `Point` being compared against.
94
-
* `_DISTANCE`: checks that the specified `Point` field is the exact `distance` away in meters from the `Point` being compared against.
95
-
* `_GTE`: checks that the specified `Point` field is greater than the `distance` away in meters from the `Point` being compared against.
96
-
* `_GT`: checks that the specified `Point` field is greater than or equal to the `distance` away in meters from the `Point` being compared against.
97
-
98
-
All of the filters take the following type as an argument:
99
-
100
-
[source, graphql, indent=0]
101
-
----
102
-
input PointDistance {
103
-
point: Point!
104
-
distance: Float!
105
-
}
106
-
----
107
-
108
-
In practice, you can construct queries such as the following which can find all users within a 5km (5000m) radius of a `Point`:
The `CartesianPoint` type is used to describe the two https://neo4j.com/docs/cypher-manual/current/values-and-types/spatial/#spatial-values-crs-cartesian[Cartesian coordinate reference systems] supported by Neo4j.
127
91
128
-
To use it in the schema, add a field with a type `CartesianPoint` to any type or types, such as in this example:
92
+
To use it in your schema, add a field with a type `CartesianPoint` to any type(s), such as in this example:
129
93
130
94
[source, graphql, indent=0]
131
95
----
@@ -134,9 +98,9 @@ type TypeWithCartesianPoint {
134
98
}
135
99
----
136
100
137
-
Once this has been done, the `CartesianPoint` type is automatically added to your schema, in addition to all of the input and output types you will need to query and manipulate spatial types through your API.
101
+
The `CartesianPoint` type is automatically added to your schema, in addition to the input and output types that you need to query and manipulate spatial types through your API.
138
102
139
-
These are the automatically generated types and how to use them:
103
+
See xref::queries-aggregations/filtering.adoc#_filtering_spatial_types[Filtering spatial types] for filter options.
140
104
141
105
==== Type definition
142
106
@@ -162,25 +126,3 @@ input CartesianPointInput {
162
126
z: Float
163
127
}
164
128
----
165
-
166
-
==== Filtering
167
-
168
-
Besides the xref::queries-aggregations/filtering.adoc#filtering-numerical-operators[Numerical operators], the `CartesianPoint` type has an additional `_DISTANCE` filter.
169
-
170
-
Here is a list of what each filter does:
171
-
172
-
* `_LT`: checks that the specified `Point` field is less than the `distance` away from the `CartesianPoint` being compared against, in the units used to specify the points.
173
-
* `_LTE`: checks that the specified `Point` field is less than or equal to the `distance` away from the `CartesianPoint` being compared against, in the units used to specify the points.
174
-
* `_DISTANCE`: checks that the specified `Point` field is the exact `distance` away from the `CartesianPoint` being compared against, in the units used to specify the points.
175
-
* `_GTE`: checks that the specified `Point` field is greater than the `distance` away from the `CartesianPoint` being compared against, in the units used to specify the points.
176
-
* `_GT`: checks that the specified `Point` field is greater than or equal to the `distance` away from the `CartesianPoint` being compared against, in the units used to specify the points.
177
-
178
-
All of the filters take the following type as an argument:
0 commit comments