graphql-ws / client
- CompleteMessage
- ConnectionAckMessage
- ConnectionInitMessage
- Disposable
- ErrorMessage
- GRAPHQL_TRANSPORT_WS_PROTOCOL
- ID
- JSONMessageReplacer
- JSONMessageReviver
- Message
- MessageType
- NextMessage
- Sink
- SubscribeMessage
- SubscribePayload
- isMessage
- parseMessage
- stringifyMessage
- Event
- EventClosed
- EventClosedListener
- EventConnected
- EventConnectedListener
- EventConnecting
- EventConnectingListener
- EventError
- EventErrorListener
- EventListener
- EventMessage
- EventMessageListener
Ƭ Event: EventConnecting | EventConnected | EventMessage | EventClosed | EventError
Ƭ EventClosed: "closed"
Ƭ 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.
▸ (event
): void
Name | Type |
---|---|
event |
unknown |
void
Ƭ EventConnected: "connected"
Ƭ 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.
▸ (socket
, payload?
): void
Name | Type |
---|---|
socket |
unknown |
payload? |
Record <string, unknown> |
void
Ƭ EventConnecting: "connecting"
Ƭ EventConnectingListener: () => void
▸ (): void
void
Ƭ EventError: "error"
Ƭ 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.
▸ (error
): void
Name | Type |
---|---|
error |
unknown |
void
Ƭ EventListener<E>: E
extends EventConnecting ? EventConnectingListener : E
extends EventConnected ? EventConnectedListener : E
extends EventMessage ? EventMessageListener : E
extends EventClosed ? EventClosedListener : E
extends EventError ? EventErrorListener : never
Name | Type |
---|---|
E |
E : Event |
Ƭ EventMessage: "message"
Ƭ EventMessageListener: (message
: Message) => void
Called for all valid messages received by the client. Mainly useful for debugging and logging received messages.
▸ (message
): void
Name | Type |
---|---|
message |
Message |
void
▸ createClient(options
): Client
Creates a disposable GraphQL over WebSocket client.
Name | Type |
---|---|
options |
ClientOptions |
Re-exports: CompleteMessage
Re-exports: ConnectionAckMessage
Re-exports: ConnectionInitMessage
Re-exports: Disposable
Re-exports: ErrorMessage
Re-exports: GRAPHQL_TRANSPORT_WS_PROTOCOL
Re-exports: ID
Re-exports: JSONMessageReplacer
Re-exports: JSONMessageReviver
Re-exports: Message
Re-exports: MessageType
Re-exports: NextMessage
Re-exports: Sink
Re-exports: SubscribeMessage
Re-exports: SubscribePayload
Re-exports: isMessage
Re-exports: parseMessage
Re-exports: stringifyMessage