Interface: Client
Defined in: src/client.ts:413
Extends
Properties
dispose()
dispose: () =>
void|Promise<void>
Defined in: src/common.ts:57
Dispose of the instance and clear up resources.
Returns
void | Promise<void>
Inherited from
Methods
iterate()
iterate<
Data,Extensions>(payload):AsyncIterableIterator<FormattedExecutionResult<Data,Extensions> |FormattedExecutionPatchResult<Data,Extensions>>
Defined in: src/client.ts:434
Subscribes and iterates over emitted results from the WebSocket through the returned async iterator.
Type Parameters
• Data = Record<string, unknown>
• Extensions = unknown
Parameters
payload
Returns
AsyncIterableIterator<FormattedExecutionResult<Data, Extensions> | FormattedExecutionPatchResult<Data, Extensions>>
on()
on<
E>(event,listener): () =>void
Defined in: src/client.ts:417
Listens on the client which dispatches events about the socket state.
Type Parameters
• E extends Event
Parameters
event
E
listener
Returns
Function
Returns
void
subscribe()
subscribe<
Data,Extensions>(payload,sink): () =>void
Defined in: src/client.ts:423
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
• Data = Record<string, unknown>
• Extensions = unknown
Parameters
payload
sink
Sink<FormattedExecutionResult<Data, Extensions> | FormattedExecutionPatchResult<Data, Extensions>>
Returns
Function
Returns
void
terminate()
terminate():
void
Defined in: src/client.ts:452
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