From b7b44707e505a4d957a5002072118c20973362e1 Mon Sep 17 00:00:00 2001 From: Idan Am_Shalem Date: Tue, 29 Sep 2020 12:17:40 +0300 Subject: [PATCH 01/15] docs: GraphQL over WebSocket visual identity [skip ci] (#19) * GraphQL Over WebSocket New PR GIF * refactor: drop old icon Co-authored-by: Denis Badurina --- README.md | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5ccc0d77..c8554ee9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@

-

🚡 GraphQL transport over WebSocket

+![GraphQLOverWebSocket](https://user-images.githubusercontent.com/25294569/94527042-172dba00-023f-11eb-944b-88c0bd58a8d2.gif) +
Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client.
[![Continuous integration](https://github.com/enisdenjo/graphql-transport-ws/workflows/Continuous%20integration/badge.svg)](https://github.com/enisdenjo/graphql-transport-ws/actions?query=workflow%3A%22Continuous+integration%22) [![graphql-transport-ws](https://img.shields.io/npm/v/graphql-transport-ws.svg?label=graphql-transport-ws&logo=npm)](https://www.npmjs.com/package/graphql-transport-ws) diff --git a/package.json b/package.json index 798debaa..ed7f5954 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "graphql-transport-ws", "version": "1.6.0", - "description": "🚡 Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client", + "description": "Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client", "keywords": [ "graphql", "graphql-subscriptions", From 9a3f54a8198379b402a8abe414ab5727ccec45cf Mon Sep 17 00:00:00 2001 From: Denis Badurina Date: Thu, 1 Oct 2020 21:29:29 +0200 Subject: [PATCH 02/15] feat(client): Optional `generateID` to provide subscription IDs (#22) Closes #21 * feat: take in a custom ID generator * test: basic --- src/client.ts | 65 ++++++++++++++++++++++++++------------------- src/server.ts | 4 +-- src/tests/client.ts | 26 ++++++++++++++++++ src/types.ts | 7 ++--- 4 files changed, 69 insertions(+), 33 deletions(-) diff --git a/src/client.ts b/src/client.ts index 8a978830..2799735e 100644 --- a/src/client.ts +++ b/src/client.ts @@ -6,7 +6,7 @@ * */ -import { Sink, UUID, Disposable } from './types'; +import { Sink, ID, Disposable } from './types'; import { GRAPHQL_TRANSPORT_WS_PROTOCOL } from './protocol'; import { Message, @@ -67,6 +67,13 @@ export interface ClientOptions { * using the client outside of the browser environment. */ webSocketImpl?: unknown; + /** + * A custom ID generator for identifying subscriptions. + * The default uses the `crypto` module in the global window + * object, suitable for the browser environment. However, if + * it can't be found, `Math.random` would be used instead. + */ + generateID?: () => ID; } export interface Client extends Disposable { @@ -92,6 +99,29 @@ export function createClient(options: ClientOptions): Client { retryTimeout = 3 * 1000, // 3 seconds on, webSocketImpl, + /** + * Generates a v4 UUID to be used as the ID. + * Reference: https://stackoverflow.com/a/2117523/709884 + */ + generateID = function generateUUID() { + if (window && window.crypto) { + return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (s) => { + const c = Number.parseInt(s, 10); + return ( + c ^ + (window.crypto.getRandomValues(new Uint8Array(1))[0] & + (15 >> (c / 4))) + ).toString(16); + }); + } + + // use Math.random when crypto is not available + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { + const r = (Math.random() * 16) | 0, + v = c == 'x' ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); + }, } = options; let WebSocketImpl = WebSocket; @@ -393,26 +423,26 @@ export function createClient(options: ClientOptions): Client { return { on: emitter.on, subscribe(payload, sink) { - const uuid = generateUUID(); + const id = generateID(); const messageHandler = ({ data }: MessageEvent) => { const message = memoParseMessage(data); switch (message.type) { case MessageType.Next: { - if (message.id === uuid) { + if (message.id === id) { // eslint-disable-next-line @typescript-eslint/no-explicit-any sink.next(message.payload as any); } return; } case MessageType.Error: { - if (message.id === uuid) { + if (message.id === id) { sink.error(message.payload); } return; } case MessageType.Complete: { - if (message.id === uuid) { + if (message.id === id) { sink.complete(); } return; @@ -431,7 +461,7 @@ export function createClient(options: ClientOptions): Client { socket.send( stringifyMessage({ - id: uuid, + id: id, type: MessageType.Subscribe, payload, }), @@ -443,7 +473,7 @@ export function createClient(options: ClientOptions): Client { // send complete message to server on cancel socket.send( stringifyMessage({ - id: uuid, + id: id, type: MessageType.Complete, }), ); @@ -511,24 +541,3 @@ function isWebSocket(val: unknown): val is typeof WebSocket { 'OPEN' in val ); } - -/** Generates a new v4 UUID. Reference: https://stackoverflow.com/a/2117523/709884 */ -function generateUUID(): UUID { - if (!window.crypto) { - // fallback to Math.random when crypto is not available - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function ( - c, - ) { - const r = (Math.random() * 16) | 0, - v = c == 'x' ? r : (r & 0x3) | 0x8; - return v.toString(16); - }); - } - return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (s) => { - const c = Number.parseInt(s, 10); - return ( - c ^ - (window.crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4))) - ).toString(16); - }); -} diff --git a/src/server.ts b/src/server.ts index 8b3c14d3..f19a064e 100644 --- a/src/server.ts +++ b/src/server.ts @@ -36,7 +36,7 @@ import { hasOwnStringProperty, noop, } from './utils'; -import { UUID } from './types'; +import { ID } from './types'; export type ExecutionResultFormatter = ( ctx: Context, @@ -199,7 +199,7 @@ export interface Context { * Subscriptions are for `subscription` operations **only**, * other operations (`query`/`mutation`) are resolved immediately. */ - subscriptions: Record>; + subscriptions: Record>; } export interface Server extends Disposable { diff --git a/src/tests/client.ts b/src/tests/client.ts index 9d96bd42..c5d001fb 100644 --- a/src/tests/client.ts +++ b/src/tests/client.ts @@ -255,6 +255,32 @@ describe('subscription operation', () => { expect(nextFnForBananas).toHaveBeenCalledTimes(2); expect(completeFnForBananas).toBeCalled(); }); + + it('should use the provided `generateID` for subscription IDs', async () => { + const generateIDFn = jest.fn(() => 'not unique'); + + const client = createClient({ url, generateID: generateIDFn }); + + client.subscribe( + { + query: `subscription { + boughtBananas { + name + } + }`, + }, + { + next: noop, + error: () => { + fail(`Unexpected error call`); + }, + complete: noop, + }, + ); + await wait(10); + + expect(generateIDFn).toBeCalled(); + }); }); describe('"concurrency"', () => { diff --git a/src/types.ts b/src/types.ts index bf3ab66a..43fbc351 100644 --- a/src/types.ts +++ b/src/types.ts @@ -7,10 +7,11 @@ import { GraphQLError } from 'graphql'; /** - * UUID v4 string type alias generated through the - * `generateUUID` function from the client. + * ID is a string type alias representing + * the globally unique ID used for identifying + * subscriptions established by the client. */ -export type UUID = string; +export type ID = string; export interface Disposable { /** Dispose of the instance and clear up resources. */ From bb71ed81422cf1793a3231b418108b3e4136c179 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Thu, 1 Oct 2020 22:44:27 +0200 Subject: [PATCH 03/15] test(client): fix timing --- src/tests/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/client.ts b/src/tests/client.ts index c5d001fb..d0aa747c 100644 --- a/src/tests/client.ts +++ b/src/tests/client.ts @@ -344,7 +344,7 @@ describe('"concurrency"', () => { }); }); - await wait(25); + await wait(30); expect(nextFnForHappy).not.toBeCalled(); expect(completeFnForHappy).toBeCalled(); From c04cff13753846d91ce372847e1c47d8306e68f7 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Thu, 1 Oct 2020 22:44:50 +0200 Subject: [PATCH 04/15] test(client): fix invalid query --- src/tests/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/client.ts b/src/tests/client.ts index d0aa747c..8c843684 100644 --- a/src/tests/client.ts +++ b/src/tests/client.ts @@ -438,7 +438,7 @@ describe('lazy', () => { { operationName: 'BecomingHappy', query: `subscription BecomingHappy { - becameHappy { + becameHappy(secret: "live in the moment") { name } }`, From fb4d8e9efdfdd0cbe3b7cc34ddadbad3a795ae35 Mon Sep 17 00:00:00 2001 From: Denis Badurina Date: Thu, 1 Oct 2020 22:49:50 +0200 Subject: [PATCH 05/15] fix(client): Dispose of subscription on complete or error messages (#23) * fix: subscription should be canceled on complete * docs: update readme * fix: actually dispose on error or complete --- README.md | 23 +++++++-------------- src/client.ts | 15 ++++++++++++-- src/tests/client.ts | 50 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index c8554ee9..94aba789 100644 --- a/README.md +++ b/README.md @@ -89,17 +89,14 @@ const client = createClient({ (async () => { const result = await new Promise((resolve, reject) => { let result; - const dispose = client.subscribe( + client.subscribe( { query: '{ hello }', }, { next: (data) => (result = data), error: reject, - complete: () => { - dispose(); - resolve(result); - }, + complete: () => resolve(result), }, ); }); @@ -114,17 +111,14 @@ const client = createClient({ }; await new Promise((resolve, reject) => { - const dispose = client.subscribe( + client.subscribe( { query: 'subscription { greetings }', }, { next: onNext, error: reject, - complete: () => { - dispose(); - resolve(); - }, + complete: resolve, }, ); }); @@ -148,13 +142,10 @@ const client = createClient({ async function execute(payload: SubscribePayload) { return new Promise((resolve, reject) => { let result: T; - const dispose = client.subscribe(payload, { + client.subscribe(payload, { next: (data) => (result = data), error: reject, - complete: () => { - dispose(); - resolve(result); - }, + complete: () => resolve(result), }); }); } @@ -165,7 +156,7 @@ async function execute(payload: SubscribePayload) { const result = await execute({ query: '{ hello }', }); - // complete and dispose + // complete // next = result = { data: { hello: 'Hello World!' } } } catch (err) { // error diff --git a/src/client.ts b/src/client.ts index 2799735e..43e36c4e 100644 --- a/src/client.ts +++ b/src/client.ts @@ -424,6 +424,7 @@ export function createClient(options: ClientOptions): Client { on: emitter.on, subscribe(payload, sink) { const id = generateID(); + const cancellerRef: CancellerRef = { current: null }; const messageHandler = ({ data }: MessageEvent) => { const message = memoParseMessage(data); @@ -438,19 +439,28 @@ export function createClient(options: ClientOptions): Client { case MessageType.Error: { if (message.id === id) { sink.error(message.payload); + // the canceller must be set at this point + // because you cannot receive a message + // if there is no existing connection + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + cancellerRef.current!(); } return; } case MessageType.Complete: { if (message.id === id) { sink.complete(); + // the canceller must be set at this point + // because you cannot receive a message + // if there is no existing connection + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + cancellerRef.current!(); } return; } } }; - const cancellerRef: CancellerRef = { current: null }; (async () => { for (;;) { try { @@ -511,7 +521,8 @@ export function createClient(options: ClientOptions): Client { } })() .catch(sink.error) - .then(sink.complete); // resolves on cancel or normal closure + .then(sink.complete) // resolves on cancel or normal closure + .finally(() => (cancellerRef.current = null)); // when this promise settles there is nothing to cancel return () => { if (cancellerRef.current) { diff --git a/src/tests/client.ts b/src/tests/client.ts index 8c843684..3acd1d72 100644 --- a/src/tests/client.ts +++ b/src/tests/client.ts @@ -281,6 +281,56 @@ describe('subscription operation', () => { expect(generateIDFn).toBeCalled(); }); + + it('should dispose of the subscription on complete', async () => { + const client = createClient({ url }); + + const completeFn = jest.fn(); + client.subscribe( + { + query: `{ + getValue + }`, + }, + { + next: noop, + error: () => { + fail(`Unexpected error call`); + }, + complete: completeFn, + }, + ); + await wait(20); + + expect(completeFn).toBeCalled(); + + await wait(20); + expect(server.webSocketServer.clients.size).toBe(0); + }); + + it('should dispose of the subscription on error', async () => { + const client = createClient({ url }); + + const errorFn = jest.fn(); + client.subscribe( + { + query: `{ + iDontExist + }`, + }, + { + next: noop, + error: errorFn, + complete: noop, + }, + ); + await wait(20); + + expect(errorFn).toBeCalled(); + + await wait(20); + expect(server.webSocketServer.clients.size).toBe(0); + }); }); describe('"concurrency"', () => { From dfffb0502be5dd9ab5598e785b9988b1f4000227 Mon Sep 17 00:00:00 2001 From: Denis Badurina Date: Thu, 1 Oct 2020 23:53:02 +0200 Subject: [PATCH 06/15] fix(server): `subscription` operations are distinct on the message ID (#24) * docs: specify what happens on duplicate ids * docs: smaller wording changes * fix(server): prevent duplicate subscription operations --- PROTOCOL.md | 4 +++- src/server.ts | 7 ++++++ src/tests/server.ts | 58 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/PROTOCOL.md b/PROTOCOL.md index 05a6ff59..e0ac166a 100644 --- a/PROTOCOL.md +++ b/PROTOCOL.md @@ -73,7 +73,9 @@ The client is now **ready** to request subscription operations. Direction: **Client -> Server** -Requests a operation specified in the message `payload`. This message leverages the unique ID field to connect future server messages to the operation started by this message. +Requests a operation specified in the message `payload`. This message provides a unique ID field to connect future server messages to the operation started by this message. + +If there is already an active subscriber for a `subscription` operation matching the provided ID, the server will close the socket immediately with the event `4409: Subscriber for already exists`. Since `query` and `mutation` resolve to a single emitted value, their subscription does not require reservations for additional future events. Having this in mind, the server may not assert this rule for these operations. ```typescript import { DocumentNode } from 'graphql'; diff --git a/src/server.ts b/src/server.ts index f19a064e..18546ead 100644 --- a/src/server.ts +++ b/src/server.ts @@ -461,6 +461,13 @@ export function createServer( if (operationAST.operation === 'subscription') { const subscriptionOrResult = await subscribe(execArgs); if (isAsyncIterable(subscriptionOrResult)) { + // iterable subscriptions are distinct on ID + if (ctx.subscriptions[message.id]) { + return ctx.socket.close( + 4409, + `Subscriber for ${message.id} already exists`, + ); + } ctx.subscriptions[message.id] = subscriptionOrResult; try { diff --git a/src/tests/server.ts b/src/tests/server.ts index 9764ca19..6a4adf03 100644 --- a/src/tests/server.ts +++ b/src/tests/server.ts @@ -819,6 +819,64 @@ describe('Subscribe', () => { expect(onMessageFn).toBeCalledTimes(3); // ack, next, complete }); + + it('should close the socket on duplicate `subscription` operation subscriptions request', async () => { + expect.assertions(3); + + await makeServer(); + + const client = new WebSocket(url, GRAPHQL_TRANSPORT_WS_PROTOCOL); + client.onopen = () => { + client.send( + stringifyMessage({ + type: MessageType.ConnectionInit, + }), + ); + }; + + client.onmessage = ({ data }) => { + const message = parseMessage(data); + if (message.type === MessageType.ConnectionAck) { + client.send( + stringifyMessage({ + id: 'not-unique', + type: MessageType.Subscribe, + payload: { + query: `subscription { + boughtBananas { + name + } + }`, + }, + }), + ); + + // try subscribing with a live subscription id + setTimeout(() => { + client.send( + stringifyMessage({ + id: 'not-unique', + type: MessageType.Subscribe, + payload: { + query: `subscription { + greetings + }`, + }, + }), + ); + }, 10); + } + }; + + await new Promise((resolve) => { + client.onclose = (event) => { + expect(event.code).toBe(4409); + expect(event.reason).toBe('Subscriber for not-unique already exists'); + expect(event.wasClean).toBeTruthy(); + resolve(); // done + }; + }); + }); }); describe('Keep-Alive', () => { From c2f204c2aa2935ba3d320f33f1bc411baa94398f Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Thu, 1 Oct 2020 23:57:15 +0200 Subject: [PATCH 07/15] docs(protocol): close is not the same as terminate [skip ci] --- PROTOCOL.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/PROTOCOL.md b/PROTOCOL.md index e0ac166a..17ed5b0e 100644 --- a/PROTOCOL.md +++ b/PROTOCOL.md @@ -16,9 +16,9 @@ Messages are represented through the JSON structure and are stringified before b - `id` used for uniquely identifying server responses and connecting them with the client requests - `payload` holding the extra "payload" information to go with the specific message type -The server can terminate the socket (kick the client off) at any time. The close event dispatched by the server is used to describe the fatal error to the client. +The server can close the socket (kick the client off) at any time. The close event dispatched by the server is used to describe the fatal error to the client. -The client terminates the socket and closes the connection by dispatching a `1000: Normal Closure` close event to the server indicating a normal closure. +The client closes the socket and the connection by dispatching a `1000: Normal Closure` close event to the server indicating a normal closure. ## Keep-Alive @@ -38,9 +38,9 @@ Indicates that the client wants to establish a connection within the existing so The client can specify additional `connectionParams` which are sent through the `payload` field in the outgoing message. -The server must receive the connection initialisation message within the allowed waiting time specified in the `connectionInitWaitTimeout` parameter during the server setup. If the client does not request a connection within the allowed timeout, the server will terminate the socket with the close event: `4408: Connection initialisation timeout`. +The server must receive the connection initialisation message within the allowed waiting time specified in the `connectionInitWaitTimeout` parameter during the server setup. If the client does not request a connection within the allowed timeout, the server will close the socket with the event: `4408: Connection initialisation timeout`. -If the server receives more than one `ConnectionInit` message at any given time, the server will terminate the socket with the close event `4429: Too many initialisation requests`. +If the server receives more than one `ConnectionInit` message at any given time, the server will close the socket with the event `4429: Too many initialisation requests`. ```typescript interface ConnectionInitMessage { @@ -91,7 +91,7 @@ interface SubscribeMessage { } ``` -Executing operations is allowed **only** after the server has acknowledged the connection through the `ConnectionAck` message, if the connection is not acknowledged, the socket will be terminated immediately with a close event `4401: Unauthorized`. +Executing operations is allowed **only** after the server has acknowledged the connection through the `ConnectionAck` message, if the connection is not acknowledged, the socket will be closed immediately with the event `4401: Unauthorized`. ### `Next` @@ -147,7 +147,7 @@ interface CompleteMessage { Direction: **bidirectional** -Receiving a message of a type or format which is not specified in this document will result in an **immediate** socket termination with a close event `4400: `. The `` can be vaguely descriptive on why the received message is invalid. +Receiving a message of a type or format which is not specified in this document will result in an **immediate** socket closure with the event `4400: `. The `` can be vaguely descriptive on why the received message is invalid. ## Examples @@ -167,7 +167,7 @@ For the sake of clarity, the following examples demonstrate the communication pr 1. _Server_ accepts the handshake and establishes a WebSocket communication channel (which we call "socket") 1. _Client_ immediately dispatches a `ConnectionInit` message setting the `connectionParams` according to the server implementation 1. _Server_ validates the connection initialisation request and decides that the client is not allowed to establish a connection -1. _Server_ terminates the socket by dispatching the close event `4403: Forbidden` +1. _Server_ closes the socket by dispatching the event `4403: Forbidden` 1. _Client_ reports an error using the close event reason (which is `Forbidden`) ### Erroneous connection initialisation @@ -176,7 +176,7 @@ For the sake of clarity, the following examples demonstrate the communication pr 1. _Server_ accepts the handshake and establishes a WebSocket communication channel (which we call "socket") 1. _Client_ immediately dispatches a `ConnectionInit` message setting the `connectionParams` according to the server implementation 1. _Server_ tries validating the connection initialisation request but an error `I'm a teapot` is thrown -1. _Server_ terminates the socket by dispatching the close event `4400: I'm a teapot` +1. _Server_ closes the socket by dispatching the event `4400: I'm a teapot` 1. _Client_ reports an error using the close event reason (which is `I'm a teapot`) ### Connection initialisation timeout @@ -186,7 +186,7 @@ For the sake of clarity, the following examples demonstrate the communication pr 1. _Client_ does not dispatch a `ConnectionInit` message 1. _Server_ waits for the `ConnectionInit` message for the duration specified in the `connectionInitWaitTimeout` parameter 1. _Server_ waiting time has passed -1. _Server_ terminates the socket by dispatching the close event `4408: Connection initialisation timeout` +1. _Server_ closes the socket by dispatching the event `4408: Connection initialisation timeout` 1. _Client_ reports an error using the close event reason (which is `Connection initialisation timeout`) ### Query/Mutation operation From e35a1ac373922bcc822c0e08a54b28dbe4b281f5 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Fri, 2 Oct 2020 00:05:43 +0200 Subject: [PATCH 08/15] docs(protocol): smaller refinements [skip ci] --- PROTOCOL.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PROTOCOL.md b/PROTOCOL.md index 17ed5b0e..c9bb7ffe 100644 --- a/PROTOCOL.md +++ b/PROTOCOL.md @@ -7,13 +7,13 @@ ## Communication -The WebSocket sub-protocol for this specification is: `graphql-transport-ws` +The WebSocket sub-protocol for this specification is: `graphql-transport-ws`. -Messages are represented through the JSON structure and are stringified before being sent over the network. They are bidirectional, meaning both the server and the client conform to the specified message structure. +Messages are represented through the JSON structure and are stringified before being sent over the network. They are bidirectional, meaning both the server and the client must conform to the specified message structure. -**All** messages contain the `type` field outlining the type or action this message describes. Depending on the type, the message can contain two more _optional_ fields: +**All** messages contain the `type` field outlining the action this message describes. Depending on the type, the message can contain two more _optional_ fields: -- `id` used for uniquely identifying server responses and connecting them with the client requests +- `id` used for uniquely identifying server responses and connecting them with the client's requests - `payload` holding the extra "payload" information to go with the specific message type The server can close the socket (kick the client off) at any time. The close event dispatched by the server is used to describe the fatal error to the client. @@ -34,7 +34,7 @@ Ping and Pong feature is a mandatory requirement by [The WebSocket Protocol](htt Direction: **Client -> Server** -Indicates that the client wants to establish a connection within the existing socket. This connection is **not** the actual WebSocket communication channel, but is rather a frame within it asking the server to allow future subscription operation requests. +Indicates that the client wants to establish a connection within the existing socket. This connection is **not** the actual WebSocket communication channel, but is rather a frame within it asking the server to allow future operation requests. The client can specify additional `connectionParams` which are sent through the `payload` field in the outgoing message. @@ -73,7 +73,7 @@ The client is now **ready** to request subscription operations. Direction: **Client -> Server** -Requests a operation specified in the message `payload`. This message provides a unique ID field to connect future server messages to the operation started by this message. +Requests an operation specified in the message `payload`. This message provides a unique ID field to connect future server messages to the operation started by this message. If there is already an active subscriber for a `subscription` operation matching the provided ID, the server will close the socket immediately with the event `4409: Subscriber for already exists`. Since `query` and `mutation` resolve to a single emitted value, their subscription does not require reservations for additional future events. Having this in mind, the server may not assert this rule for these operations. @@ -132,7 +132,7 @@ interface ErrorMessage { Direction: **bidirectional** -- **Server -> Client** indicates that the requested operation execution has completed. If the server dispatched the `Error` message relative to the original `Subscribe` message, **no `Complete` message will be emitted**. +- **Server -> Client** indicates that the requested operation execution has completed. If the server dispatched the `Error` message relative to the original `Subscribe` message, no `Complete` message will be emitted. - **Client -> Server** (for `subscription` operations only) indicating that the client has stopped listening to the events and wants to complete the source stream. No further data events, relevant to the original subscription, should be sent through. From 78e8c95af3c1f775f309c5c4575fed7c5ae37f7c Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Fri, 2 Oct 2020 00:06:04 +0200 Subject: [PATCH 09/15] docs: generate --- docs/enums/_message_.messagetype.md | 12 ++++---- docs/interfaces/_client_.client.md | 6 ++-- docs/interfaces/_client_.clientoptions.md | 28 ++++++++++++++----- docs/interfaces/_message_.completemessage.md | 4 +-- .../_message_.connectionackmessage.md | 2 +- .../_message_.connectioninitmessage.md | 4 +-- docs/interfaces/_message_.errormessage.md | 6 ++-- docs/interfaces/_message_.nextmessage.md | 6 ++-- docs/interfaces/_message_.subscribemessage.md | 6 ++-- docs/interfaces/_message_.subscribepayload.md | 6 ++-- docs/interfaces/_server_.context.md | 14 +++++----- docs/interfaces/_server_.server.md | 4 +-- docs/interfaces/_server_.serveroptions.md | 24 ++++++++-------- docs/interfaces/_types_.disposable.md | 2 +- docs/interfaces/_types_.sink.md | 6 ++-- docs/modules/_client_.md | 12 ++++---- docs/modules/_message_.md | 2 +- docs/modules/_protocol_.md | 2 +- docs/modules/_server_.md | 4 +-- docs/modules/_types_.md | 13 +++++---- 20 files changed, 89 insertions(+), 74 deletions(-) diff --git a/docs/enums/_message_.messagetype.md b/docs/enums/_message_.messagetype.md index 9f63d7e3..ad548d20 100644 --- a/docs/enums/_message_.messagetype.md +++ b/docs/enums/_message_.messagetype.md @@ -21,7 +21,7 @@ Types of messages allowed to be sent by the client/server over the WS protocol. • **Complete**: = "complete" -*Defined in [message.ts:24](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L24)* +*Defined in [message.ts:24](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L24)* ___ @@ -29,7 +29,7 @@ ___ • **ConnectionAck**: = "connection_ack" -*Defined in [message.ts:19](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L19)* +*Defined in [message.ts:19](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L19)* ___ @@ -37,7 +37,7 @@ ___ • **ConnectionInit**: = "connection_init" -*Defined in [message.ts:18](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L18)* +*Defined in [message.ts:18](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L18)* ___ @@ -45,7 +45,7 @@ ___ • **Error**: = "error" -*Defined in [message.ts:23](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L23)* +*Defined in [message.ts:23](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L23)* ___ @@ -53,7 +53,7 @@ ___ • **Next**: = "next" -*Defined in [message.ts:22](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L22)* +*Defined in [message.ts:22](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L22)* ___ @@ -61,4 +61,4 @@ ___ • **Subscribe**: = "subscribe" -*Defined in [message.ts:21](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L21)* +*Defined in [message.ts:21](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L21)* diff --git a/docs/interfaces/_client_.client.md b/docs/interfaces/_client_.client.md index 4d661659..cd5ebe52 100644 --- a/docs/interfaces/_client_.client.md +++ b/docs/interfaces/_client_.client.md @@ -27,7 +27,7 @@ *Inherited from [Disposable](_types_.disposable.md).[dispose](_types_.disposable.md#dispose)* -*Defined in [types.ts:17](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/types.ts#L17)* +*Defined in [types.ts:18](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/types.ts#L18)* Dispose of the instance and clear up resources. @@ -41,7 +41,7 @@ Dispose of the instance and clear up resources. ▸ **on**‹**E**›(`event`: E, `listener`: [EventListener](../modules/_client_.md#eventlistener)‹E›): *function* -*Defined in [client.ts:76](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L76)* +*Defined in [client.ts:83](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L83)* Listens on the client which dispatches events about the socket state. @@ -66,7 +66,7 @@ ___ ▸ **subscribe**‹**T**›(`payload`: [SubscribePayload](_message_.subscribepayload.md), `sink`: [Sink](_types_.sink.md)‹T›): *function* -*Defined in [client.ts:82](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L82)* +*Defined in [client.ts:89](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L89)* Subscribes through the WebSocket following the config parameters. It uses the `sink` to emit received data or errors. Returns a _cleanup_ diff --git a/docs/interfaces/_client_.clientoptions.md b/docs/interfaces/_client_.clientoptions.md index 99b359dc..66ae2124 100644 --- a/docs/interfaces/_client_.clientoptions.md +++ b/docs/interfaces/_client_.clientoptions.md @@ -13,6 +13,7 @@ Configuration used for the `create` client function. ### Properties * [connectionParams](_client_.clientoptions.md#optional-connectionparams) +* [generateID](_client_.clientoptions.md#optional-generateid) * [lazy](_client_.clientoptions.md#optional-lazy) * [on](_client_.clientoptions.md#optional-on) * [retryAttempts](_client_.clientoptions.md#optional-retryattempts) @@ -26,17 +27,30 @@ Configuration used for the `create` client function. • **connectionParams**? : *Record‹string, unknown› | function* -*Defined in [client.ts:40](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L40)* +*Defined in [client.ts:40](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L40)* Optional parameters that the client specifies when establishing a connection with the server. ___ +### `Optional` generateID + +• **generateID**? : *undefined | function* + +*Defined in [client.ts:76](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L76)* + +A custom ID generator for identifying subscriptions. +The default uses the `crypto` module in the global window +object, suitable for the browser environment. However, if +it can't be found, `Math.random` would be used instead. + +___ + ### `Optional` lazy • **lazy**? : *undefined | false | true* -*Defined in [client.ts:46](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L46)* +*Defined in [client.ts:46](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L46)* Should the connection be established immediately and persisted or after the first listener subscribed. @@ -49,7 +63,7 @@ ___ • **on**? : *Partial‹object›* -*Defined in [client.ts:63](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L63)* +*Defined in [client.ts:63](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L63)* Register listeners before initialising the client. This way you can ensure to catch all client relevant emitted events. @@ -62,7 +76,7 @@ ___ • **retryAttempts**? : *undefined | number* -*Defined in [client.ts:51](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L51)* +*Defined in [client.ts:51](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L51)* How many times should the client try to reconnect on abnormal socket closure before it errors out? @@ -74,7 +88,7 @@ ___ • **retryTimeout**? : *undefined | number* -*Defined in [client.ts:56](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L56)* +*Defined in [client.ts:56](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L56)* How long should the client wait until attempting to retry. @@ -86,7 +100,7 @@ ___ • **url**: *string* -*Defined in [client.ts:38](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L38)* +*Defined in [client.ts:38](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L38)* URL of the GraphQL server to connect. @@ -96,7 +110,7 @@ ___ • **webSocketImpl**? : *unknown* -*Defined in [client.ts:69](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L69)* +*Defined in [client.ts:69](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L69)* A custom WebSocket implementation to use instead of the one provided by the global scope. Mostly useful for when diff --git a/docs/interfaces/_message_.completemessage.md b/docs/interfaces/_message_.completemessage.md index bf1ea60f..947d753c 100644 --- a/docs/interfaces/_message_.completemessage.md +++ b/docs/interfaces/_message_.completemessage.md @@ -19,7 +19,7 @@ • **id**: *string* -*Defined in [message.ts:61](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L61)* +*Defined in [message.ts:61](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L61)* ___ @@ -27,4 +27,4 @@ ___ • **type**: *[Complete](../enums/_message_.messagetype.md#complete)* -*Defined in [message.ts:62](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L62)* +*Defined in [message.ts:62](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L62)* diff --git a/docs/interfaces/_message_.connectionackmessage.md b/docs/interfaces/_message_.connectionackmessage.md index e89ae448..555624b8 100644 --- a/docs/interfaces/_message_.connectionackmessage.md +++ b/docs/interfaces/_message_.connectionackmessage.md @@ -18,4 +18,4 @@ • **type**: *[ConnectionAck](../enums/_message_.messagetype.md#connectionack)* -*Defined in [message.ts:33](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L33)* +*Defined in [message.ts:33](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L33)* diff --git a/docs/interfaces/_message_.connectioninitmessage.md b/docs/interfaces/_message_.connectioninitmessage.md index d904c129..08bd2f5b 100644 --- a/docs/interfaces/_message_.connectioninitmessage.md +++ b/docs/interfaces/_message_.connectioninitmessage.md @@ -19,7 +19,7 @@ • **payload**? : *Record‹string, unknown›* -*Defined in [message.ts:29](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L29)* +*Defined in [message.ts:29](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L29)* ___ @@ -27,4 +27,4 @@ ___ • **type**: *[ConnectionInit](../enums/_message_.messagetype.md#connectioninit)* -*Defined in [message.ts:28](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L28)* +*Defined in [message.ts:28](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L28)* diff --git a/docs/interfaces/_message_.errormessage.md b/docs/interfaces/_message_.errormessage.md index 7a8c7a3d..03d2e7dc 100644 --- a/docs/interfaces/_message_.errormessage.md +++ b/docs/interfaces/_message_.errormessage.md @@ -20,7 +20,7 @@ • **id**: *string* -*Defined in [message.ts:55](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L55)* +*Defined in [message.ts:55](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L55)* ___ @@ -28,7 +28,7 @@ ___ • **payload**: *readonly GraphQLError[]* -*Defined in [message.ts:57](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L57)* +*Defined in [message.ts:57](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L57)* ___ @@ -36,4 +36,4 @@ ___ • **type**: *[Error](../enums/_message_.messagetype.md#error)* -*Defined in [message.ts:56](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L56)* +*Defined in [message.ts:56](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L56)* diff --git a/docs/interfaces/_message_.nextmessage.md b/docs/interfaces/_message_.nextmessage.md index a35bc199..1f7bb0e3 100644 --- a/docs/interfaces/_message_.nextmessage.md +++ b/docs/interfaces/_message_.nextmessage.md @@ -20,7 +20,7 @@ • **id**: *string* -*Defined in [message.ts:49](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L49)* +*Defined in [message.ts:49](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L49)* ___ @@ -28,7 +28,7 @@ ___ • **payload**: *ExecutionResult* -*Defined in [message.ts:51](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L51)* +*Defined in [message.ts:51](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L51)* ___ @@ -36,4 +36,4 @@ ___ • **type**: *[Next](../enums/_message_.messagetype.md#next)* -*Defined in [message.ts:50](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L50)* +*Defined in [message.ts:50](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L50)* diff --git a/docs/interfaces/_message_.subscribemessage.md b/docs/interfaces/_message_.subscribemessage.md index f44bbbe4..81cbe8c1 100644 --- a/docs/interfaces/_message_.subscribemessage.md +++ b/docs/interfaces/_message_.subscribemessage.md @@ -20,7 +20,7 @@ • **id**: *string* -*Defined in [message.ts:37](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L37)* +*Defined in [message.ts:37](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L37)* ___ @@ -28,7 +28,7 @@ ___ • **payload**: *[SubscribePayload](_message_.subscribepayload.md)* -*Defined in [message.ts:39](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L39)* +*Defined in [message.ts:39](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L39)* ___ @@ -36,4 +36,4 @@ ___ • **type**: *[Subscribe](../enums/_message_.messagetype.md#subscribe)* -*Defined in [message.ts:38](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L38)* +*Defined in [message.ts:38](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L38)* diff --git a/docs/interfaces/_message_.subscribepayload.md b/docs/interfaces/_message_.subscribepayload.md index 4249767f..29a02cc1 100644 --- a/docs/interfaces/_message_.subscribepayload.md +++ b/docs/interfaces/_message_.subscribepayload.md @@ -20,7 +20,7 @@ • **operationName**? : *string | null* -*Defined in [message.ts:43](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L43)* +*Defined in [message.ts:43](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L43)* ___ @@ -28,7 +28,7 @@ ___ • **query**: *string | DocumentNode* -*Defined in [message.ts:44](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L44)* +*Defined in [message.ts:44](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L44)* ___ @@ -36,4 +36,4 @@ ___ • **variables**? : *Record‹string, unknown› | null* -*Defined in [message.ts:45](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L45)* +*Defined in [message.ts:45](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L45)* diff --git a/docs/interfaces/_server_.context.md b/docs/interfaces/_server_.context.md index 002ad25b..b603e339 100644 --- a/docs/interfaces/_server_.context.md +++ b/docs/interfaces/_server_.context.md @@ -23,7 +23,7 @@ • **acknowledged**: *boolean* -*Defined in [server.ts:194](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L194)* +*Defined in [server.ts:194](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L194)* Indicates that the connection was acknowledged by having dispatched the `ConnectionAck` message @@ -35,7 +35,7 @@ ___ • **connectionInitReceived**: *boolean* -*Defined in [server.ts:188](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L188)* +*Defined in [server.ts:188](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L188)* Indicates that the `ConnectionInit` message has been received by the server. If this is @@ -48,7 +48,7 @@ ___ • **connectionParams**? : *Readonly‹Record‹string, unknown››* -*Defined in [server.ts:196](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L196)* +*Defined in [server.ts:196](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L196)* The parameters passed during the connection initialisation. @@ -58,7 +58,7 @@ ___ • **request**: *IncomingMessage* -*Defined in [server.ts:181](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L181)* +*Defined in [server.ts:181](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L181)* The initial HTTP request before the actual socket and connection is established. @@ -69,7 +69,7 @@ ___ • **socket**: *WebSocket* -*Defined in [server.ts:176](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L176)* +*Defined in [server.ts:176](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L176)* The actual WebSocket connection between the server and the client. @@ -77,9 +77,9 @@ ___ ### subscriptions -• **subscriptions**: *Record‹[UUID](../modules/_types_.md#uuid), AsyncIterator‹unknown››* +• **subscriptions**: *Record‹[ID](../modules/_types_.md#id), AsyncIterator‹unknown››* -*Defined in [server.ts:202](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L202)* +*Defined in [server.ts:202](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L202)* Holds the active subscriptions for this context. Subscriptions are for `subscription` operations **only**, diff --git a/docs/interfaces/_server_.server.md b/docs/interfaces/_server_.server.md index a05d3fa7..f5995f28 100644 --- a/docs/interfaces/_server_.server.md +++ b/docs/interfaces/_server_.server.md @@ -23,7 +23,7 @@ *Inherited from [Disposable](_types_.disposable.md).[dispose](_types_.disposable.md#dispose)* -*Defined in [types.ts:17](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/types.ts#L17)* +*Defined in [types.ts:18](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/types.ts#L18)* Dispose of the instance and clear up resources. @@ -37,4 +37,4 @@ ___ • **webSocketServer**: *Server* -*Defined in [server.ts:206](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L206)* +*Defined in [server.ts:206](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L206)* diff --git a/docs/interfaces/_server_.serveroptions.md b/docs/interfaces/_server_.serveroptions.md index 3b7e74ae..650c60df 100644 --- a/docs/interfaces/_server_.serveroptions.md +++ b/docs/interfaces/_server_.serveroptions.md @@ -29,7 +29,7 @@ • **connectionInitWaitTimeout**? : *undefined | number* -*Defined in [server.ts:126](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L126)* +*Defined in [server.ts:126](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L126)* **`default`** 3 * 1000 (3 seconds) @@ -49,7 +49,7 @@ ___ • **context**? : *SubscriptionArgs["contextValue"]* -*Defined in [server.ts:62](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L62)* +*Defined in [server.ts:62](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L62)* A value which is provided to every resolver and holds important contextual information like the currently @@ -63,7 +63,7 @@ ___ • **execute**: *function* -*Defined in [server.ts:82](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L82)* +*Defined in [server.ts:82](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L82)* Is the `subscribe` function from GraphQL which is used to @@ -86,7 +86,7 @@ ___ • **formatExecutionResult**? : *[ExecutionResultFormatter](../modules/_server_.md#executionresultformatter)* -*Defined in [server.ts:138](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L138)* +*Defined in [server.ts:138](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L138)* Format the operation execution results if the implementation requires an adjusted @@ -99,7 +99,7 @@ ___ • **keepAlive**? : *undefined | number* -*Defined in [server.ts:169](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L169)* +*Defined in [server.ts:169](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L169)* The timout between dispatched keep-alive messages. Internally the lib uses the [WebSocket Ping and Pongs]((https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers#Pings_and_Pongs_The_Heartbeat_of_WebSockets)) to check that the link between @@ -114,7 +114,7 @@ ___ • **onComplete**? : *undefined | function* -*Defined in [server.ts:160](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L160)* +*Defined in [server.ts:160](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L160)* The complete callback is executed after the operation has completed or the subscription @@ -126,7 +126,7 @@ ___ • **onConnect**? : *undefined | function* -*Defined in [server.ts:112](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L112)* +*Defined in [server.ts:112](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L112)* Is the connection callback called when the client requests the connection initialisation @@ -153,7 +153,7 @@ ___ • **onSubscribe**? : *undefined | function* -*Defined in [server.ts:148](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L148)* +*Defined in [server.ts:148](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L148)* The subscribe callback executed before the actual operation execution. Useful @@ -169,7 +169,7 @@ ___ • **roots**? : *undefined | object* -*Defined in [server.ts:70](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L70)* +*Defined in [server.ts:70](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L70)* The GraphQL root fields or resolvers to go alongside the schema. Learn more about them @@ -183,7 +183,7 @@ ___ • **schema**? : *GraphQLSchema* -*Defined in [server.ts:54](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L54)* +*Defined in [server.ts:54](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L54)* The GraphQL schema on which the operations will be executed and validated against. If @@ -197,7 +197,7 @@ ___ • **subscribe**: *function* -*Defined in [server.ts:89](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L89)* +*Defined in [server.ts:89](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L89)* Is the `subscribe` function from GraphQL which is used to @@ -220,7 +220,7 @@ ___ • **validationRules**? : *readonly ValidationRule[]* -*Defined in [server.ts:131](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L131)* +*Defined in [server.ts:131](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L131)* Custom validation rules overriding all validation rules defined by the GraphQL spec. diff --git a/docs/interfaces/_types_.disposable.md b/docs/interfaces/_types_.disposable.md index 4ce45554..1c9cd06a 100644 --- a/docs/interfaces/_types_.disposable.md +++ b/docs/interfaces/_types_.disposable.md @@ -22,7 +22,7 @@ • **dispose**: *function* -*Defined in [types.ts:17](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/types.ts#L17)* +*Defined in [types.ts:18](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/types.ts#L18)* Dispose of the instance and clear up resources. diff --git a/docs/interfaces/_types_.sink.md b/docs/interfaces/_types_.sink.md index 5d6f5dc6..6ba7bd14 100644 --- a/docs/interfaces/_types_.sink.md +++ b/docs/interfaces/_types_.sink.md @@ -26,7 +26,7 @@ A representation of any set of values over any amount of time. ▸ **complete**(): *void* -*Defined in [types.ts:29](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/types.ts#L29)* +*Defined in [types.ts:30](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/types.ts#L30)* The sink has completed. This function "closes" the sink. @@ -38,7 +38,7 @@ ___ ▸ **error**(`error`: Error | CloseEvent | readonly GraphQLError[]): *void* -*Defined in [types.ts:27](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/types.ts#L27)* +*Defined in [types.ts:28](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/types.ts#L28)* An error that has occured. Calling this function "closes" the sink. @@ -56,7 +56,7 @@ ___ ▸ **next**(`value`: T): *void* -*Defined in [types.ts:25](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/types.ts#L25)* +*Defined in [types.ts:26](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/types.ts#L26)* Next value arriving. diff --git a/docs/modules/_client_.md b/docs/modules/_client_.md index 16c1af62..271ddbb4 100644 --- a/docs/modules/_client_.md +++ b/docs/modules/_client_.md @@ -27,7 +27,7 @@ Ƭ **Event**: *[EventConnecting](_client_.md#eventconnecting) | [EventConnected](_client_.md#eventconnected) | [EventClosed](_client_.md#eventclosed)* -*Defined in [client.ts:23](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L23)* +*Defined in [client.ts:23](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L23)* ___ @@ -35,7 +35,7 @@ ___ Ƭ **EventClosed**: *"closed"* -*Defined in [client.ts:22](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L22)* +*Defined in [client.ts:22](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L22)* ___ @@ -43,7 +43,7 @@ ___ Ƭ **EventConnected**: *"connected"* -*Defined in [client.ts:21](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L21)* +*Defined in [client.ts:21](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L21)* ___ @@ -51,7 +51,7 @@ ___ Ƭ **EventConnecting**: *"connecting"* -*Defined in [client.ts:20](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L20)* +*Defined in [client.ts:20](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L20)* ___ @@ -59,7 +59,7 @@ ___ Ƭ **EventListener**: *E extends EventConnecting ? function : E extends EventConnected ? function : E extends EventClosed ? function : never* -*Defined in [client.ts:25](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L25)* +*Defined in [client.ts:25](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L25)* ## Functions @@ -67,7 +67,7 @@ ___ ▸ **createClient**(`options`: [ClientOptions](../interfaces/_client_.clientoptions.md)): *[Client](../interfaces/_client_.client.md)* -*Defined in [client.ts:86](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/client.ts#L86)* +*Defined in [client.ts:93](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L93)* Creates a disposable GraphQL subscriptions client. diff --git a/docs/modules/_message_.md b/docs/modules/_message_.md index 172018a0..ddef138e 100644 --- a/docs/modules/_message_.md +++ b/docs/modules/_message_.md @@ -28,4 +28,4 @@ Ƭ **Message**: *T extends ConnectionAck ? ConnectionAckMessage : T extends ConnectionInit ? ConnectionInitMessage : T extends Subscribe ? SubscribeMessage : T extends Next ? NextMessage : T extends Error ? ErrorMessage : T extends Complete ? CompleteMessage : never* -*Defined in [message.ts:65](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/message.ts#L65)* +*Defined in [message.ts:65](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L65)* diff --git a/docs/modules/_protocol_.md b/docs/modules/_protocol_.md index 26f633a7..dabc1f78 100644 --- a/docs/modules/_protocol_.md +++ b/docs/modules/_protocol_.md @@ -16,6 +16,6 @@ protocol • **GRAPHQL_TRANSPORT_WS_PROTOCOL**: *"graphql-transport-ws"* = "graphql-transport-ws" -*Defined in [protocol.ts:8](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/protocol.ts#L8)* +*Defined in [protocol.ts:8](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/protocol.ts#L8)* The WebSocket sub-protocol used for the [GraphQL over WebSocket Protocol](/PROTOCOL.md). diff --git a/docs/modules/_server_.md b/docs/modules/_server_.md index 52166ce4..9f5f20da 100644 --- a/docs/modules/_server_.md +++ b/docs/modules/_server_.md @@ -24,7 +24,7 @@ Ƭ **ExecutionResultFormatter**: *function* -*Defined in [server.ts:41](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L41)* +*Defined in [server.ts:41](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L41)* #### Type declaration: @@ -43,7 +43,7 @@ Name | Type | ▸ **createServer**(`options`: [ServerOptions](../interfaces/_server_.serveroptions.md), `websocketOptionsOrServer`: WebSocketServerOptions | WebSocketServer): *[Server](../interfaces/_server_.server.md)* -*Defined in [server.ts:218](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/server.ts#L218)* +*Defined in [server.ts:218](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L218)* Creates a protocol complient WebSocket GraphQL subscription server. Read more about the protocol diff --git a/docs/modules/_types_.md b/docs/modules/_types_.md index c1306ba1..df920921 100644 --- a/docs/modules/_types_.md +++ b/docs/modules/_types_.md @@ -11,15 +11,16 @@ ### Type aliases -* [UUID](_types_.md#uuid) +* [ID](_types_.md#id) ## Type aliases -### UUID +### ID -Ƭ **UUID**: *string* +Ƭ **ID**: *string* -*Defined in [types.ts:13](https://github.com/enisdenjo/graphql-transport-ws/blob/1515fe2/src/types.ts#L13)* +*Defined in [types.ts:14](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/types.ts#L14)* -UUID v4 string type alias generated through the -`generateUUID` function from the client. +ID is a string type alias representing +the globally unique ID used for identifying +subscriptions established by the client. From d1c984fe58f3c0454ca5f554f52299dd4a7e7085 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Fri, 2 Oct 2020 00:40:39 +0200 Subject: [PATCH 10/15] refactor: use globalThis --- src/client.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client.ts b/src/client.ts index 43e36c4e..79e9551f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -69,8 +69,8 @@ export interface ClientOptions { webSocketImpl?: unknown; /** * A custom ID generator for identifying subscriptions. - * The default uses the `crypto` module in the global window - * object, suitable for the browser environment. However, if + * The default uses the `crypto` module in the global scope + * which is present for modern browsers. However, if * it can't be found, `Math.random` would be used instead. */ generateID?: () => ID; @@ -104,12 +104,12 @@ export function createClient(options: ClientOptions): Client { * Reference: https://stackoverflow.com/a/2117523/709884 */ generateID = function generateUUID() { - if (window && window.crypto) { + if (globalThis.crypto) { return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (s) => { const c = Number.parseInt(s, 10); return ( c ^ - (window.crypto.getRandomValues(new Uint8Array(1))[0] & + (globalThis.crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4))) ).toString(16); }); @@ -124,7 +124,7 @@ export function createClient(options: ClientOptions): Client { }, } = options; - let WebSocketImpl = WebSocket; + let WebSocketImpl = globalThis.WebSocket; if (webSocketImpl) { if (!isWebSocket(webSocketImpl)) { throw new Error('Invalid WebSocket implementation provided'); From 9368e011ee9ddcc5fdd40dcc0139477ab6c13ae9 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Fri, 2 Oct 2020 00:53:59 +0200 Subject: [PATCH 11/15] refactor(client): report missing or non-constructor WebSocketImpl --- src/client.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/client.ts b/src/client.ts index 79e9551f..f3c344b1 100644 --- a/src/client.ts +++ b/src/client.ts @@ -131,6 +131,9 @@ export function createClient(options: ClientOptions): Client { } WebSocketImpl = webSocketImpl; } + if (!WebSocketImpl) { + throw new Error('WebSocket implementation missing'); + } const emitter = (() => { const listeners: { [event in Event]: EventListener[] } = { @@ -546,6 +549,7 @@ function isCloseEvent(val: unknown): val is CloseEvent { function isWebSocket(val: unknown): val is typeof WebSocket { return ( typeof val === 'function' && + 'constructor' in val && 'CLOSED' in val && 'CLOSING' in val && 'CONNECTING' in val && From 1a75190e32fc8372d5982598b6d053cb96980426 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Fri, 2 Oct 2020 00:54:21 +0200 Subject: [PATCH 12/15] docs: add client usage in Node recipe --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 94aba789..3079b064 100644 --- a/README.md +++ b/README.md @@ -322,6 +322,32 @@ const link = new WebSocketLink({ +
+Client usage in Node + +```ts +const WebSocket = require('ws'); +const Crypto = require('crypto'); +const { createClient } = require('graphql-transport-ws'); + +const client = createClient({ + url: 'wss://no.browser/graphql', + webSocketImpl: WebSocket, + /** + * Generates a v4 UUID to be used as the ID. + * Reference: https://stackoverflow.com/a/2117523/709884 + */ + generateID: () => + ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => + (c ^ (Crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16), + ), +}); + +// consider other recipes for usage inspiration +``` + +
+
Server usage with Express GraphQL From 42eb7d92dd5857f0a8131a2cdcfe5ca642a5f936 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Fri, 2 Oct 2020 01:02:32 +0200 Subject: [PATCH 13/15] docs: ws module has to be installed [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3079b064..3a2997bd 100644 --- a/README.md +++ b/README.md @@ -326,7 +326,7 @@ const link = new WebSocketLink({ Client usage in Node ```ts -const WebSocket = require('ws'); +const WebSocket = require('ws'); // yarn add ws const Crypto = require('crypto'); const { createClient } = require('graphql-transport-ws'); From f30e852efe93deb6ae80b51bf12183fcf478e9c1 Mon Sep 17 00:00:00 2001 From: enisdenjo Date: Fri, 2 Oct 2020 01:04:30 +0200 Subject: [PATCH 14/15] docs: generate [skip ci] --- docs/enums/_message_.messagetype.md | 12 +++++----- docs/interfaces/_client_.client.md | 6 ++--- docs/interfaces/_client_.clientoptions.md | 20 ++++++++-------- docs/interfaces/_message_.completemessage.md | 4 ++-- .../_message_.connectionackmessage.md | 2 +- .../_message_.connectioninitmessage.md | 4 ++-- docs/interfaces/_message_.errormessage.md | 6 ++--- docs/interfaces/_message_.nextmessage.md | 6 ++--- docs/interfaces/_message_.subscribemessage.md | 6 ++--- docs/interfaces/_message_.subscribepayload.md | 6 ++--- docs/interfaces/_server_.context.md | 12 +++++----- docs/interfaces/_server_.server.md | 4 ++-- docs/interfaces/_server_.serveroptions.md | 24 +++++++++---------- docs/interfaces/_types_.disposable.md | 2 +- docs/interfaces/_types_.sink.md | 6 ++--- docs/modules/_client_.md | 12 +++++----- docs/modules/_message_.md | 2 +- docs/modules/_protocol_.md | 2 +- docs/modules/_server_.md | 4 ++-- docs/modules/_types_.md | 2 +- 20 files changed, 71 insertions(+), 71 deletions(-) diff --git a/docs/enums/_message_.messagetype.md b/docs/enums/_message_.messagetype.md index ad548d20..9c81ffb4 100644 --- a/docs/enums/_message_.messagetype.md +++ b/docs/enums/_message_.messagetype.md @@ -21,7 +21,7 @@ Types of messages allowed to be sent by the client/server over the WS protocol. • **Complete**: = "complete" -*Defined in [message.ts:24](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L24)* +*Defined in [message.ts:24](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L24)* ___ @@ -29,7 +29,7 @@ ___ • **ConnectionAck**: = "connection_ack" -*Defined in [message.ts:19](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L19)* +*Defined in [message.ts:19](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L19)* ___ @@ -37,7 +37,7 @@ ___ • **ConnectionInit**: = "connection_init" -*Defined in [message.ts:18](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L18)* +*Defined in [message.ts:18](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L18)* ___ @@ -45,7 +45,7 @@ ___ • **Error**: = "error" -*Defined in [message.ts:23](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L23)* +*Defined in [message.ts:23](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L23)* ___ @@ -53,7 +53,7 @@ ___ • **Next**: = "next" -*Defined in [message.ts:22](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L22)* +*Defined in [message.ts:22](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L22)* ___ @@ -61,4 +61,4 @@ ___ • **Subscribe**: = "subscribe" -*Defined in [message.ts:21](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L21)* +*Defined in [message.ts:21](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L21)* diff --git a/docs/interfaces/_client_.client.md b/docs/interfaces/_client_.client.md index cd5ebe52..35ecf5b3 100644 --- a/docs/interfaces/_client_.client.md +++ b/docs/interfaces/_client_.client.md @@ -27,7 +27,7 @@ *Inherited from [Disposable](_types_.disposable.md).[dispose](_types_.disposable.md#dispose)* -*Defined in [types.ts:18](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/types.ts#L18)* +*Defined in [types.ts:18](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/types.ts#L18)* Dispose of the instance and clear up resources. @@ -41,7 +41,7 @@ Dispose of the instance and clear up resources. ▸ **on**‹**E**›(`event`: E, `listener`: [EventListener](../modules/_client_.md#eventlistener)‹E›): *function* -*Defined in [client.ts:83](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L83)* +*Defined in [client.ts:83](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L83)* Listens on the client which dispatches events about the socket state. @@ -66,7 +66,7 @@ ___ ▸ **subscribe**‹**T**›(`payload`: [SubscribePayload](_message_.subscribepayload.md), `sink`: [Sink](_types_.sink.md)‹T›): *function* -*Defined in [client.ts:89](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L89)* +*Defined in [client.ts:89](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L89)* Subscribes through the WebSocket following the config parameters. It uses the `sink` to emit received data or errors. Returns a _cleanup_ diff --git a/docs/interfaces/_client_.clientoptions.md b/docs/interfaces/_client_.clientoptions.md index 66ae2124..6f8337ba 100644 --- a/docs/interfaces/_client_.clientoptions.md +++ b/docs/interfaces/_client_.clientoptions.md @@ -27,7 +27,7 @@ Configuration used for the `create` client function. • **connectionParams**? : *Record‹string, unknown› | function* -*Defined in [client.ts:40](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L40)* +*Defined in [client.ts:40](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L40)* Optional parameters that the client specifies when establishing a connection with the server. @@ -37,11 +37,11 @@ ___ • **generateID**? : *undefined | function* -*Defined in [client.ts:76](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L76)* +*Defined in [client.ts:76](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L76)* A custom ID generator for identifying subscriptions. -The default uses the `crypto` module in the global window -object, suitable for the browser environment. However, if +The default uses the `crypto` module in the global scope +which is present for modern browsers. However, if it can't be found, `Math.random` would be used instead. ___ @@ -50,7 +50,7 @@ ___ • **lazy**? : *undefined | false | true* -*Defined in [client.ts:46](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L46)* +*Defined in [client.ts:46](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L46)* Should the connection be established immediately and persisted or after the first listener subscribed. @@ -63,7 +63,7 @@ ___ • **on**? : *Partial‹object›* -*Defined in [client.ts:63](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L63)* +*Defined in [client.ts:63](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L63)* Register listeners before initialising the client. This way you can ensure to catch all client relevant emitted events. @@ -76,7 +76,7 @@ ___ • **retryAttempts**? : *undefined | number* -*Defined in [client.ts:51](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L51)* +*Defined in [client.ts:51](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L51)* How many times should the client try to reconnect on abnormal socket closure before it errors out? @@ -88,7 +88,7 @@ ___ • **retryTimeout**? : *undefined | number* -*Defined in [client.ts:56](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L56)* +*Defined in [client.ts:56](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L56)* How long should the client wait until attempting to retry. @@ -100,7 +100,7 @@ ___ • **url**: *string* -*Defined in [client.ts:38](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L38)* +*Defined in [client.ts:38](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L38)* URL of the GraphQL server to connect. @@ -110,7 +110,7 @@ ___ • **webSocketImpl**? : *unknown* -*Defined in [client.ts:69](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L69)* +*Defined in [client.ts:69](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L69)* A custom WebSocket implementation to use instead of the one provided by the global scope. Mostly useful for when diff --git a/docs/interfaces/_message_.completemessage.md b/docs/interfaces/_message_.completemessage.md index 947d753c..fe384413 100644 --- a/docs/interfaces/_message_.completemessage.md +++ b/docs/interfaces/_message_.completemessage.md @@ -19,7 +19,7 @@ • **id**: *string* -*Defined in [message.ts:61](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L61)* +*Defined in [message.ts:61](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L61)* ___ @@ -27,4 +27,4 @@ ___ • **type**: *[Complete](../enums/_message_.messagetype.md#complete)* -*Defined in [message.ts:62](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L62)* +*Defined in [message.ts:62](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L62)* diff --git a/docs/interfaces/_message_.connectionackmessage.md b/docs/interfaces/_message_.connectionackmessage.md index 555624b8..3c634a4e 100644 --- a/docs/interfaces/_message_.connectionackmessage.md +++ b/docs/interfaces/_message_.connectionackmessage.md @@ -18,4 +18,4 @@ • **type**: *[ConnectionAck](../enums/_message_.messagetype.md#connectionack)* -*Defined in [message.ts:33](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L33)* +*Defined in [message.ts:33](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L33)* diff --git a/docs/interfaces/_message_.connectioninitmessage.md b/docs/interfaces/_message_.connectioninitmessage.md index 08bd2f5b..4e06be9b 100644 --- a/docs/interfaces/_message_.connectioninitmessage.md +++ b/docs/interfaces/_message_.connectioninitmessage.md @@ -19,7 +19,7 @@ • **payload**? : *Record‹string, unknown›* -*Defined in [message.ts:29](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L29)* +*Defined in [message.ts:29](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L29)* ___ @@ -27,4 +27,4 @@ ___ • **type**: *[ConnectionInit](../enums/_message_.messagetype.md#connectioninit)* -*Defined in [message.ts:28](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L28)* +*Defined in [message.ts:28](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L28)* diff --git a/docs/interfaces/_message_.errormessage.md b/docs/interfaces/_message_.errormessage.md index 03d2e7dc..2078529b 100644 --- a/docs/interfaces/_message_.errormessage.md +++ b/docs/interfaces/_message_.errormessage.md @@ -20,7 +20,7 @@ • **id**: *string* -*Defined in [message.ts:55](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L55)* +*Defined in [message.ts:55](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L55)* ___ @@ -28,7 +28,7 @@ ___ • **payload**: *readonly GraphQLError[]* -*Defined in [message.ts:57](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L57)* +*Defined in [message.ts:57](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L57)* ___ @@ -36,4 +36,4 @@ ___ • **type**: *[Error](../enums/_message_.messagetype.md#error)* -*Defined in [message.ts:56](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L56)* +*Defined in [message.ts:56](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L56)* diff --git a/docs/interfaces/_message_.nextmessage.md b/docs/interfaces/_message_.nextmessage.md index 1f7bb0e3..68832f89 100644 --- a/docs/interfaces/_message_.nextmessage.md +++ b/docs/interfaces/_message_.nextmessage.md @@ -20,7 +20,7 @@ • **id**: *string* -*Defined in [message.ts:49](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L49)* +*Defined in [message.ts:49](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L49)* ___ @@ -28,7 +28,7 @@ ___ • **payload**: *ExecutionResult* -*Defined in [message.ts:51](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L51)* +*Defined in [message.ts:51](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L51)* ___ @@ -36,4 +36,4 @@ ___ • **type**: *[Next](../enums/_message_.messagetype.md#next)* -*Defined in [message.ts:50](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L50)* +*Defined in [message.ts:50](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L50)* diff --git a/docs/interfaces/_message_.subscribemessage.md b/docs/interfaces/_message_.subscribemessage.md index 81cbe8c1..615f8d55 100644 --- a/docs/interfaces/_message_.subscribemessage.md +++ b/docs/interfaces/_message_.subscribemessage.md @@ -20,7 +20,7 @@ • **id**: *string* -*Defined in [message.ts:37](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L37)* +*Defined in [message.ts:37](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L37)* ___ @@ -28,7 +28,7 @@ ___ • **payload**: *[SubscribePayload](_message_.subscribepayload.md)* -*Defined in [message.ts:39](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L39)* +*Defined in [message.ts:39](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L39)* ___ @@ -36,4 +36,4 @@ ___ • **type**: *[Subscribe](../enums/_message_.messagetype.md#subscribe)* -*Defined in [message.ts:38](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L38)* +*Defined in [message.ts:38](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L38)* diff --git a/docs/interfaces/_message_.subscribepayload.md b/docs/interfaces/_message_.subscribepayload.md index 29a02cc1..d2a7c1fe 100644 --- a/docs/interfaces/_message_.subscribepayload.md +++ b/docs/interfaces/_message_.subscribepayload.md @@ -20,7 +20,7 @@ • **operationName**? : *string | null* -*Defined in [message.ts:43](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L43)* +*Defined in [message.ts:43](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L43)* ___ @@ -28,7 +28,7 @@ ___ • **query**: *string | DocumentNode* -*Defined in [message.ts:44](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L44)* +*Defined in [message.ts:44](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L44)* ___ @@ -36,4 +36,4 @@ ___ • **variables**? : *Record‹string, unknown› | null* -*Defined in [message.ts:45](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L45)* +*Defined in [message.ts:45](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L45)* diff --git a/docs/interfaces/_server_.context.md b/docs/interfaces/_server_.context.md index b603e339..6349d6a0 100644 --- a/docs/interfaces/_server_.context.md +++ b/docs/interfaces/_server_.context.md @@ -23,7 +23,7 @@ • **acknowledged**: *boolean* -*Defined in [server.ts:194](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L194)* +*Defined in [server.ts:194](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L194)* Indicates that the connection was acknowledged by having dispatched the `ConnectionAck` message @@ -35,7 +35,7 @@ ___ • **connectionInitReceived**: *boolean* -*Defined in [server.ts:188](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L188)* +*Defined in [server.ts:188](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L188)* Indicates that the `ConnectionInit` message has been received by the server. If this is @@ -48,7 +48,7 @@ ___ • **connectionParams**? : *Readonly‹Record‹string, unknown››* -*Defined in [server.ts:196](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L196)* +*Defined in [server.ts:196](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L196)* The parameters passed during the connection initialisation. @@ -58,7 +58,7 @@ ___ • **request**: *IncomingMessage* -*Defined in [server.ts:181](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L181)* +*Defined in [server.ts:181](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L181)* The initial HTTP request before the actual socket and connection is established. @@ -69,7 +69,7 @@ ___ • **socket**: *WebSocket* -*Defined in [server.ts:176](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L176)* +*Defined in [server.ts:176](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L176)* The actual WebSocket connection between the server and the client. @@ -79,7 +79,7 @@ ___ • **subscriptions**: *Record‹[ID](../modules/_types_.md#id), AsyncIterator‹unknown››* -*Defined in [server.ts:202](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L202)* +*Defined in [server.ts:202](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L202)* Holds the active subscriptions for this context. Subscriptions are for `subscription` operations **only**, diff --git a/docs/interfaces/_server_.server.md b/docs/interfaces/_server_.server.md index f5995f28..b40f8d39 100644 --- a/docs/interfaces/_server_.server.md +++ b/docs/interfaces/_server_.server.md @@ -23,7 +23,7 @@ *Inherited from [Disposable](_types_.disposable.md).[dispose](_types_.disposable.md#dispose)* -*Defined in [types.ts:18](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/types.ts#L18)* +*Defined in [types.ts:18](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/types.ts#L18)* Dispose of the instance and clear up resources. @@ -37,4 +37,4 @@ ___ • **webSocketServer**: *Server* -*Defined in [server.ts:206](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L206)* +*Defined in [server.ts:206](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L206)* diff --git a/docs/interfaces/_server_.serveroptions.md b/docs/interfaces/_server_.serveroptions.md index 650c60df..873810fc 100644 --- a/docs/interfaces/_server_.serveroptions.md +++ b/docs/interfaces/_server_.serveroptions.md @@ -29,7 +29,7 @@ • **connectionInitWaitTimeout**? : *undefined | number* -*Defined in [server.ts:126](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L126)* +*Defined in [server.ts:126](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L126)* **`default`** 3 * 1000 (3 seconds) @@ -49,7 +49,7 @@ ___ • **context**? : *SubscriptionArgs["contextValue"]* -*Defined in [server.ts:62](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L62)* +*Defined in [server.ts:62](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L62)* A value which is provided to every resolver and holds important contextual information like the currently @@ -63,7 +63,7 @@ ___ • **execute**: *function* -*Defined in [server.ts:82](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L82)* +*Defined in [server.ts:82](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L82)* Is the `subscribe` function from GraphQL which is used to @@ -86,7 +86,7 @@ ___ • **formatExecutionResult**? : *[ExecutionResultFormatter](../modules/_server_.md#executionresultformatter)* -*Defined in [server.ts:138](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L138)* +*Defined in [server.ts:138](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L138)* Format the operation execution results if the implementation requires an adjusted @@ -99,7 +99,7 @@ ___ • **keepAlive**? : *undefined | number* -*Defined in [server.ts:169](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L169)* +*Defined in [server.ts:169](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L169)* The timout between dispatched keep-alive messages. Internally the lib uses the [WebSocket Ping and Pongs]((https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers#Pings_and_Pongs_The_Heartbeat_of_WebSockets)) to check that the link between @@ -114,7 +114,7 @@ ___ • **onComplete**? : *undefined | function* -*Defined in [server.ts:160](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L160)* +*Defined in [server.ts:160](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L160)* The complete callback is executed after the operation has completed or the subscription @@ -126,7 +126,7 @@ ___ • **onConnect**? : *undefined | function* -*Defined in [server.ts:112](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L112)* +*Defined in [server.ts:112](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L112)* Is the connection callback called when the client requests the connection initialisation @@ -153,7 +153,7 @@ ___ • **onSubscribe**? : *undefined | function* -*Defined in [server.ts:148](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L148)* +*Defined in [server.ts:148](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L148)* The subscribe callback executed before the actual operation execution. Useful @@ -169,7 +169,7 @@ ___ • **roots**? : *undefined | object* -*Defined in [server.ts:70](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L70)* +*Defined in [server.ts:70](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L70)* The GraphQL root fields or resolvers to go alongside the schema. Learn more about them @@ -183,7 +183,7 @@ ___ • **schema**? : *GraphQLSchema* -*Defined in [server.ts:54](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L54)* +*Defined in [server.ts:54](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L54)* The GraphQL schema on which the operations will be executed and validated against. If @@ -197,7 +197,7 @@ ___ • **subscribe**: *function* -*Defined in [server.ts:89](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L89)* +*Defined in [server.ts:89](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L89)* Is the `subscribe` function from GraphQL which is used to @@ -220,7 +220,7 @@ ___ • **validationRules**? : *readonly ValidationRule[]* -*Defined in [server.ts:131](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L131)* +*Defined in [server.ts:131](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L131)* Custom validation rules overriding all validation rules defined by the GraphQL spec. diff --git a/docs/interfaces/_types_.disposable.md b/docs/interfaces/_types_.disposable.md index 1c9cd06a..1c8dd5c8 100644 --- a/docs/interfaces/_types_.disposable.md +++ b/docs/interfaces/_types_.disposable.md @@ -22,7 +22,7 @@ • **dispose**: *function* -*Defined in [types.ts:18](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/types.ts#L18)* +*Defined in [types.ts:18](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/types.ts#L18)* Dispose of the instance and clear up resources. diff --git a/docs/interfaces/_types_.sink.md b/docs/interfaces/_types_.sink.md index 6ba7bd14..e9034a3b 100644 --- a/docs/interfaces/_types_.sink.md +++ b/docs/interfaces/_types_.sink.md @@ -26,7 +26,7 @@ A representation of any set of values over any amount of time. ▸ **complete**(): *void* -*Defined in [types.ts:30](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/types.ts#L30)* +*Defined in [types.ts:30](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/types.ts#L30)* The sink has completed. This function "closes" the sink. @@ -38,7 +38,7 @@ ___ ▸ **error**(`error`: Error | CloseEvent | readonly GraphQLError[]): *void* -*Defined in [types.ts:28](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/types.ts#L28)* +*Defined in [types.ts:28](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/types.ts#L28)* An error that has occured. Calling this function "closes" the sink. @@ -56,7 +56,7 @@ ___ ▸ **next**(`value`: T): *void* -*Defined in [types.ts:26](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/types.ts#L26)* +*Defined in [types.ts:26](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/types.ts#L26)* Next value arriving. diff --git a/docs/modules/_client_.md b/docs/modules/_client_.md index 271ddbb4..00745dac 100644 --- a/docs/modules/_client_.md +++ b/docs/modules/_client_.md @@ -27,7 +27,7 @@ Ƭ **Event**: *[EventConnecting](_client_.md#eventconnecting) | [EventConnected](_client_.md#eventconnected) | [EventClosed](_client_.md#eventclosed)* -*Defined in [client.ts:23](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L23)* +*Defined in [client.ts:23](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L23)* ___ @@ -35,7 +35,7 @@ ___ Ƭ **EventClosed**: *"closed"* -*Defined in [client.ts:22](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L22)* +*Defined in [client.ts:22](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L22)* ___ @@ -43,7 +43,7 @@ ___ Ƭ **EventConnected**: *"connected"* -*Defined in [client.ts:21](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L21)* +*Defined in [client.ts:21](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L21)* ___ @@ -51,7 +51,7 @@ ___ Ƭ **EventConnecting**: *"connecting"* -*Defined in [client.ts:20](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L20)* +*Defined in [client.ts:20](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L20)* ___ @@ -59,7 +59,7 @@ ___ Ƭ **EventListener**: *E extends EventConnecting ? function : E extends EventConnected ? function : E extends EventClosed ? function : never* -*Defined in [client.ts:25](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L25)* +*Defined in [client.ts:25](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L25)* ## Functions @@ -67,7 +67,7 @@ ___ ▸ **createClient**(`options`: [ClientOptions](../interfaces/_client_.clientoptions.md)): *[Client](../interfaces/_client_.client.md)* -*Defined in [client.ts:93](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/client.ts#L93)* +*Defined in [client.ts:93](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/client.ts#L93)* Creates a disposable GraphQL subscriptions client. diff --git a/docs/modules/_message_.md b/docs/modules/_message_.md index ddef138e..b57e677f 100644 --- a/docs/modules/_message_.md +++ b/docs/modules/_message_.md @@ -28,4 +28,4 @@ Ƭ **Message**: *T extends ConnectionAck ? ConnectionAckMessage : T extends ConnectionInit ? ConnectionInitMessage : T extends Subscribe ? SubscribeMessage : T extends Next ? NextMessage : T extends Error ? ErrorMessage : T extends Complete ? CompleteMessage : never* -*Defined in [message.ts:65](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/message.ts#L65)* +*Defined in [message.ts:65](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/message.ts#L65)* diff --git a/docs/modules/_protocol_.md b/docs/modules/_protocol_.md index dabc1f78..49533ba1 100644 --- a/docs/modules/_protocol_.md +++ b/docs/modules/_protocol_.md @@ -16,6 +16,6 @@ protocol • **GRAPHQL_TRANSPORT_WS_PROTOCOL**: *"graphql-transport-ws"* = "graphql-transport-ws" -*Defined in [protocol.ts:8](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/protocol.ts#L8)* +*Defined in [protocol.ts:8](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/protocol.ts#L8)* The WebSocket sub-protocol used for the [GraphQL over WebSocket Protocol](/PROTOCOL.md). diff --git a/docs/modules/_server_.md b/docs/modules/_server_.md index 9f5f20da..e31f9ab1 100644 --- a/docs/modules/_server_.md +++ b/docs/modules/_server_.md @@ -24,7 +24,7 @@ Ƭ **ExecutionResultFormatter**: *function* -*Defined in [server.ts:41](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L41)* +*Defined in [server.ts:41](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L41)* #### Type declaration: @@ -43,7 +43,7 @@ Name | Type | ▸ **createServer**(`options`: [ServerOptions](../interfaces/_server_.serveroptions.md), `websocketOptionsOrServer`: WebSocketServerOptions | WebSocketServer): *[Server](../interfaces/_server_.server.md)* -*Defined in [server.ts:218](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/server.ts#L218)* +*Defined in [server.ts:218](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/server.ts#L218)* Creates a protocol complient WebSocket GraphQL subscription server. Read more about the protocol diff --git a/docs/modules/_types_.md b/docs/modules/_types_.md index df920921..a7984719 100644 --- a/docs/modules/_types_.md +++ b/docs/modules/_types_.md @@ -19,7 +19,7 @@ Ƭ **ID**: *string* -*Defined in [types.ts:14](https://github.com/enisdenjo/graphql-transport-ws/blob/e35a1ac/src/types.ts#L14)* +*Defined in [types.ts:14](https://github.com/enisdenjo/graphql-transport-ws/blob/42eb7d9/src/types.ts#L14)* ID is a string type alias representing the globally unique ID used for identifying From a51313f4dd696f30b45f42e3bd8133944d91130f Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 1 Oct 2020 23:06:26 +0000 Subject: [PATCH 15/15] =?UTF-8?q?chore(release):=20=F0=9F=8E=89=201.7.0=20?= =?UTF-8?q?[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # [1.7.0](https://github.com/enisdenjo/graphql-transport-ws/compare/v1.6.0...v1.7.0) (2020-10-01) ### Bug Fixes * **client:** Dispose of subscription on complete or error messages ([#23](https://github.com/enisdenjo/graphql-transport-ws/issues/23)) ([fb4d8e9](https://github.com/enisdenjo/graphql-transport-ws/commit/fb4d8e9efdfdd0cbe3b7cc34ddadbad3a795ae35)) * **server:** `subscription` operations are distinct on the message ID ([#24](https://github.com/enisdenjo/graphql-transport-ws/issues/24)) ([dfffb05](https://github.com/enisdenjo/graphql-transport-ws/commit/dfffb0502be5dd9ab5598e785b9988b1f4000227)) ### Features * **client:** Optional `generateID` to provide subscription IDs ([#22](https://github.com/enisdenjo/graphql-transport-ws/issues/22)) ([9a3f54a](https://github.com/enisdenjo/graphql-transport-ws/commit/9a3f54a8198379b402a8abe414ab5727ccec45cf)), closes [#21](https://github.com/enisdenjo/graphql-transport-ws/issues/21) --- CHANGELOG.md | 13 +++++++++++++ package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94735538..2a314d3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +# [1.7.0](https://github.com/enisdenjo/graphql-transport-ws/compare/v1.6.0...v1.7.0) (2020-10-01) + + +### Bug Fixes + +* **client:** Dispose of subscription on complete or error messages ([#23](https://github.com/enisdenjo/graphql-transport-ws/issues/23)) ([fb4d8e9](https://github.com/enisdenjo/graphql-transport-ws/commit/fb4d8e9efdfdd0cbe3b7cc34ddadbad3a795ae35)) +* **server:** `subscription` operations are distinct on the message ID ([#24](https://github.com/enisdenjo/graphql-transport-ws/issues/24)) ([dfffb05](https://github.com/enisdenjo/graphql-transport-ws/commit/dfffb0502be5dd9ab5598e785b9988b1f4000227)) + + +### Features + +* **client:** Optional `generateID` to provide subscription IDs ([#22](https://github.com/enisdenjo/graphql-transport-ws/issues/22)) ([9a3f54a](https://github.com/enisdenjo/graphql-transport-ws/commit/9a3f54a8198379b402a8abe414ab5727ccec45cf)), closes [#21](https://github.com/enisdenjo/graphql-transport-ws/issues/21) + # [1.6.0](https://github.com/enisdenjo/graphql-transport-ws/compare/v1.5.0...v1.6.0) (2020-09-28) diff --git a/package.json b/package.json index ed7f5954..0be7789f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "graphql-transport-ws", - "version": "1.6.0", + "version": "1.7.0", "description": "Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client", "keywords": [ "graphql",