src/index.js
/**
 * Transmit a GraphQL operation message over a WebSocket.
 * @param {object} webSocket - WebSocket connection
 * @param {object} message - GraphQL operation message
 * @throws {TypeError} Throws a type error if the provided message is not a valid client-side operation message.
 * @throws {Error} Throws an error if the provided message cannot be serialized to JSON.
 * @throws {TypeError} Throws a type error if the provided WebSocket connection is not open.
 */
Transmit a GraphQL operation message over a WebSocket.
@param {object} webSocket - WebSocket connection
@param {object} message - GraphQL operation message
@throws {TypeError} Throws a type error if the provided message is not a valid client-side operation message.
@throws {Error} Throws an error if the provided message cannot be serialized to JSON.
@throws {TypeError} Throws a type error if the provided WebSocket connection is not open.
Transmit a GraphQL operation message over a WebSocket . @param { object } webSocket - WebSocket connection @param { object } message - GraphQL operation message @throws { TypeError } Throws a type error if the provided message is not a valid client - side operation message . @throws { Error } Throws an error if the provided message cannot be serialized to JSON . @throws { TypeError } Throws a type error if the provided WebSocket connection is not open .
function send(webSocket, message) {
    if (!(message instanceof(OperationMessageFromClient))) {
        throw TypeError("Invalid message");
    }
    try {
        var serialized = JSON.stringify(message, null, 0);
    } catch (e) {
        throw Error("Unable to serialize message");
    }
    ensureOpen(webSocket).send(serialized);
}
function send ( webSocket , message ) { if ( ! ( message instanceof ( OperationMessageFromClient ) ) ) { throw TypeError ( "Invalid message" ) ; } try { var serialized = JSON . stringify ( message , null , 0 ) ; } catch ( e ) { throw Error ( "Unable to serialize message" ) ; } ensureOpen ( webSocket ) . send ( serialized ) ; }
Transmit a GraphQL operation message over a WebSocket.
Transmit a GraphQL operation message over a WebSocket .