Skip to content

Commit 27008f4

Browse files
update subscriptions pages
1 parent 9ffa025 commit 27008f4

File tree

4 files changed

+41
-28
lines changed

4 files changed

+41
-28
lines changed

modules/ROOT/pages/directives/schema-configuration/type-configuration.adoc

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ type Movie @node @mutation(operations: [CREATE]) {
112112

113113
== `@subscription`
114114

115-
This directive is used to limit subscription operations in the library.
115+
This directive is used to enable subscription operations in the library.
116+
Subscriptions are opt-in by default, meaning that they are disabled unless explicitly enabled.
116117

117118
=== Definition
118119

@@ -129,22 +130,29 @@ directive @subscription(events: [SubscriptionFields!]! = [CREATED, UPDATED, DELE
129130

130131
=== Usage
131132

132-
.Disable subscriptions for _Movie_
133+
.Enable only _movieCreated_ subscription for _Movie_
133134
[source, graphql, indent=0]
134135
----
135-
type Movie @node @subscription(events: []) {
136+
type Movie @node @subscription(events: [CREATED]) {
136137
title: String
137138
length: Int
138139
}
139140
----
140141

141-
.Enable only _movieCreated_ subscription for _Movie_
142+
.Enable subscriptions for all types but disable subscriptions for _Movie_
142143
[source, graphql, indent=0]
143144
----
144-
type Movie @node @subscription(events: [CREATED]) {
145+
type Movie @node @subscription(events: []) {
145146
title: String
146147
length: Int
147148
}
149+
150+
type Actor @node {
151+
name: String
152+
movies: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT)
153+
}
154+
155+
extend schema @subscription
148156
----
149157

150158
[[type-definitions-default-values-default]]

modules/ROOT/pages/subscriptions/events.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type Movie @node {
2727
title: String
2828
genre: String
2929
}
30+
extend schema @subscription
3031
----
3132

3233
A subscription to any newly created node of the `Movie` type should look like this:
@@ -66,6 +67,7 @@ type Movie @node {
6667
title: String
6768
genre: String
6869
}
70+
extend schema @subscription
6971
----
7072

7173
A subscription to any node of the `Movie` type with its properties recently updated should look like this:
@@ -105,6 +107,7 @@ type Movie @node {
105107
title: String
106108
genre: String
107109
}
110+
extend schema @subscription
108111
----
109112

110113
A subscription to any deleted nodes of the `Movie` type should look like this:

modules/ROOT/pages/subscriptions/filtering.adoc

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ For the `Boolean` type, these are the only available comparison operators.
2626

2727
The following comparison operators are available for numeric types (`Int`, `Float`, xref::types/index.adoc[`BigInt`]):
2828

29-
* `_LT`
30-
* `_LTE`
31-
* `_GTE`
32-
* `_GT`
29+
* `lt`
30+
* `lte`
31+
* `gte`
32+
* `gt`
3333

3434
[NOTE]
3535
====
@@ -40,19 +40,19 @@ Filtering on xref::types/temporal.adoc[Temporal types] and xref::types/spatial.a
4040

4141
The following case-sensitive comparison operators are only available for use on `String` and `ID` types:
4242

43-
* `_STARTS_WITH`
44-
* `_ENDS_WITH`
45-
* `_CONTAINS`
43+
* `startsWith`
44+
* `endsWith`
45+
* `contains`
4646

4747
=== Array comparison
4848

4949
The following operator is available on non-array fields, and accepts an array argument:
5050

51-
* `_IN`
51+
* `in`
5252

5353
Conversely, the following operator is available on array fields, and accepts a single argument:
5454

55-
* `_INCLUDES`
55+
* `includes`
5656

5757
These operators are available for all types apart from `Boolean`.
5858

@@ -79,6 +79,7 @@ type Movie @node {
7979
averageRating: Float
8080
releasedIn: Int
8181
}
82+
extend schema @subscription
8283
----
8384

8485
Now, here is how filtering can be applied when creating a subscription:
@@ -90,7 +91,7 @@ To filter subscriptions to `create` operations for movies by their genre, here i
9091
[source, graphql, indent=0]
9192
----
9293
subscription {
93-
movieCreated(where: { genre_EQ: "Drama" }) {
94+
movieCreated(where: { genre: { eq: "Drama" } }) {
9495
createdMovie {
9596
title
9697
}
@@ -112,7 +113,7 @@ Here is how to filter subscription to `update` operations in movies with average
112113
[source, graphql, indent=0]
113114
----
114115
subscription {
115-
movieUpdate(where: { averageRating_GT: 8 }) {
116+
movieUpdate(where: { averageRating: { gt: 8 } }) {
116117
updatedMovie {
117118
title
118119
}
@@ -144,14 +145,14 @@ mutation {
144145
145146
mutation {
146147
updateTheMatrix: updateMovie(
147-
where: { title_EQ: "The Matrix" }
148-
update: { averageRating: 7.9 }
148+
where: { title: { eq: "The Matrix" } }
149+
update: { averageRating: { set: 7.9 }}
149150
) {
150151
title
151152
},
152153
updateResurrections: updateMovie(
153-
where: { title_EQ: "The Matrix Resurrections" }
154-
update: { averageRating: 8.9 }
154+
where: { title: { eq: "The Matrix Resurrections" }}
155+
update: { averageRating: { set: 8.9 }}
155156
) {
156157
title
157158
}
@@ -167,7 +168,7 @@ Here is how to filter subscription to `delete` operations in movies by their gen
167168
[source, graphql, indent=0]
168169
----
169170
subscription {
170-
movieDeleted(where: { NOT: { genre_EQ: "Comedy" } }) {
171+
movieDeleted(where: { NOT: { genre: { eq: "Comedy" } } }) {
171172
deletedMovie {
172173
title
173174
}
@@ -196,12 +197,12 @@ They could subscribe to any updates that cover this particular set of interests
196197
subscription {
197198
movieUpdated(where: {
198199
OR: [
199-
{ title_CONTAINS: "Matrix" },
200-
{ genre_EQ: "comedy" },
200+
{ title: { contains: "Matrix" } },
201+
{ genre: { eq: "comedy"} },
201202
{ AND: [
202-
{ NOT: { genre_EQ: "romantic comedy" } },
203-
{ releasedIn_GT: 2000 },
204-
{ releasedIn_LTE: 2005 }
203+
{ NOT: { genre: { eq: "romantic comedy" }} },
204+
{ releasedIn: { gt: 2000 } },
205+
{ releasedIn: { lte: 2005 } }
205206
] },
206207
]
207208
}) {

modules/ROOT/pages/subscriptions/getting-started.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const typeDefs = `
6464
type Actor @node {
6565
name: String
6666
}
67+
extend schema @subscription
6768
`;
6869
6970
const driver = neo4j.driver("bolt://localhost:7687", neo4j.auth.basic("username", "password"));
@@ -144,7 +145,7 @@ You can subscribe to new movies created with the following statement:
144145
[source, graphql, indent=0]
145146
----
146147
subscription {
147-
movieCreated(where: { title_EQ: "The Matrix" }) {
148+
movieCreated(where: { title: { eq: "The Matrix" } }) {
148149
createdMovie {
149150
title
150151
}
@@ -158,7 +159,7 @@ You can try this with the following query:
158159
[source, graphql, indent=0]
159160
----
160161
mutation {
161-
createMovies(input: [{ title_EQ: "The Matrix" }]) {
162+
createMovies(input: [{ title: { eq: "The Matrix" } }]) {
162163
movies {
163164
title
164165
}

0 commit comments

Comments
 (0)