Documentation
Modules
client

Module: client

Classes

Interfaces

Client

Event

Ƭ Event: EventConnecting | EventOpened | EventConnected | EventPing | EventPong | EventMessage | EventClosed | EventError

All events that could occur.

Defined in

src/client.ts:92


EventClosed

Ƭ EventClosed: "closed"

WebSocket connection has closed.

Defined in

src/client.ts:78


EventClosedListener

Ƭ EventClosedListener: (event: unknown) => void

The argument is actually the websocket CloseEvent, but to avoid bundling DOM typings because the client can run in Node env too, you should assert the websocket type during implementation.

Type declaration

▸ (event): void

Parameters
NameType
eventunknown
Returns

void

Defined in

src/client.ts:167


EventConnected

Ƭ EventConnected: "connected"

Open WebSocket connection has been acknowledged.

Defined in

src/client.ts:50


EventConnectedListener

Ƭ EventConnectedListener: (socket: unknown, payload: ConnectionAckMessage["payload"], wasRetry: boolean) => void

The first argument is actually the WebSocket, but to avoid bundling DOM typings because the client can run in Node env too, you should assert the websocket type during implementation.

Also, the second argument is the optional payload that the server may send through the ConnectionAck message.

Type declaration

▸ (socket, payload, wasRetry): void

Parameters
NameType
socketunknown
payloadConnectionAckMessage["payload"]
wasRetryboolean
Returns

void

Defined in

src/client.ts:124


EventConnecting

Ƭ EventConnecting: "connecting"

WebSocket started connecting.

Defined in

src/client.ts:36


EventConnectingListener

Ƭ EventConnectingListener: (isRetry: boolean) => void

Type declaration

▸ (isRetry): void

Parameters
NameType
isRetryboolean
Returns

void

Defined in

src/client.ts:103


EventError

Ƭ EventError: "error"

WebSocket connection had an error or client had an internal error.

Defined in

src/client.ts:85


EventErrorListener

Ƭ EventErrorListener: (error: unknown) => void

Events dispatched from the WebSocket onerror are handled in this listener, as well as all internal client errors that could throw.

Type declaration

▸ (error): void

Parameters
NameType
errorunknown
Returns

void

Defined in

src/client.ts:175


EventListener

Ƭ EventListener<E>: E extends EventConnecting ? EventConnectingListener : E extends EventOpened ? EventOpenedListener : E extends EventConnected ? EventConnectedListener : E extends EventPing ? EventPingListener : E extends EventPong ? EventPongListener : E extends EventMessage ? EventMessageListener : E extends EventClosed ? EventClosedListener : E extends EventError ? EventErrorListener : never

Type parameters

NameType
Eextends Event

Defined in

src/client.ts:178


EventMessage

Ƭ EventMessage: "message"

A message has been received.

Defined in

src/client.ts:71


EventMessageListener

Ƭ EventMessageListener: (message: Message) => void

Called for all valid messages received by the client. Mainly useful for debugging and logging received messages.

Type declaration

▸ (message): void

Parameters
NameType
messageMessage
Returns

void

Defined in

src/client.ts:158


EventOpened

Ƭ EventOpened: "opened"

WebSocket has opened.

Defined in

src/client.ts:43


EventOpenedListener

Ƭ EventOpenedListener: (socket: unknown) => void

The first argument is actually the WebSocket, but to avoid bundling DOM typings because the client can run in Node env too, you should assert the websocket type during implementation.

Type declaration

▸ (socket): void

Parameters
NameType
socketunknown
Returns

void

Defined in

src/client.ts:112


EventPing

Ƭ EventPing: "ping"

PingMessage has been received or sent.

Defined in

src/client.ts:57


EventPingListener

Ƭ EventPingListener: (received: boolean, payload: PingMessage["payload"]) => void

The first argument communicates whether the ping was received from the server. If false, the ping was sent by the client.

Type declaration

▸ (received, payload): void

Parameters
NameType
receivedboolean
payloadPingMessage["payload"]
Returns

void

Defined in

src/client.ts:136


EventPong

Ƭ EventPong: "pong"

PongMessage has been received or sent.

Defined in

src/client.ts:64


EventPongListener

Ƭ EventPongListener: (received: boolean, payload: PongMessage["payload"]) => void

The first argument communicates whether the pong was received from the server. If false, the pong was sent by the client.

Type declaration

▸ (received, payload): void

Parameters
NameType
receivedboolean
payloadPongMessage["payload"]
Returns

void

Defined in

src/client.ts:147


createClient

createClient<P>(options): Client

Creates a disposable GraphQL over WebSocket client.

Type parameters

NameType
Pextends undefined | Record<string, unknown> = undefined | Record<string, unknown>

Parameters

NameType
optionsClientOptions<P>

Returns

Client

Defined in

src/client.ts:471

Other

CloseCode

Re-exports CloseCode


CompleteMessage

Re-exports CompleteMessage


ConnectionAckMessage

Re-exports ConnectionAckMessage


ConnectionInitMessage

Re-exports ConnectionInitMessage


Disposable

Re-exports Disposable


ErrorMessage

Re-exports ErrorMessage


ExecutionPatchResult

Re-exports ExecutionPatchResult


ExecutionResult

Re-exports ExecutionResult


GRAPHQL_TRANSPORT_WS_PROTOCOL

Re-exports GRAPHQL_TRANSPORT_WS_PROTOCOL


ID

Re-exports ID


JSONMessageReplacer

Re-exports JSONMessageReplacer


JSONMessageReviver

Re-exports JSONMessageReviver


Message

Re-exports Message


MessageType

Re-exports MessageType


NextMessage

Re-exports NextMessage


PingMessage

Re-exports PingMessage


PongMessage

Re-exports PongMessage


Sink

Re-exports Sink


SubscribeMessage

Re-exports SubscribeMessage


SubscribePayload

Re-exports SubscribePayload


isMessage

Re-exports isMessage


parseMessage

Re-exports parseMessage


stringifyMessage

Re-exports stringifyMessage


validateMessage

Re-exports validateMessage