@graphql-tools/executor-http
Advanced tools
Comparing version 1.2.2 to 1.2.3-alpha-eeb5a1d4d585f1315b38da3d023b25283b3ac051
# @graphql-tools/executor-http | ||
## 1.2.3-alpha-eeb5a1d4d585f1315b38da3d023b25283b3ac051 | ||
### Patch Changes | ||
- [#376](https://github.com/graphql-hive/gateway/pull/376) [`eeb5a1d`](https://github.com/graphql-hive/gateway/commit/eeb5a1d4d585f1315b38da3d023b25283b3ac051) Thanks [@ardatan](https://github.com/ardatan)! - No need to handle event listeners inside HTTP Executor thanks to the improvements with `@graphql-tools/utils`'s `registerAbortSignalListener` to avoid Node.js warnings when multiple event listeners registered to an `AbortSignal` | ||
## 1.2.2 | ||
@@ -4,0 +10,0 @@ |
@@ -286,25 +286,8 @@ import { abortSignalAny } from '@graphql-hive/gateway-abort-signal-any'; | ||
function createSignalWrapper(signal) { | ||
const listeners = /* @__PURE__ */ new Set(); | ||
signal.onabort = (event) => { | ||
for (const listener of listeners) { | ||
listener(event); | ||
} | ||
}; | ||
return Object.assign(signal, { | ||
addEventListener(_type, listener) { | ||
listeners.add(listener); | ||
}, | ||
removeEventListener(_type, listener) { | ||
listeners.delete(listener); | ||
} | ||
}); | ||
} | ||
function buildHTTPExecutor(options) { | ||
const printFn = options?.print ?? defaultPrintFn; | ||
const disposeCtrl = new AbortController(); | ||
const sharedSignal = createSignalWrapper(disposeCtrl.signal); | ||
const baseExecutor = (request, excludeQuery) => { | ||
if (sharedSignal.aborted) { | ||
return createResultForAbort(sharedSignal.reason); | ||
if (disposeCtrl.signal.aborted) { | ||
return createResultForAbort(disposeCtrl.signal.reason); | ||
} | ||
@@ -338,3 +321,3 @@ const fetchFn = request.extensions?.fetch ?? options?.fetch ?? fetch; | ||
} | ||
const signals = [sharedSignal]; | ||
const signals = [disposeCtrl.signal]; | ||
const signalFromRequest = request.signal || request.info?.signal; | ||
@@ -350,3 +333,3 @@ if (signalFromRequest) { | ||
} | ||
const signal = abortSignalAny(signals); | ||
const signal = signals.length > 1 ? abortSignalAny(signals) : signals[0]; | ||
const upstreamErrorExtensions = { | ||
@@ -561,4 +544,4 @@ request: { | ||
function retryAttempt() { | ||
if (sharedSignal.aborted) { | ||
return createResultForAbort(sharedSignal.reason); | ||
if (disposeCtrl.signal.aborted) { | ||
return createResultForAbort(disposeCtrl.signal.reason); | ||
} | ||
@@ -565,0 +548,0 @@ attempt++; |
{ | ||
"name": "@graphql-tools/executor-http", | ||
"version": "1.2.2", | ||
"version": "1.2.3-alpha-eeb5a1d4d585f1315b38da3d023b25283b3ac051", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "A set of utils for faster development of GraphQL tools", |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
72925
1312
2