Catch the highlights of GraphQLConf 2023! Click for recordings. Or check out our recap blog post.
Documentation
Interfaces
client.Client

Interface: Client

client.Client

Hierarchy

Properties

dispose

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

Type declaration

▸ (): void | Promise<void>

Dispose of the instance and clear up resources.

Returns

void | Promise<void>

Inherited from

Disposable.dispose

Defined in

src/common.ts:57 (opens in a new tab)

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:447 (opens in a new tab)


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

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

Returns

void

Defined in

src/client.ts:433 (opens in a new tab)


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

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.

Returns

void

Defined in

src/client.ts:439 (opens in a new tab)


terminate

terminate(): void

Terminates the WebSocket abruptly and immediately.

A close event 4499: Terminated is issued to the current WebSocket and an artificial { code: 4499, reason: 'Terminated', wasClean: false } close-event-like object 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 (opens in a new tab).

Returns

void

Defined in

src/client.ts:462 (opens in a new tab)