Skip to content

Latest commit

 

History

History
338 lines (195 loc) · 6.83 KB

client.md

File metadata and controls

338 lines (195 loc) · 6.83 KB

graphql-ws / client

Module: client

Table of contents

References

Interfaces

Type aliases

Functions

Client

Event

Ƭ Event: EventConnecting | EventConnected | EventMessage | EventClosed | EventError


EventClosed

Ƭ EventClosed: "closed"


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
Name Type
event unknown
Returns

void


EventConnected

Ƭ EventConnected: "connected"


EventConnectedListener

Ƭ EventConnectedListener: (socket: unknown, payload?: Record<string, 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.

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

Type declaration

▸ (socket, payload?): void

Parameters
Name Type
socket unknown
payload? Record<string, unknown>
Returns

void


EventConnecting

Ƭ EventConnecting: "connecting"


EventConnectingListener

Ƭ EventConnectingListener: () => void

Type declaration

▸ (): void

Returns

void


EventError

Ƭ EventError: "error"


EventErrorListener

Ƭ EventErrorListener: (error: unknown) => void

The argument can be either an Error Event or an instance of Error, but to avoid bundling DOM typings because the client can run in Node env too, you should assert the type during implementation. Events dispatched from the WebSocket onerror can be handler in this listener.

Type declaration

▸ (error): void

Parameters
Name Type
error unknown
Returns

void


EventListener

Ƭ EventListener<E>: E extends EventConnecting ? EventConnectingListener : E extends EventConnected ? EventConnectedListener : E extends EventMessage ? EventMessageListener : E extends EventClosed ? EventClosedListener : E extends EventError ? EventErrorListener : never

Type parameters

Name Type
E E: Event

EventMessage

Ƭ EventMessage: "message"


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
Name Type
message Message
Returns

void


createClient

createClient(options): Client

Creates a disposable GraphQL over WebSocket client.

Parameters

Name Type
options ClientOptions

Returns

Client

Other

CompleteMessage

Re-exports: CompleteMessage


ConnectionAckMessage

Re-exports: ConnectionAckMessage


ConnectionInitMessage

Re-exports: ConnectionInitMessage


Disposable

Re-exports: Disposable


ErrorMessage

Re-exports: ErrorMessage


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


Sink

Re-exports: Sink


SubscribeMessage

Re-exports: SubscribeMessage


SubscribePayload

Re-exports: SubscribePayload


isMessage

Re-exports: isMessage


parseMessage

Re-exports: parseMessage


stringifyMessage

Re-exports: stringifyMessage