Skip to content

Commit 0b0e740

Browse files
authored
Merge pull request #192 from neo4j/update-subscriptions-docs
Update subscriptions docs with 6.x changes
2 parents d64b6b9 + a84c1b4 commit 0b0e740

File tree

9 files changed

+53
-2534
lines changed

9 files changed

+53
-2534
lines changed

modules/ROOT/content-nav.adoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
** xref:subscriptions/getting-started.adoc[Getting started]
5151
** xref:subscriptions/events.adoc[Events]
5252
** xref:subscriptions/filtering.adoc[]
53-
** xref:subscriptions/scaling.adoc[]
54-
** xref:subscriptions/engines.adoc[Engines]
53+
** xref:subscriptions/customize-cdc.adoc[]
5554
5655
* *How-To*
5756

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,9 @@ enum SubscriptionFields {
118118
CREATED
119119
UPDATED
120120
DELETED
121-
RELATIONSHIP_CREATED
122-
RELATIONSHIP_DELETED
123121
}
124122
125-
directive @subscription(events: [SubscriptionFields!]! = [CREATED, UPDATED, DELETED, RELATIONSHIP_CREATED, RELATIONSHIP_DELETED]) on OBJECT | SCHEMA
123+
directive @subscription(events: [SubscriptionFields!]! = [CREATED, UPDATED, DELETE]) on OBJECT | SCHEMA
126124
----
127125

128126
=== Usage
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[[customize-cdc]]
2+
= Customize CDC subscriptions
3+
:page-aliases: subscriptions/plugins/index.adoc, subscriptions/plugins/amqp.adoc, subscriptions/plugins/single-instance.adoc
4+
:description: This page describes how to customize the behavior of subscriptions.
5+
6+
GraphQL subscriptions to Neo4j use [Change Data Capture](https://neo4j.com/docs/cdc/current/) (CDC).
7+
Its behavior can be configured by passing an instance of `Neo4jGraphQLSubscriptionsCDCEngine`.
8+
9+
== Neo4jGraphQLSubscriptionsCDCEngine
10+
11+
By default, the GraphQL library uses the same driver passed to `Neo4jGraphQL` to poll for events every second.
12+
This behavior can be changed by creating a custom instance of `Neo4jGraphQLSubscriptionsCDCEngine`.
13+
14+
The following options can be passed to the constructor:
15+
16+
* `driver`: The driver to be used for CDC queries.
17+
* `pollTime`: The interval, in milliseconds, between queries to CDC.
18+
Defaults to 1000ms.
19+
Note that poll time is the period between a finished request and the start of the next.
20+
The actual time it takes for CDC events to trigger the subscription also depends on your network.
21+
* `queryConfig`: An object with the driver query options to be passed to CDC requests.
22+
Use the `db` field to define the target database for CDC.
23+
24+
For example:
25+
26+
[source, javascript, indent=0]
27+
----
28+
import { Neo4jGraphQL, Neo4jGraphQLSubscriptionsCDCEngine } from '@neo4j/graphql';
29+
30+
const engine = new Neo4jGraphQLSubscriptionsCDCEngine({
31+
driver,
32+
pollTime: 5000
33+
})
34+
35+
const neoSchema = new Neo4jGraphQL({
36+
typeDefs,
37+
driver,
38+
features: {
39+
subscriptions: engine,
40+
queryConfig: {
41+
database: "neo4j",
42+
}
43+
},
44+
});
45+
----
46+

modules/ROOT/pages/subscriptions/engines.adoc

Lines changed: 0 additions & 221 deletions
This file was deleted.

0 commit comments

Comments
 (0)