Documentation
Modules
common

Module: common

Enumerations

Interfaces

Common

ID

Ƭ ID: string

ID is a string type alias representing the globally unique ID used for identifying subscriptions established by the client.

Defined in

src/common.ts:52


JSONMessageReplacer

Ƭ JSONMessageReplacer: (this: any, key: string, value: any) => any

Type declaration

▸ (this, key, value): any

Function that allows customization of the produced JSON string for the elements of an outgoing Message object.

Read more about using it: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#the_replacer_parameter

Parameters
NameType
thisany
keystring
valueany
Returns

any

Defined in

src/common.ts:446


JSONMessageReviver

Ƭ JSONMessageReviver: (this: any, key: string, value: any) => any

Type declaration

▸ (this, key, value): any

Function for transforming values within a message during JSON parsing The values are produced by parsing the incoming raw JSON.

Read more about using it: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#using_the_reviver_parameter

Parameters
NameType
thisany
keystring
valueany
Returns

any

Defined in

src/common.ts:421


Message

Ƭ Message<T>: T extends ConnectionAck ? ConnectionAckMessage : T extends ConnectionInit ? ConnectionInitMessage : T extends Ping ? PingMessage : T extends Pong ? PongMessage : T extends Subscribe ? SubscribeMessage : T extends Next ? NextMessage : T extends Error ? ErrorMessage : T extends Complete ? CompleteMessage : never

Type parameters

NameType
Textends MessageType = MessageType

Defined in

src/common.ts:182


GRAPHQL_TRANSPORT_WS_PROTOCOL

Const GRAPHQL_TRANSPORT_WS_PROTOCOL: "graphql-transport-ws"

The WebSocket sub-protocol used for the GraphQL over WebSocket Protocol.

Defined in

src/common.ts:15


isMessage

isMessage(val): val is ConnectionInitMessage | ConnectionAckMessage | PingMessage | PongMessage | SubscribeMessage | NextMessage | ErrorMessage | CompleteMessage

Checks if the provided value is a valid GraphQL over WebSocket message.

Deprecated

Use validateMessage instead.

Parameters

NameType
valunknown

Returns

val is ConnectionInitMessage | ConnectionAckMessage | PingMessage | PongMessage | SubscribeMessage | NextMessage | ErrorMessage | CompleteMessage

Defined in

src/common.ts:403


parseMessage

parseMessage(data, reviver?): Message

Parses the raw websocket message data to a valid message.

Parameters

NameType
dataunknown
reviver?JSONMessageReviver

Returns

Message

Defined in

src/common.ts:428


stringifyMessage

stringifyMessage<T>(msg, replacer?): string

Stringifies a valid message ready to be sent through the socket.

Type parameters

NameType
Textends MessageType

Parameters

NameType
msgMessage<T>
replacer?JSONMessageReplacer

Returns

string

Defined in

src/common.ts:453


validateMessage

validateMessage(val): Message

Validates the message against the GraphQL over WebSocket Protocol.

Invalid messages will throw descriptive errors.

Parameters

NameType
valunknown

Returns

Message

Defined in

src/common.ts:208