How to use the subscriptions-transport-ws/dist/message-types.GQL_CONNECTION_ERROR function in subscriptions-transport-ws

To help you get started, we’ve selected a few subscriptions-transport-ws examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qmit-pro / moleculer-api / src / schema / plugin / protocol / graphql / handler / subscription.ts View on Github external
const connectionClosedHandler = (error: any) => {
        if (error) {
          this.sendError(
            connectionContext,
            "",
            {message: error.message ? error.message : error},
            MessageTypes.GQL_CONNECTION_ERROR,
          );

          setTimeout(() => {
            // 1011 is an unexpected condition prevented the request from being fulfilled
            connectionContext.socket.close(1011);
          }, 10);
        }
        this.onClose(connectionContext);

        if (this.onDisconnect) {
          this.onDisconnect(socket, connectionContext);
        }
      };