@graphql-tools/executor-legacy-ws
Advanced tools
Comparing version 1.0.0 to 1.0.1-rc-20230612101309-a46efd88
"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, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12753
261
2