@graphql-tools/executor-http 3.5.0 → 3.5.1-rc-f7596fdf71c1b2144a3964ad3a79c6aeadf3d1d4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/index.cjs +14 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +14 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @graphql-tools/executor-http
|
|
2
2
|
|
|
3
|
+
## 3.5.1-rc-f7596fdf71c1b2144a3964ad3a79c6aeadf3d1d4
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [`4a2d3b6`](https://github.com/graphql-hive/gateway/commit/4a2d3b6a4e34cbe984ce7e36fd3306d907fb29d1) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Deduplicate inflight requests only within the same executor and the same `context`
|
|
9
|
+
|
|
10
|
+
The `fetch` implementation receives the request `context` and may handle each request differently, so identical requests with different contexts or from different executors are no longer deduplicated together.
|
|
11
|
+
|
|
3
12
|
## 3.5.0
|
|
4
13
|
### Minor Changes
|
|
5
14
|
|
package/dist/index.cjs
CHANGED
|
@@ -550,9 +550,10 @@ function prepareGETUrl({
|
|
|
550
550
|
return finalUrl;
|
|
551
551
|
}
|
|
552
552
|
|
|
553
|
-
const inflightRequests = /* @__PURE__ */ new Map();
|
|
554
553
|
function buildHTTPExecutor(options) {
|
|
555
554
|
const printFn = options?.print ?? executorCommon.defaultPrintFn;
|
|
555
|
+
const inflightRequestsByContext = /* @__PURE__ */ new WeakMap();
|
|
556
|
+
const inflightRequestsWithoutContext = /* @__PURE__ */ new Map();
|
|
556
557
|
let disposeCtrl;
|
|
557
558
|
const baseExecutor = (request, excludeQuery) => {
|
|
558
559
|
if (!request.context?.request?.cf) {
|
|
@@ -839,6 +840,18 @@ function buildHTTPExecutor(options) {
|
|
|
839
840
|
if (typeof inflightRequestOptions.body === "object") {
|
|
840
841
|
return runInflightRequest();
|
|
841
842
|
}
|
|
843
|
+
let inflightRequests = inflightRequestsWithoutContext;
|
|
844
|
+
if (context != null) {
|
|
845
|
+
if (Object(context) !== context) {
|
|
846
|
+
return runInflightRequest();
|
|
847
|
+
}
|
|
848
|
+
let contextInflightRequests = inflightRequestsByContext.get(context);
|
|
849
|
+
if (!contextInflightRequests) {
|
|
850
|
+
contextInflightRequests = /* @__PURE__ */ new Map();
|
|
851
|
+
inflightRequestsByContext.set(context, contextInflightRequests);
|
|
852
|
+
}
|
|
853
|
+
inflightRequests = contextInflightRequests;
|
|
854
|
+
}
|
|
842
855
|
let inflightRequestId = `${inflightRequestOptions.url}|${inflightRequestOptions.method}`;
|
|
843
856
|
if (inflightRequestOptions.body) {
|
|
844
857
|
inflightRequestId += `|${inflightRequestOptions.body}`;
|
package/dist/index.d.cts
CHANGED
|
@@ -101,6 +101,11 @@ interface HTTPExecutorOptions {
|
|
|
101
101
|
* Whether to deduplicate inflight requests with the same parameters.
|
|
102
102
|
* This can be useful to avoid making multiple identical requests to the upstream service when
|
|
103
103
|
* multiple parts of the gateway are requesting the same data at the same time.
|
|
104
|
+
*
|
|
105
|
+
* Requests are deduplicated only within the same executor and the same `context` object,
|
|
106
|
+
* because the `fetch` implementation receives the `context` and may handle each request
|
|
107
|
+
* differently.
|
|
108
|
+
*
|
|
104
109
|
* @default true
|
|
105
110
|
*/
|
|
106
111
|
deduplicateInflightRequests?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -101,6 +101,11 @@ interface HTTPExecutorOptions {
|
|
|
101
101
|
* Whether to deduplicate inflight requests with the same parameters.
|
|
102
102
|
* This can be useful to avoid making multiple identical requests to the upstream service when
|
|
103
103
|
* multiple parts of the gateway are requesting the same data at the same time.
|
|
104
|
+
*
|
|
105
|
+
* Requests are deduplicated only within the same executor and the same `context` object,
|
|
106
|
+
* because the `fetch` implementation receives the `context` and may handle each request
|
|
107
|
+
* differently.
|
|
108
|
+
*
|
|
104
109
|
* @default true
|
|
105
110
|
*/
|
|
106
111
|
deduplicateInflightRequests?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -548,9 +548,10 @@ function prepareGETUrl({
|
|
|
548
548
|
return finalUrl;
|
|
549
549
|
}
|
|
550
550
|
|
|
551
|
-
const inflightRequests = /* @__PURE__ */ new Map();
|
|
552
551
|
function buildHTTPExecutor(options) {
|
|
553
552
|
const printFn = options?.print ?? defaultPrintFn;
|
|
553
|
+
const inflightRequestsByContext = /* @__PURE__ */ new WeakMap();
|
|
554
|
+
const inflightRequestsWithoutContext = /* @__PURE__ */ new Map();
|
|
554
555
|
let disposeCtrl;
|
|
555
556
|
const baseExecutor = (request, excludeQuery) => {
|
|
556
557
|
if (!request.context?.request?.cf) {
|
|
@@ -837,6 +838,18 @@ function buildHTTPExecutor(options) {
|
|
|
837
838
|
if (typeof inflightRequestOptions.body === "object") {
|
|
838
839
|
return runInflightRequest();
|
|
839
840
|
}
|
|
841
|
+
let inflightRequests = inflightRequestsWithoutContext;
|
|
842
|
+
if (context != null) {
|
|
843
|
+
if (Object(context) !== context) {
|
|
844
|
+
return runInflightRequest();
|
|
845
|
+
}
|
|
846
|
+
let contextInflightRequests = inflightRequestsByContext.get(context);
|
|
847
|
+
if (!contextInflightRequests) {
|
|
848
|
+
contextInflightRequests = /* @__PURE__ */ new Map();
|
|
849
|
+
inflightRequestsByContext.set(context, contextInflightRequests);
|
|
850
|
+
}
|
|
851
|
+
inflightRequests = contextInflightRequests;
|
|
852
|
+
}
|
|
840
853
|
let inflightRequestId = `${inflightRequestOptions.url}|${inflightRequestOptions.method}`;
|
|
841
854
|
if (inflightRequestOptions.body) {
|
|
842
855
|
inflightRequestId += `|${inflightRequestOptions.body}`;
|
package/package.json
CHANGED