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
Copy file name to clipboardExpand all lines: README.md
+16Lines changed: 16 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,22 @@ This DataSync fork allows for `Next` messages to be handled by the Server with a
15
15
16
16
The Client implemeneted here now also supports sending `Next` messages to the server via adding an `Observable` object, which will automatically wrap and send `Next` frames as it updates.
17
17
18
+
### Example
19
+
*The client and the server has already gone through [successful connection initialisation.](https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md#successful-connection-initialisation)*
20
+
1.*Client* generates a unique ID for the following operation
21
+
2.*Client* dispatches the `Subscribe` message with the generated ID through the `id` field and the requested operation passed through the `payload` field
22
+
*All future communication is linked through this unique ID*
23
+
3.*Server* executes the streaming GraphQL operation
24
+
4.*Server* checks if the generated ID is unique across active streaming subscriptions
25
+
- If not unique, the server will close the socket with the event `4409: Subscriber for <generated-id> already exists`
26
+
If unique, continue...
27
+
5.*Server* optionally checks if the operation is valid before starting executing it, e.g. checking permissions
28
+
- If not valid, the server sends an `Error` message and deems the operation complete.
29
+
If valid, continue...
30
+
6.*Server* & *Client* dispatch results over time with the `Next` message
31
+
-*Server* & *Client* handle received `Next` messages with their respectively defined callbacks. All Context is assumed to be the same between the two and is established in step 3 when the subscription is created.
32
+
7. The operation completes as described in [the `graphql-transport-ws` protocol](https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md#streaming-operation)
33
+
18
34
## Usage
19
35
20
36
To use this package, include it in your `Package.swift` dependencies:
0 commit comments