@graphql-mesh/plugin-operation-headers 1.3.20 → 1.3.21
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/cjs/index.js +9 -12
- package/esm/index.js +10 -13
- package/package.json +4 -3
package/cjs/index.js
CHANGED
|
@@ -2,24 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useOperationHeaders = useOperationHeaders;
|
|
4
4
|
const utils_1 = require("@graphql-mesh/utils");
|
|
5
|
+
const promise_helpers_1 = require("@whatwg-node/promise-helpers");
|
|
5
6
|
function useOperationHeaders(factoryFn) {
|
|
6
7
|
return {
|
|
7
8
|
onFetch({ url, options, context, setOptions }) {
|
|
8
|
-
|
|
9
|
-
const newHeaders$ = factoryFn({
|
|
9
|
+
return (0, promise_helpers_1.handleMaybePromise)(() => factoryFn({
|
|
10
10
|
url,
|
|
11
11
|
options,
|
|
12
12
|
context,
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
...options,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
});
|
|
13
|
+
}), newHeaders => setOptions({
|
|
14
|
+
...options,
|
|
15
|
+
headers: {
|
|
16
|
+
...(0, utils_1.getHeadersObj)(options.headers || {}),
|
|
17
|
+
...newHeaders,
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
23
20
|
},
|
|
24
21
|
};
|
|
25
22
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import { getHeadersObj
|
|
1
|
+
import { getHeadersObj } from '@graphql-mesh/utils';
|
|
2
|
+
import { handleMaybePromise } from '@whatwg-node/promise-helpers';
|
|
2
3
|
export function useOperationHeaders(factoryFn) {
|
|
3
4
|
return {
|
|
4
5
|
onFetch({ url, options, context, setOptions }) {
|
|
5
|
-
|
|
6
|
-
const newHeaders$ = factoryFn({
|
|
6
|
+
return handleMaybePromise(() => factoryFn({
|
|
7
7
|
url,
|
|
8
8
|
options,
|
|
9
9
|
context,
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
...options,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
});
|
|
10
|
+
}), newHeaders => setOptions({
|
|
11
|
+
...options,
|
|
12
|
+
headers: {
|
|
13
|
+
...getHeadersObj(options.headers || {}),
|
|
14
|
+
...newHeaders,
|
|
15
|
+
},
|
|
16
|
+
}));
|
|
20
17
|
},
|
|
21
18
|
};
|
|
22
19
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/plugin-operation-headers",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.21",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@graphql-hive/gateway-runtime": "^1.3.3",
|
|
10
|
-
"@graphql-mesh/types": "^0.103.
|
|
11
|
-
"@graphql-mesh/utils": "^0.103.
|
|
10
|
+
"@graphql-mesh/types": "^0.103.20",
|
|
11
|
+
"@graphql-mesh/utils": "^0.103.20",
|
|
12
|
+
"@whatwg-node/promise-helpers": "^1.0.0",
|
|
12
13
|
"tslib": "^2.4.0"
|
|
13
14
|
},
|
|
14
15
|
"repository": {
|