graphql-ws / common
- CompleteMessage
- ConnectionAckMessage
- ConnectionInitMessage
- Disposable
- ErrorMessage
- ExecutionPatchResult
- ExecutionResult
- NextMessage
- PingMessage
- PongMessage
- Sink
- SubscribeMessage
- SubscribePayload
Ƭ ID: string
ID is a string type alias representing the globally unique ID used for identifying subscriptions established by the client.
Ƭ JSONMessageReplacer: (this
: any
, key
: string
, value
: any
) => any
▸ (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
Name | Type |
---|---|
this |
any |
key |
string |
value |
any |
any
Ƭ JSONMessageReviver: (this
: any
, key
: string
, value
: any
) => any
▸ (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
Name | Type |
---|---|
this |
any |
key |
string |
value |
any |
any
Ƭ 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
Name | Type |
---|---|
T |
extends MessageType = MessageType |
• Const
GRAPHQL_TRANSPORT_WS_PROTOCOL: "graphql-transport-ws"
The WebSocket sub-protocol used for the GraphQL over WebSocket Protocol.
▸ 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.
Name | Type |
---|---|
val |
unknown |
val is ConnectionInitMessage | ConnectionAckMessage | PingMessage | PongMessage | SubscribeMessage | NextMessage | ErrorMessage | CompleteMessage
▸ parseMessage(data
, reviver?
): Message
Parses the raw websocket message data to a valid message.
Name | Type |
---|---|
data |
unknown |
reviver? |
JSONMessageReviver |
▸ stringifyMessage<T
>(msg
, replacer?
): string
Stringifies a valid message ready to be sent through the socket.
Name | Type |
---|---|
T |
extends MessageType |
Name | Type |
---|---|
msg |
Message <T > |
replacer? |
JSONMessageReplacer |
string
▸ validateMessage(val
): Message
Validates the message against the GraphQL over WebSocket Protocol.
Invalid messages will throw descriptive errors.
Name | Type |
---|---|
val |
unknown |