@graphql-tools/executor-legacy-ws
Advanced tools
Comparing version 1.0.1 to 1.0.2-alpha-20230906162118-0d524f64
@@ -5,5 +5,5 @@ "use strict"; | ||
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")); | ||
const utils_1 = require("@graphql-tools/utils"); | ||
var LEGACY_WS; | ||
@@ -23,2 +23,3 @@ (function (LEGACY_WS) { | ||
function buildWSLegacyExecutor(subscriptionsEndpoint, WebSocketImpl, options) { | ||
let executorConnectionParams = {}; | ||
let websocket = null; | ||
@@ -43,2 +44,3 @@ const ensureWebsocket = (errorHandler = err => console.error(err)) => { | ||
} | ||
payload = Object.assign(payload, executorConnectionParams); | ||
websocket.send(JSON.stringify({ | ||
@@ -71,2 +73,8 @@ type: LEGACY_WS.CONNECTION_INIT, | ||
return function legacyExecutor(request) { | ||
// additional connection params can be supplied through the "connectionParams" field in extensions. | ||
// TODO: connection params only from the FIRST operation in lazy mode will be used (detect connectionParams changes and reconnect, too implicit?) | ||
if (request.extensions?.['connectionParams'] && | ||
typeof request.extensions?.['connectionParams'] === 'object') { | ||
executorConnectionParams = Object.assign(executorConnectionParams, request.extensions['connectionParams']); | ||
} | ||
const id = Date.now().toString(); | ||
@@ -73,0 +81,0 @@ return (0, utils_1.observableToAsyncIterable)({ |
@@ -1,4 +0,4 @@ | ||
import { observableToAsyncIterable } from '@graphql-tools/utils'; | ||
import { print } from 'graphql'; | ||
import WebSocket from 'isomorphic-ws'; | ||
import { observableToAsyncIterable } from '@graphql-tools/utils'; | ||
export var LEGACY_WS; | ||
@@ -18,2 +18,3 @@ (function (LEGACY_WS) { | ||
export function buildWSLegacyExecutor(subscriptionsEndpoint, WebSocketImpl, options) { | ||
let executorConnectionParams = {}; | ||
let websocket = null; | ||
@@ -38,2 +39,3 @@ const ensureWebsocket = (errorHandler = err => console.error(err)) => { | ||
} | ||
payload = Object.assign(payload, executorConnectionParams); | ||
websocket.send(JSON.stringify({ | ||
@@ -66,2 +68,8 @@ type: LEGACY_WS.CONNECTION_INIT, | ||
return function legacyExecutor(request) { | ||
// additional connection params can be supplied through the "connectionParams" field in extensions. | ||
// TODO: connection params only from the FIRST operation in lazy mode will be used (detect connectionParams changes and reconnect, too implicit?) | ||
if (request.extensions?.['connectionParams'] && | ||
typeof request.extensions?.['connectionParams'] === 'object') { | ||
executorConnectionParams = Object.assign(executorConnectionParams, request.extensions['connectionParams']); | ||
} | ||
const id = Date.now().toString(); | ||
@@ -68,0 +76,0 @@ return observableToAsyncIterable({ |
{ | ||
"name": "@graphql-tools/executor-legacy-ws", | ||
"version": "1.0.1", | ||
"version": "1.0.2-alpha-20230906162118-0d524f64", | ||
"description": "A set of utils for faster development of GraphQL tools", | ||
@@ -10,7 +10,7 @@ "sideEffects": false, | ||
"dependencies": { | ||
"@graphql-tools/utils": "^10.0.0", | ||
"@types/ws": "^8.0.0", | ||
"@graphql-tools/utils": "^10.0.0", | ||
"isomorphic-ws": "5.0.0", | ||
"ws": "8.13.0", | ||
"tslib": "^2.4.0" | ||
"tslib": "^2.4.0", | ||
"ws": "8.14.0" | ||
}, | ||
@@ -17,0 +17,0 @@ "repository": { |
/// <reference types="ws" /> | ||
import WebSocket from 'isomorphic-ws'; | ||
import { Executor } from '@graphql-tools/utils'; | ||
import WebSocket from 'isomorphic-ws'; | ||
export declare enum LEGACY_WS { | ||
@@ -17,5 +17,5 @@ CONNECTION_INIT = "connection_init", | ||
export interface LegacyWSExecutorOpts { | ||
connectionParams?: Record<string, any>; | ||
connectionParams?: Record<string, unknown> | (() => Record<string, unknown>); | ||
headers?: Record<string, any>; | ||
} | ||
export declare function buildWSLegacyExecutor(subscriptionsEndpoint: string, WebSocketImpl: typeof WebSocket, options?: LegacyWSExecutorOpts): Executor; |
Sorry, the diff of this file is not supported yet
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
15844
315
2