Skip to content

Commit fa20501

Browse files
Merge pull request #195 from MacondoExpress/_EQ
Update filtering examples by using `_EQ` and add migration guide
2 parents 335a622 + 499230e commit fa20501

File tree

20 files changed

+107
-70
lines changed

20 files changed

+107
-70
lines changed

modules/ROOT/pages/migration/index.adoc

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ a|
5454
[source, graphql, indent=0]
5555
----
5656
query {
57-
movies(where: { NOT: { title: "The Matrix" } }) {
57+
movies(where: { NOT: { title_EQ: "The Matrix" } }) {
5858
title
5959
}
6060
}
@@ -78,7 +78,7 @@ a|
7878
[source, graphql, indent=0]
7979
----
8080
query {
81-
movies(where: { actors_NOT: { name: "Keanu" } }) {
81+
movies(where: { actors_NOT: { name_EQ: "Keanu" } }) {
8282
title
8383
}
8484
}
@@ -87,7 +87,7 @@ a|
8787
[source, graphql, indent=0]
8888
----
8989
query {
90-
movies(where: { actors_NONE: { name: "Keanu" } }) {
90+
movies(where: { actors_NONE: { name_EQ: "Keanu" } }) {
9191
title
9292
}
9393
}
@@ -96,6 +96,43 @@ query {
9696

9797
== Deprecations and warnings
9898

99+
=== Implicit equality filters are deprecated
100+
101+
The following implicit equality filters are deprecated:
102+
103+
- `{ name: "Keanu" }`
104+
- `{ count: 10 }`
105+
106+
You can achieve the same by using `{ name_EQ: "Keanu" }` and `{ count_EQ: 10 }`.
107+
The deprecated quality filters will be removed in version 7.x.
108+
109+
[cols="1,1"]
110+
|===
111+
|Before | Now
112+
113+
a|
114+
[source, graphql, indent=0]
115+
----
116+
query {
117+
users(where: { name: "John" }) {
118+
id
119+
name
120+
}
121+
}
122+
----
123+
a|
124+
[source, graphql, indent=0]
125+
----
126+
query {
127+
users(where: { name_EQ: "John" }) {
128+
id
129+
name
130+
}
131+
}
132+
----
133+
|===
134+
135+
99136
=== `@node` will have to be explicitly defined
100137

101138
In the future, types without the `@node` directive will no longer be treated as Neo4j nodes.

modules/ROOT/pages/mutations/create.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ mutation {
140140
name: "Tom Hanks",
141141
movies: {
142142
connectOrCreate: {
143-
where: { node: { id: "1234" } }
143+
where: { node: { id_EQ: "1234" } }
144144
onCreate: { node: { title: "Forrest Gump" } }
145145
}
146146
}

modules/ROOT/pages/mutations/delete.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ A single post can be deleted by executing the following GraphQL statement:
4949
----
5050
mutation {
5151
deletePosts(where: {
52-
id: "6042E807-47AE-4857-B7FE-1AADF522DE8B"
52+
id_EQ: "6042E807-47AE-4857-B7FE-1AADF522DE8B"
5353
}) {
5454
nodesDeleted
5555
relationshipsDeleted
@@ -67,7 +67,7 @@ In case you want to delete a `User` *and* all of their posts, you can use a sing
6767
[source, graphql, indent=0]
6868
----
6969
mutation {
70-
deleteUsers(where: { name: "Jane Doe" }, delete: { posts: {} }) {
70+
deleteUsers(where: { name_EQ: "Jane Doe" }, delete: { posts: {} }) {
7171
nodesDeleted
7272
relationshipsDeleted
7373
}
@@ -82,14 +82,14 @@ Essentially, the above query is equivalent to:
8282
mutation {
8383
deleteUsers(
8484
where: {
85-
name: "Jane Doe"
85+
name_EQ: "Jane Doe"
8686
},
8787
delete: {
8888
posts: [
8989
where: {
9090
node: {
9191
creator: {
92-
name: "Jane Doe"
92+
name_EQ: "Jane Doe"
9393
}
9494
}
9595
}

modules/ROOT/pages/mutations/update.adoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ The content of a `Post` can be updated by executing the following GraphQL statem
5959
mutation {
6060
updatePosts(
6161
where: {
62-
id: "892CC104-A228-4BB3-8640-6ADC9F2C2A5F"
62+
id_EQ: "892CC104-A228-4BB3-8640-6ADC9F2C2A5F"
6363
}
6464
update: {
6565
content: "Some new content for this Post!"
@@ -82,7 +82,7 @@ Instead of creating a `Post` with the `create` mutation and then connecting it t
8282
----
8383
mutation {
8484
updateUsers(
85-
where: { name: "John Doe" }
85+
where: { name_EQ: "John Doe" }
8686
update: {
8787
posts: {
8888
create: [
@@ -113,7 +113,7 @@ mutation {
113113
name: "Tom Hanks",
114114
movies: {
115115
connectOrCreate: {
116-
where: { node: { id: "1234" } }
116+
where: { node: { id_EQ: "1234" } }
117117
onCreate: { node: { title: "Forrest Gump" } }
118118
}
119119
}
@@ -134,12 +134,12 @@ mutation {
134134
update: {
135135
movies: {
136136
connectOrCreate: {
137-
where: { node: { id: "1234" } }
137+
where: { node: { id_EQ: "1234" } }
138138
onCreate: { node: { title: "Forrest Gump" } }
139139
}
140140
}
141141
},
142-
where: { name: "Tom Hanks" }
142+
where: { name_EQ: "Tom Hanks" }
143143
) {
144144
info {
145145
nodesCreated
@@ -462,7 +462,7 @@ Here is how you can do that:
462462
----
463463
mutation incrementViewCountMutation {
464464
updateVideos(
465-
where: { id: "VideoID" }
465+
where: { id_EQ: "VideoID" }
466466
update: { views_INCREMENT: 1 }
467467
) {
468468
videos {
@@ -480,7 +480,7 @@ To do that, you have to update the relationship property `revenue`:
480480
----
481481
mutation addRevenueMutation {
482482
updateUsers(
483-
where: { id: "UserID" },
483+
where: { id_EQ: "UserID" },
484484
update: { ownVideo: [{ update: { edge: { revenue_ADD: 0.01 } } }] }
485485
) {
486486
users {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ query {
3030
]
3131
},
3232
{
33-
movies_SOME: { title: "The Matrix" }
33+
movies_SOME: { title_EQ: "The Matrix" }
3434
}
3535
]}
3636
) {
@@ -54,7 +54,7 @@ For example:
5454
[source, graphql, indent=0]
5555
----
5656
query {
57-
users(where: {name: "John" })
57+
users(where: { name_EQ: "John" })
5858
id
5959
name
6060
}
@@ -66,7 +66,7 @@ For non-equality, you must use the xref:/queries-aggregations/filtering.adoc#_bo
6666
[source, graphql, indent=0]
6767
----
6868
query {
69-
users(where: { NOT: {name: "John" }})
69+
users(where: { NOT: { name_EQ: "John" }})
7070
id
7171
name
7272
}
@@ -376,7 +376,7 @@ For example:
376376
[source, graphql, indent=0]
377377
----
378378
query {
379-
posts(where: { author: { id: "7CF1D9D6-E527-4ACD-9C2A-207AE0F5CB8C" } }) {
379+
posts(where: { author: { id_EQ: "7CF1D9D6-E527-4ACD-9C2A-207AE0F5CB8C" } }) {
380380
content
381381
}
382382
}
@@ -386,7 +386,7 @@ query {
386386
[source, graphql, indent=0]
387387
----
388388
query {
389-
posts(where: { NOT: { author: { id: "7CF1D9D6-E527-4ACD-9C2A-207AE0F5CB8C" } } }) {
389+
posts(where: { NOT: { author: { id_EQ: "7CF1D9D6-E527-4ACD-9C2A-207AE0F5CB8C" } } }) {
390390
content
391391
}
392392
}

modules/ROOT/pages/queries-aggregations/pagination/cursor-based.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ If you wanted to fetch the posts of user "John Smith" 10 at a time, you would fi
2424
[source, graphql, indent=0]
2525
----
2626
query {
27-
users(where: { name: "John Smith" }) {
27+
users(where: { name_EQ: "John Smith" }) {
2828
name
2929
postsConnection(first: 10) {
3030
edges {
@@ -46,7 +46,7 @@ In the return value, if `hasNextPage` is `true`, you would pass `endCursor` into
4646
[source, graphql, indent=0]
4747
----
4848
query Users($after: String) {
49-
users(where: { name: "John Smith" }) {
49+
users(where: { name_EQ: "John Smith" }) {
5050
name
5151
postsConnection(first: 10, after: $after) {
5252
edges {
@@ -72,7 +72,7 @@ The Connection fields also offer a `totalCount` field which can be used to calcu
7272
[source, graphql, indent=0]
7373
----
7474
query Users($after: String) {
75-
users(where: { name: "John Smith" }) {
75+
users(where: { name_EQ: "John Smith" }) {
7676
name
7777
postsConnection(first: 10) {
7878
edges {

modules/ROOT/pages/queries-aggregations/pagination/offset-based.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Say that in addition to the `User` type above, there is also a `Post` type which
7272
----
7373
query {
7474
users(where: {
75-
name: "Billy"
75+
name_EQ: "Billy"
7676
}) {
7777
name
7878
posts(options: {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ query {
6060
[source, graphql, indent=0]
6161
----
6262
query {
63-
users(where: { name: "Jane Smith" }) {
63+
users(where: { name_EQ: "Jane Smith" }) {
6464
id
6565
name
6666
posts {

modules/ROOT/pages/security/authorization.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type User @node {
3434
}
3535
3636
type Post @node @authorization(filter: [
37-
{ where: { node: { author: { id: "$jwt.sub" } } } }
37+
{ where: { node: { author: { id_EQ: "$jwt.sub" } } } }
3838
]) {
3939
title: String!
4040
content: String!
@@ -58,7 +58,7 @@ For instance, to only require filtering for the reading and aggregating posts:
5858
[source, graphql, indent=0]
5959
----
6060
type Post @node @authorization(filter: [
61-
{ operations: [READ, AGGREGATE] where: { node: { author: { id: "$jwt.sub" } } } }
61+
{ operations: [READ, AGGREGATE] where: { node: { author: { id_EQ: "$jwt.sub" } } } }
6262
]) {
6363
title: String!
6464
content: String!
@@ -87,7 +87,7 @@ type JWT @jwt {
8787
}
8888
8989
type User @node @authorization(validate: [
90-
{ where: { node: { id: "$jwt.sub" } } }
90+
{ where: { node: { id_EQ: "$jwt.sub" } } }
9191
{ where: { jwt: { roles_INCLUDES: "admin" } } }
9292
]) {
9393
id: ID!
@@ -112,7 +112,7 @@ For instance, to only require validation for the update or deletion of a post:
112112
[source, graphql, indent=0]
113113
----
114114
type Post @node @authorization(validate: [
115-
{ operations: [UPDATE, DELETE] where: { node: { author: { id: "$jwt.sub" } } } }
115+
{ operations: [UPDATE, DELETE] where: { node: { author: { id_EQ: "$jwt.sub" } } } }
116116
]) {
117117
title: String!
118118
content: String!
@@ -140,8 +140,8 @@ type User @node {
140140
}
141141
142142
type Post @node @authorization(filter: [
143-
{ where: { node: { author: { id: "$jwt.sub" } } } }
144-
{ requireAuthentication: false, operations: [READ], where: { node: { public: true } } }
143+
{ where: { node: { author: { id_EQ: "$jwt.sub" } } } }
144+
{ requireAuthentication: false, operations: [READ], where: { node: { public_EQ: true } } }
145145
]) {
146146
title: String!
147147
content: String!

modules/ROOT/pages/security/operations.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ For single `delete` mutations, rules with `DELETE` on the object are evaluated:
6363
[source, graphql, indent=0]
6464
----
6565
mutation {
66-
deleteMovies(where: { title: "The Matrix" }) { # DELETE ON OBJECT Movie
66+
deleteMovies(where: { title_EQ: "The Matrix" }) { # DELETE ON OBJECT Movie
6767
nodesDeleted
6868
}
6969
}
@@ -75,8 +75,8 @@ For `delete` mutations with nested delete operations, rules with operation `DELE
7575
----
7676
mutation {
7777
deleteMovies( # DELETE ON OBJECT Movie
78-
where: { title: "The Matrix" }
79-
delete: { actors: { where: { node: { name: "Keanu" } } } } # DELETE ON OBJECT Actor
78+
where: { title_EQ: "The Matrix" }
79+
delete: { actors: { where: { node: { name_EQ: "Keanu" } } } } # DELETE ON OBJECT Actor
8080
) {
8181
nodesDeleted
8282
}
@@ -89,8 +89,8 @@ For a complex `update` mutation with many effects, a variety of rules is evaluat
8989
----
9090
mutation {
9191
updateMovies(
92-
where: { title: "The Matrix" }
93-
connect: { actors: { where: { node: { name: "Keanu" } } } } # CONNECT ON OBJECT Actor and Movie
92+
where: { title_EQ: "The Matrix" }
93+
connect: { actors: { where: { node: { name_EQ: "Keanu" } } } } # CONNECT ON OBJECT Actor and Movie
9494
update: { # UPDATE ON OBJECT Movie
9595
title: "Speed" # UPDATE ON FIELD_DEFINITION Movie.title
9696
}

0 commit comments

Comments
 (0)