@graphql-mesh/utils 0.103.19 → 0.103.20
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/in-context-sdk.js +8 -14
- package/cjs/iterateAsync.js +5 -2
- package/cjs/load-from-module-export-expression.js +3 -2
- package/cjs/wrapFetchWithHooks.js +4 -8
- package/esm/in-context-sdk.js +9 -15
- package/esm/iterateAsync.js +5 -2
- package/esm/load-from-module-export-expression.js +4 -3
- package/esm/wrapFetchWithHooks.js +4 -8
- package/package.json +3 -2
package/cjs/in-context-sdk.js
CHANGED
|
@@ -7,6 +7,7 @@ const batch_delegate_1 = require("@graphql-tools/batch-delegate");
|
|
|
7
7
|
const delegate_1 = require("@graphql-tools/delegate");
|
|
8
8
|
const utils_1 = require("@graphql-tools/utils");
|
|
9
9
|
const wrap_1 = require("@graphql-tools/wrap");
|
|
10
|
+
const promise_helpers_1 = require("@whatwg-node/promise-helpers");
|
|
10
11
|
const iterateAsync_js_1 = require("./iterateAsync.js");
|
|
11
12
|
const parseAndPrintWithCache_js_1 = require("./parseAndPrintWithCache.js");
|
|
12
13
|
exports.MESH_API_CONTEXT_SYMBOL = Symbol('isMeshAPIContext');
|
|
@@ -156,9 +157,8 @@ function getInContextSDK(unifiedSchema, rawSources, logger, onDelegateHooks) {
|
|
|
156
157
|
typeName: rootType.name,
|
|
157
158
|
fieldName,
|
|
158
159
|
};
|
|
159
|
-
const onDelegateResult$ = (0, iterateAsync_js_1.iterateAsync)(onDelegateHooks, onDelegateHook => onDelegateHook(onDelegatePayload), onDelegateHookDones);
|
|
160
160
|
fixInfo(batchDelegationOptions.info, operationType);
|
|
161
|
-
return (0,
|
|
161
|
+
return (0, promise_helpers_1.handleMaybePromise)(() => (0, iterateAsync_js_1.iterateAsync)(onDelegateHooks, onDelegateHook => onDelegateHook(onDelegatePayload), onDelegateHookDones), () => handleIterationResult(batch_delegate_1.batchDelegateToSchema, batchDelegationOptions, onDelegateHookDones));
|
|
162
162
|
}
|
|
163
163
|
else {
|
|
164
164
|
const regularDelegateOptions = {
|
|
@@ -178,9 +178,8 @@ function getInContextSDK(unifiedSchema, rawSources, logger, onDelegateHooks) {
|
|
|
178
178
|
typeName: rootType.name,
|
|
179
179
|
fieldName,
|
|
180
180
|
};
|
|
181
|
-
const onDelegateResult$ = (0, iterateAsync_js_1.iterateAsync)(onDelegateHooks, onDelegateHook => onDelegateHook(onDelegatePayload), onDelegateHookDones);
|
|
182
181
|
fixInfo(regularDelegateOptions.info, operationType);
|
|
183
|
-
return (0,
|
|
182
|
+
return (0, promise_helpers_1.handleMaybePromise)(() => (0, iterateAsync_js_1.iterateAsync)(onDelegateHooks, onDelegateHook => onDelegateHook(onDelegatePayload), onDelegateHookDones), () => handleIterationResult(delegate_1.delegateToSchema, regularDelegateOptions, onDelegateHookDones));
|
|
184
183
|
}
|
|
185
184
|
};
|
|
186
185
|
}
|
|
@@ -224,17 +223,12 @@ function identical(val) {
|
|
|
224
223
|
return val;
|
|
225
224
|
}
|
|
226
225
|
function handleIterationResult(delegateFn, delegateOptions, onDelegateHookDones) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
226
|
+
return (0, promise_helpers_1.handleMaybePromise)(() => delegateFn(delegateOptions), delegationResult => (0, promise_helpers_1.handleMaybePromise)(() => (0, iterateAsync_js_1.iterateAsync)(onDelegateHookDones, onDelegateHookDone => onDelegateHookDone({
|
|
227
|
+
result: delegationResult,
|
|
228
|
+
setResult(newResult) {
|
|
230
229
|
delegationResult = newResult;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
result: delegationResult,
|
|
234
|
-
setResult,
|
|
235
|
-
}));
|
|
236
|
-
return (0, utils_1.mapMaybePromise)(onDelegateDoneResult$, () => delegationResult);
|
|
237
|
-
});
|
|
230
|
+
},
|
|
231
|
+
})), () => delegationResult));
|
|
238
232
|
}
|
|
239
233
|
function fixInfo(info, operationType) {
|
|
240
234
|
info.operation ||= {
|
package/cjs/iterateAsync.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.iterateAsync = iterateAsync;
|
|
4
|
-
const
|
|
4
|
+
const promise_helpers_1 = require("@whatwg-node/promise-helpers");
|
|
5
5
|
function iterateAsync(iterable, callback, results) {
|
|
6
|
+
if (iterable?.length === 0) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
6
9
|
const iterator = iterable[Symbol.iterator]();
|
|
7
10
|
function iterate() {
|
|
8
11
|
const { done: endOfIterator, value } = iterator.next();
|
|
@@ -13,7 +16,7 @@ function iterateAsync(iterable, callback, results) {
|
|
|
13
16
|
function endEarly() {
|
|
14
17
|
endedEarly = true;
|
|
15
18
|
}
|
|
16
|
-
return (0,
|
|
19
|
+
return (0, promise_helpers_1.handleMaybePromise)(() => callback(value, endEarly), result => {
|
|
17
20
|
if (endedEarly) {
|
|
18
21
|
return;
|
|
19
22
|
}
|
|
@@ -4,6 +4,7 @@ exports.loadFromModuleExportExpression = loadFromModuleExportExpression;
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/return-await */
|
|
5
5
|
const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
|
|
6
6
|
const utils_1 = require("@graphql-tools/utils");
|
|
7
|
+
const promise_helpers_1 = require("@whatwg-node/promise-helpers");
|
|
7
8
|
const defaultImportFn_js_1 = require("./defaultImportFn.js");
|
|
8
9
|
function loadFromModuleExportExpression(expression, options) {
|
|
9
10
|
if (typeof expression !== 'string') {
|
|
@@ -11,10 +12,10 @@ function loadFromModuleExportExpression(expression, options) {
|
|
|
11
12
|
}
|
|
12
13
|
const { defaultExportName, cwd, importFn = defaultImportFn_js_1.defaultImportFn } = options || {};
|
|
13
14
|
const [modulePath, exportName = defaultExportName] = expression.split('#');
|
|
14
|
-
return (0,
|
|
15
|
+
return (0, promise_helpers_1.handleMaybePromise)(() => tryImport(modulePath, cwd, importFn), mod => mod[exportName] || (mod.default && mod.default[exportName]) || mod.default || mod);
|
|
15
16
|
}
|
|
16
17
|
function tryImport(modulePath, cwd, importFn) {
|
|
17
|
-
return (0,
|
|
18
|
+
return (0, promise_helpers_1.handleMaybePromise)(() => importFn(modulePath), m => m, () => {
|
|
18
19
|
if (!cross_helpers_1.path.isAbsolute(modulePath)) {
|
|
19
20
|
const absoluteModulePath = cross_helpers_1.path.isAbsolute(modulePath)
|
|
20
21
|
? modulePath
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loggerForExecutionRequest = exports.requestIdByRequest = void 0;
|
|
4
4
|
exports.wrapFetchWithHooks = wrapFetchWithHooks;
|
|
5
|
-
const
|
|
5
|
+
const promise_helpers_1 = require("@whatwg-node/promise-helpers");
|
|
6
6
|
const iterateAsync_js_1 = require("./iterateAsync.js");
|
|
7
7
|
const logger_js_1 = require("./logger.js");
|
|
8
8
|
exports.requestIdByRequest = new WeakMap();
|
|
@@ -12,7 +12,7 @@ function wrapFetchWithHooks(onFetchHooks) {
|
|
|
12
12
|
let fetchFn;
|
|
13
13
|
let response$;
|
|
14
14
|
const onFetchDoneHooks = [];
|
|
15
|
-
return (0,
|
|
15
|
+
return (0, promise_helpers_1.handleMaybePromise)(() => (0, iterateAsync_js_1.iterateAsync)(onFetchHooks, (onFetch, endEarly) => onFetch({
|
|
16
16
|
fetchFn,
|
|
17
17
|
setFetchFn(newFetchFn) {
|
|
18
18
|
fetchFn = newFetchFn;
|
|
@@ -62,12 +62,8 @@ function wrapFetchWithHooks(onFetchHooks) {
|
|
|
62
62
|
if (response$) {
|
|
63
63
|
return response$;
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return response$;
|
|
68
|
-
}
|
|
69
|
-
return (0, utils_1.mapMaybePromise)(response$, function (response) {
|
|
70
|
-
return (0, utils_1.mapMaybePromise)((0, iterateAsync_js_1.iterateAsync)(onFetchDoneHooks, onFetchDone => onFetchDone({
|
|
65
|
+
return (0, promise_helpers_1.handleMaybePromise)(() => fetchFn(url, options, context, info), function (response) {
|
|
66
|
+
return (0, promise_helpers_1.handleMaybePromise)(() => (0, iterateAsync_js_1.iterateAsync)(onFetchDoneHooks, onFetchDone => onFetchDone({
|
|
71
67
|
response,
|
|
72
68
|
setResponse(newResponse) {
|
|
73
69
|
response = newResponse;
|
package/esm/in-context-sdk.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { getNamedType, isLeafType, Kind, print } from 'graphql';
|
|
2
2
|
import { batchDelegateToSchema } from '@graphql-tools/batch-delegate';
|
|
3
3
|
import { applySchemaTransforms, delegateToSchema } from '@graphql-tools/delegate';
|
|
4
|
-
import { buildOperationNodeForField, isDocumentNode,
|
|
4
|
+
import { buildOperationNodeForField, isDocumentNode, memoize1 } from '@graphql-tools/utils';
|
|
5
5
|
import { WrapQuery } from '@graphql-tools/wrap';
|
|
6
|
+
import { handleMaybePromise } from '@whatwg-node/promise-helpers';
|
|
6
7
|
import { iterateAsync } from './iterateAsync.js';
|
|
7
8
|
import { parseWithCache } from './parseAndPrintWithCache.js';
|
|
8
9
|
export const MESH_API_CONTEXT_SYMBOL = Symbol('isMeshAPIContext');
|
|
@@ -152,9 +153,8 @@ export function getInContextSDK(unifiedSchema, rawSources, logger, onDelegateHoo
|
|
|
152
153
|
typeName: rootType.name,
|
|
153
154
|
fieldName,
|
|
154
155
|
};
|
|
155
|
-
const onDelegateResult$ = iterateAsync(onDelegateHooks, onDelegateHook => onDelegateHook(onDelegatePayload), onDelegateHookDones);
|
|
156
156
|
fixInfo(batchDelegationOptions.info, operationType);
|
|
157
|
-
return
|
|
157
|
+
return handleMaybePromise(() => iterateAsync(onDelegateHooks, onDelegateHook => onDelegateHook(onDelegatePayload), onDelegateHookDones), () => handleIterationResult(batchDelegateToSchema, batchDelegationOptions, onDelegateHookDones));
|
|
158
158
|
}
|
|
159
159
|
else {
|
|
160
160
|
const regularDelegateOptions = {
|
|
@@ -174,9 +174,8 @@ export function getInContextSDK(unifiedSchema, rawSources, logger, onDelegateHoo
|
|
|
174
174
|
typeName: rootType.name,
|
|
175
175
|
fieldName,
|
|
176
176
|
};
|
|
177
|
-
const onDelegateResult$ = iterateAsync(onDelegateHooks, onDelegateHook => onDelegateHook(onDelegatePayload), onDelegateHookDones);
|
|
178
177
|
fixInfo(regularDelegateOptions.info, operationType);
|
|
179
|
-
return
|
|
178
|
+
return handleMaybePromise(() => iterateAsync(onDelegateHooks, onDelegateHook => onDelegateHook(onDelegatePayload), onDelegateHookDones), () => handleIterationResult(delegateToSchema, regularDelegateOptions, onDelegateHookDones));
|
|
180
179
|
}
|
|
181
180
|
};
|
|
182
181
|
}
|
|
@@ -220,17 +219,12 @@ function identical(val) {
|
|
|
220
219
|
return val;
|
|
221
220
|
}
|
|
222
221
|
function handleIterationResult(delegateFn, delegateOptions, onDelegateHookDones) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
222
|
+
return handleMaybePromise(() => delegateFn(delegateOptions), delegationResult => handleMaybePromise(() => iterateAsync(onDelegateHookDones, onDelegateHookDone => onDelegateHookDone({
|
|
223
|
+
result: delegationResult,
|
|
224
|
+
setResult(newResult) {
|
|
226
225
|
delegationResult = newResult;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
result: delegationResult,
|
|
230
|
-
setResult,
|
|
231
|
-
}));
|
|
232
|
-
return mapMaybePromise(onDelegateDoneResult$, () => delegationResult);
|
|
233
|
-
});
|
|
226
|
+
},
|
|
227
|
+
})), () => delegationResult));
|
|
234
228
|
}
|
|
235
229
|
function fixInfo(info, operationType) {
|
|
236
230
|
info.operation ||= {
|
package/esm/iterateAsync.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { handleMaybePromise } from '@whatwg-node/promise-helpers';
|
|
2
2
|
export function iterateAsync(iterable, callback, results) {
|
|
3
|
+
if (iterable?.length === 0) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
3
6
|
const iterator = iterable[Symbol.iterator]();
|
|
4
7
|
function iterate() {
|
|
5
8
|
const { done: endOfIterator, value } = iterator.next();
|
|
@@ -10,7 +13,7 @@ export function iterateAsync(iterable, callback, results) {
|
|
|
10
13
|
function endEarly() {
|
|
11
14
|
endedEarly = true;
|
|
12
15
|
}
|
|
13
|
-
return
|
|
16
|
+
return handleMaybePromise(() => callback(value, endEarly), result => {
|
|
14
17
|
if (endedEarly) {
|
|
15
18
|
return;
|
|
16
19
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/return-await */
|
|
2
2
|
import { path } from '@graphql-mesh/cross-helpers';
|
|
3
|
-
import { fakePromise
|
|
3
|
+
import { fakePromise } from '@graphql-tools/utils';
|
|
4
|
+
import { handleMaybePromise } from '@whatwg-node/promise-helpers';
|
|
4
5
|
import { defaultImportFn } from './defaultImportFn.js';
|
|
5
6
|
export function loadFromModuleExportExpression(expression, options) {
|
|
6
7
|
if (typeof expression !== 'string') {
|
|
@@ -8,10 +9,10 @@ export function loadFromModuleExportExpression(expression, options) {
|
|
|
8
9
|
}
|
|
9
10
|
const { defaultExportName, cwd, importFn = defaultImportFn } = options || {};
|
|
10
11
|
const [modulePath, exportName = defaultExportName] = expression.split('#');
|
|
11
|
-
return
|
|
12
|
+
return handleMaybePromise(() => tryImport(modulePath, cwd, importFn), mod => mod[exportName] || (mod.default && mod.default[exportName]) || mod.default || mod);
|
|
12
13
|
}
|
|
13
14
|
function tryImport(modulePath, cwd, importFn) {
|
|
14
|
-
return
|
|
15
|
+
return handleMaybePromise(() => importFn(modulePath), m => m, () => {
|
|
15
16
|
if (!path.isAbsolute(modulePath)) {
|
|
16
17
|
const absoluteModulePath = path.isAbsolute(modulePath)
|
|
17
18
|
? modulePath
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { handleMaybePromise } from '@whatwg-node/promise-helpers';
|
|
2
2
|
import { iterateAsync } from './iterateAsync.js';
|
|
3
3
|
import { DefaultLogger } from './logger.js';
|
|
4
4
|
export const requestIdByRequest = new WeakMap();
|
|
@@ -8,7 +8,7 @@ export function wrapFetchWithHooks(onFetchHooks) {
|
|
|
8
8
|
let fetchFn;
|
|
9
9
|
let response$;
|
|
10
10
|
const onFetchDoneHooks = [];
|
|
11
|
-
return
|
|
11
|
+
return handleMaybePromise(() => iterateAsync(onFetchHooks, (onFetch, endEarly) => onFetch({
|
|
12
12
|
fetchFn,
|
|
13
13
|
setFetchFn(newFetchFn) {
|
|
14
14
|
fetchFn = newFetchFn;
|
|
@@ -58,12 +58,8 @@ export function wrapFetchWithHooks(onFetchHooks) {
|
|
|
58
58
|
if (response$) {
|
|
59
59
|
return response$;
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return response$;
|
|
64
|
-
}
|
|
65
|
-
return mapMaybePromise(response$, function (response) {
|
|
66
|
-
return mapMaybePromise(iterateAsync(onFetchDoneHooks, onFetchDone => onFetchDone({
|
|
61
|
+
return handleMaybePromise(() => fetchFn(url, options, context, info), function (response) {
|
|
62
|
+
return handleMaybePromise(() => iterateAsync(onFetchDoneHooks, onFetchDone => onFetchDone({
|
|
67
63
|
response,
|
|
68
64
|
setResponse(newResponse) {
|
|
69
65
|
response = newResponse;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/utils",
|
|
3
|
-
"version": "0.103.
|
|
3
|
+
"version": "0.103.20",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "*"
|
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@graphql-mesh/cross-helpers": "^0.4.10",
|
|
10
10
|
"@graphql-mesh/string-interpolation": "^0.5.8",
|
|
11
|
-
"@graphql-mesh/types": "^0.103.
|
|
11
|
+
"@graphql-mesh/types": "^0.103.20",
|
|
12
12
|
"@graphql-tools/batch-delegate": "^9.0.16",
|
|
13
13
|
"@graphql-tools/delegate": "^10.0.28",
|
|
14
14
|
"@graphql-tools/utils": "^10.8.0",
|
|
15
15
|
"@graphql-tools/wrap": "^10.0.28",
|
|
16
16
|
"@whatwg-node/disposablestack": "^0.0.5",
|
|
17
17
|
"@whatwg-node/fetch": "^0.10.4",
|
|
18
|
+
"@whatwg-node/promise-helpers": "^1.0.0",
|
|
18
19
|
"dset": "^3.1.2",
|
|
19
20
|
"js-yaml": "^4.1.0",
|
|
20
21
|
"lodash.get": "^4.4.2",
|