Documentation
Interfaces
client.Client

Interface: Client

client.Client

Hierarchy

Properties

dispose

dispose: () => void | Promise<void>

Dispose of the instance and clear up resources.

Type declaration

▸ (): void | Promise<void>

Returns

void | Promise<void>

Inherited from

Disposable.dispose

Defined in

src/common.ts:57

Methods

iterate

iterate<Data, Extensions>(payload): AsyncIterableIterator<ExecutionResult<Data, Extensions>>

Subscribes and iterates over emitted results from the WebSocket through the returned async iterator.

Type parameters

NameType
DataRecord<string, unknown>
Extensionsunknown

Parameters

NameType
payloadSubscribePayload

Returns

AsyncIterableIterator<ExecutionResult<Data, Extensions>>

Defined in

src/client.ts:448


on

on<E>(event, listener): () => void

Listens on the client which dispatches events about the socket state.

Type parameters

NameType
Eextends Event

Parameters

NameType
eventE
listenerEventListener<E>

Returns

fn

▸ (): void

Returns

void

Defined in

src/client.ts:434


subscribe

subscribe<Data, Extensions>(payload, sink): () => void

Subscribes through the WebSocket following the config parameters. It uses the sink to emit received data or errors. Returns a cleanup function used for dropping the subscription and cleaning stuff up.

Type parameters

NameType
DataRecord<string, unknown>
Extensionsunknown

Parameters

NameType
payloadSubscribePayload
sinkSink<ExecutionResult<Data, Extensions>>

Returns

fn

▸ (): void

Returns

void

Defined in

src/client.ts:440


terminate

terminate(): void

Terminates the WebSocket abruptly and immediately.

A close event 4499: Terminated is issued to the current WebSocket and a synthetic TerminatedCloseEvent is immediately emitted without waiting for the one coming from WebSocket.onclose.

Terminating is not considered fatal and a connection retry will occur as expected.

Useful in cases where the WebSocket is stuck and not emitting any events; can happen on iOS Safari, see: https://github.com/enisdenjo/graphql-ws/discussions/290.

Returns

void

Defined in

src/client.ts:463