Interface: Client
client.Client
Hierarchy
-
↳
Client
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
Defined in
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
Name | Type |
---|---|
Data | Record <string , unknown > |
Extensions | unknown |
Parameters
Name | Type |
---|---|
payload | SubscribePayload |
Returns
AsyncIterableIterator
<ExecutionResult
<Data
, Extensions
>>
Defined in
on
▸ on<E
>(event
, listener
): () => void
Listens on the client which dispatches events about the socket state.
Type parameters
Name | Type |
---|---|
E | extends Event |
Parameters
Name | Type |
---|---|
event | E |
listener | EventListener <E > |
Returns
fn
▸ (): void
Returns
void
Defined in
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
Name | Type |
---|---|
Data | Record <string , unknown > |
Extensions | unknown |
Parameters
Name | Type |
---|---|
payload | SubscribePayload |
sink | Sink <ExecutionResult <Data , Extensions >> |
Returns
fn
▸ (): void
Returns
void
Defined in
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