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
Update docs to use features instead of Neo4jGraphQLSubscriptionsSingleInstancePlugin (#167)
* Update docs to use features instead of Neo4jGraphQLSubscriptionsSingleInstancePlugin
* small adjustments, mostly a heading alias that was never working + an xref to that heading
---------
Co-authored-by: Richard Sill <richard.sill@neo4j.com>
Copy file name to clipboardExpand all lines: modules/ROOT/pages/ogm/subscriptions.adoc
+46-38Lines changed: 46 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ This section shows how to use subscriptions with the OGM inside custom resolvers
10
10
11
11
=== Prerequisites
12
12
13
-
. Use the following type definitions:
13
+
Use the following type definitions:
14
14
[source, javascript, indent=0]
15
15
----
16
16
const typeDefs = `#graphql
@@ -21,28 +21,32 @@ const typeDefs = `#graphql
21
21
`;
22
22
----
23
23
24
-
. Set up a subscriptions plugin instance to be shared between the Library and the OGM constructors:
25
-
[source, javascript, indent=0]
26
-
----
27
-
const subscriptionsPlugin = new Neo4jGraphQLSubscriptionsSingleInstancePlugin();
28
-
----
24
+
Set up a server that supports subscriptions. See more instructions in the xref:subscriptions/getting-started.adoc#_setting_up_an_apolloserver_server[Getting started] page.
29
25
30
-
. Set up a server that supports subscriptions.
31
-
See more instructions in the xref:subscriptions/getting-started.adoc#setting-up-server[Getting started page].
26
+
=== Adding the OGM
32
27
28
+
Enable the subscriptions feature in the OGM constructor:
33
29
34
-
=== Adding the OGM
30
+
[source, javascript, indent=0]
31
+
----
32
+
const ogm = new OGM({
33
+
typeDefs,
34
+
driver,
35
+
features: {
36
+
subscriptions: true
37
+
},
38
+
});
39
+
----
35
40
36
-
In order to utilize the `@private` marked field on the `User` type, you need to create the `User` model.
37
-
Also, to use the subscriptions, you need to pass in the subscriptions plugin instance to the OGM constructor:
41
+
Create the `User` model, which utilizes the `@private` marked field on the `User` type in the type definitions.
Make sure you initialize the OGM instance before using it by adding the following line to the `main()` function:
48
+
Initialize the OGM instance before using it by adding the following line to the `main()` function:
49
+
46
50
[source, javascript, indent=0]
47
51
----
48
52
await ogm.init();
@@ -52,39 +56,39 @@ await ogm.init();
52
56
53
57
xref:custom-resolvers/[Custom resolvers] can be used for multiple reasons such as performing data manipulation and checks, or interact with third party systems.
54
58
In this case, you only need to create a `User` node with the `password` field set.
Copy file name to clipboardExpand all lines: modules/ROOT/pages/subscriptions/getting-started.adoc
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ This guide shows how to start using subscription capabilities on a GraphQL serve
9
9
If you use link:https://studio.apollographql.com/[Apollo Studio], make sure to select the link:https://www.npmjs.com/package/graphql-ws[graphql-ws] implementation in the connection settings.
10
10
====
11
11
12
+
12
13
== Enable subscription capabilities
13
14
14
15
Before using subscriptions on a GraphQL server, you must enable them by passing the `subscriptions` feature to `Neo4jGraphQL`:
@@ -24,6 +25,7 @@ new Neo4jGraphQL({
24
25
});
25
26
----
26
27
28
+
27
29
== Install dependencies
28
30
29
31
Then, the next step is to install the following dependencies:
@@ -33,8 +35,8 @@ Then, the next step is to install the following dependencies:
33
35
npm i --save ws graphql-ws neo4j-driver @neo4j/graphql express @apollo/server body-parser cors
34
36
----
35
37
36
-
[setting-up-server]
37
-
== Set up an `@apollo/server` server
38
+
39
+
== Setting up an `@apollo/server` server
38
40
39
41
Add the following code to your `index.js` file to implement a simple `@apollo/server` server with subscriptions (for more options, see link:https://www.apollographql.com/docs/apollo-server/data/subscriptions/[Apollo's documentation]):
0 commit comments