Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@graphql-tools/executor-legacy-ws

Package Overview
Dependencies
Maintainers
3
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/executor-legacy-ws - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1-rc-20230612101309-a46efd88

20

cjs/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildWSLegacyExecutor = exports.LEGACY_WS = void 0;
const tslib_1 = require("tslib");
const utils_1 = require("@graphql-tools/utils");
const graphql_1 = require("graphql");
const isomorphic_ws_1 = tslib_1.__importDefault(require("isomorphic-ws"));
var LEGACY_WS;

@@ -18,5 +20,4 @@ (function (LEGACY_WS) {

LEGACY_WS["COMPLETE"] = "complete";
})(LEGACY_WS = exports.LEGACY_WS || (exports.LEGACY_WS = {}));
})(LEGACY_WS || (exports.LEGACY_WS = LEGACY_WS = {}));
function buildWSLegacyExecutor(subscriptionsEndpoint, WebSocketImpl, options) {
const observerById = new Map();
let websocket = null;

@@ -45,5 +46,8 @@ const ensureWebsocket = () => {

};
websocket.onclose = () => {
websocket = null;
};
};
const cleanupWebsocket = () => {
if (websocket != null && observerById.size === 0) {
if (websocket != null) {
websocket.send(JSON.stringify({

@@ -108,6 +112,8 @@ type: LEGACY_WS.CONNECTION_TERMINATE,

unsubscribe: () => {
websocket?.send(JSON.stringify({
type: LEGACY_WS.STOP,
id,
}));
if (websocket?.readyState === isomorphic_ws_1.default.OPEN) {
websocket?.send(JSON.stringify({
type: LEGACY_WS.STOP,
id,
}));
}
cleanupWebsocket();

@@ -114,0 +120,0 @@ },

import { observableToAsyncIterable } from '@graphql-tools/utils';
import { print } from 'graphql';
import WebSocket from 'isomorphic-ws';
export var LEGACY_WS;

@@ -17,3 +18,2 @@ (function (LEGACY_WS) {

export function buildWSLegacyExecutor(subscriptionsEndpoint, WebSocketImpl, options) {
const observerById = new Map();
let websocket = null;

@@ -42,5 +42,8 @@ const ensureWebsocket = () => {

};
websocket.onclose = () => {
websocket = null;
};
};
const cleanupWebsocket = () => {
if (websocket != null && observerById.size === 0) {
if (websocket != null) {
websocket.send(JSON.stringify({

@@ -105,6 +108,8 @@ type: LEGACY_WS.CONNECTION_TERMINATE,

unsubscribe: () => {
websocket?.send(JSON.stringify({
type: LEGACY_WS.STOP,
id,
}));
if (websocket?.readyState === WebSocket.OPEN) {
websocket?.send(JSON.stringify({
type: LEGACY_WS.STOP,
id,
}));
}
cleanupWebsocket();

@@ -111,0 +116,0 @@ },

{
"name": "@graphql-tools/executor-legacy-ws",
"version": "1.0.0",
"version": "1.0.1-rc-20230612101309-a46efd88",
"description": "A set of utils for faster development of GraphQL tools",

@@ -5,0 +5,0 @@ "sideEffects": false,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc