Methods
ensureOpen(webSocket) → {object}
Validate WebSocket connection state
Parameters:
Name | Type | Description |
---|---|---|
webSocket |
object | WebSocket connection |
Throws:
-
-
Throws an error if the websocket connection is not open.
- Type
- Error
-
-
-
Throws a type error if the state of the websocket is undefined or unknown.
- Type
- TypeError
-
Returns:
- WebSocket
- Type
- object
receive(message) → {ConnectionErrorMessage|ConnectionAckMessage|DataMessage|ErrorMessage|CompleteMessage}
Derive a server-side GraphQL operation message from an object.
Parameters:
Name | Type | Description |
---|---|---|
message |
object | Message received from server |
Throws:
-
Throws a type error if the provided message is of an unknown type.
- Type
- TypeError
Returns:
GraphQL operation message
send(webSocket, message)
Transmit a GraphQL operation message over a WebSocket.
Parameters:
Name | Type | Description |
---|---|---|
webSocket |
object | WebSocket connection |
message |
object | GraphQL operation message |
Throws:
-
-
Throws a type error if the provided message is not a valid client-side operation message.
- Type
- TypeError
-
-
-
Throws an error if the provided message cannot be serialized to JSON.
- Type
- Error
-
-
-
Throws a type error if the provided WebSocket connection is not open.
- Type
- TypeError
-