@graphql-tools/executor 1.3.6 → 1.3.7-alpha-20241209101052-b0932c49214ceb915e4bebbab82ae2fee9dfba47
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/execution/coerceError.js +1 -2
- package/cjs/execution/execute.js +19 -10
- package/cjs/execution/flattenAsyncIterable.js +9 -2
- package/cjs/execution/invariant.js +1 -2
- package/cjs/execution/normalizedExecutor.js +1 -2
- package/cjs/execution/promiseForObject.js +1 -2
- package/cjs/execution/values.js +1 -3
- package/esm/execution/execute.js +9 -0
- package/esm/execution/flattenAsyncIterable.js +8 -0
- package/esm/execution/values.js +0 -1
- package/package.json +3 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.coerceError =
|
|
3
|
+
exports.coerceError = coerceError;
|
|
4
4
|
function coerceError(error) {
|
|
5
5
|
if (error instanceof Error) {
|
|
6
6
|
return error;
|
|
@@ -23,4 +23,3 @@ function coerceError(error) {
|
|
|
23
23
|
}
|
|
24
24
|
return new Error(String(error));
|
|
25
25
|
}
|
|
26
|
-
exports.coerceError = coerceError;
|
package/cjs/execution/execute.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.defaultFieldResolver = exports.defaultTypeResolver = exports.CRITICAL_ERROR = exports.getFragmentsFromDocument = void 0;
|
|
4
|
+
exports.execute = execute;
|
|
5
|
+
exports.executeSync = executeSync;
|
|
6
|
+
exports.assertValidExecutionArguments = assertValidExecutionArguments;
|
|
7
|
+
exports.buildExecutionContext = buildExecutionContext;
|
|
8
|
+
exports.buildResolveInfo = buildResolveInfo;
|
|
9
|
+
exports.subscribe = subscribe;
|
|
10
|
+
exports.flattenIncrementalResults = flattenIncrementalResults;
|
|
11
|
+
exports.getFieldDef = getFieldDef;
|
|
12
|
+
exports.isIncrementalResult = isIncrementalResult;
|
|
4
13
|
const graphql_1 = require("graphql");
|
|
5
14
|
const value_or_promise_1 = require("value-or-promise");
|
|
6
15
|
const utils_1 = require("@graphql-tools/utils");
|
|
16
|
+
const disposablestack_1 = require("@whatwg-node/disposablestack");
|
|
7
17
|
const coerceError_js_1 = require("./coerceError.js");
|
|
8
18
|
const flattenAsyncIterable_js_1 = require("./flattenAsyncIterable.js");
|
|
9
19
|
const invariant_js_1 = require("./invariant.js");
|
|
@@ -50,7 +60,6 @@ function execute(args) {
|
|
|
50
60
|
}
|
|
51
61
|
return executeImpl(exeContext);
|
|
52
62
|
}
|
|
53
|
-
exports.execute = execute;
|
|
54
63
|
function executeImpl(exeContext) {
|
|
55
64
|
if (exeContext.signal?.aborted) {
|
|
56
65
|
throw exeContext.signal.reason;
|
|
@@ -107,7 +116,6 @@ function executeSync(args) {
|
|
|
107
116
|
}
|
|
108
117
|
return result;
|
|
109
118
|
}
|
|
110
|
-
exports.executeSync = executeSync;
|
|
111
119
|
/**
|
|
112
120
|
* Given a completed execution context and data, build the `{ errors, data }`
|
|
113
121
|
* response defined by the "Response" section of the GraphQL specification.
|
|
@@ -128,7 +136,6 @@ function assertValidExecutionArguments(schema, document, rawVariableValues) {
|
|
|
128
136
|
// Variables, if provided, must be an object.
|
|
129
137
|
console.assert(rawVariableValues == null || (0, utils_1.isObjectLike)(rawVariableValues), 'Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.');
|
|
130
138
|
}
|
|
131
|
-
exports.assertValidExecutionArguments = assertValidExecutionArguments;
|
|
132
139
|
exports.getFragmentsFromDocument = (0, utils_1.memoize1)(function getFragmentsFromDocument(document) {
|
|
133
140
|
const fragments = Object.create(null);
|
|
134
141
|
for (const definition of document.definitions) {
|
|
@@ -202,7 +209,6 @@ function buildExecutionContext(args) {
|
|
|
202
209
|
signal,
|
|
203
210
|
};
|
|
204
211
|
}
|
|
205
|
-
exports.buildExecutionContext = buildExecutionContext;
|
|
206
212
|
function buildPerEventExecutionContext(exeContext, payload) {
|
|
207
213
|
return {
|
|
208
214
|
...exeContext,
|
|
@@ -386,7 +392,6 @@ function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) {
|
|
|
386
392
|
variableValues: exeContext.variableValues,
|
|
387
393
|
};
|
|
388
394
|
}
|
|
389
|
-
exports.buildResolveInfo = buildResolveInfo;
|
|
390
395
|
exports.CRITICAL_ERROR = 'CRITICAL_ERROR';
|
|
391
396
|
function handleFieldError(error, returnType, errors) {
|
|
392
397
|
// If the field type is non-nullable, then it is resolved without any
|
|
@@ -824,7 +829,6 @@ function subscribe(args) {
|
|
|
824
829
|
}
|
|
825
830
|
return mapSourceToResponse(exeContext, resultOrStream);
|
|
826
831
|
}
|
|
827
|
-
exports.subscribe = subscribe;
|
|
828
832
|
function flattenIncrementalResults(incrementalResults) {
|
|
829
833
|
const subsequentIterator = incrementalResults.subsequentResults;
|
|
830
834
|
let initialResultSent = false;
|
|
@@ -854,9 +858,12 @@ function flattenIncrementalResults(incrementalResults) {
|
|
|
854
858
|
done = true;
|
|
855
859
|
return subsequentIterator.throw(error);
|
|
856
860
|
},
|
|
861
|
+
[disposablestack_1.DisposableSymbols.asyncDispose]() {
|
|
862
|
+
done = true;
|
|
863
|
+
return subsequentIterator?.[disposablestack_1.DisposableSymbols.asyncDispose]?.();
|
|
864
|
+
},
|
|
857
865
|
};
|
|
858
866
|
}
|
|
859
|
-
exports.flattenIncrementalResults = flattenIncrementalResults;
|
|
860
867
|
async function* ensureAsyncIterable(someExecutionResult) {
|
|
861
868
|
if ('initialResult' in someExecutionResult) {
|
|
862
869
|
yield* flattenIncrementalResults(someExecutionResult);
|
|
@@ -1235,6 +1242,10 @@ function yieldSubsequentPayloads(exeContext) {
|
|
|
1235
1242
|
isDone = true;
|
|
1236
1243
|
return Promise.reject(error);
|
|
1237
1244
|
},
|
|
1245
|
+
async [disposablestack_1.DisposableSymbols.asyncDispose]() {
|
|
1246
|
+
await returnStreamIterators();
|
|
1247
|
+
isDone = true;
|
|
1248
|
+
},
|
|
1238
1249
|
};
|
|
1239
1250
|
}
|
|
1240
1251
|
class DeferredFragmentRecord {
|
|
@@ -1349,8 +1360,6 @@ function getFieldDef(schema, parentType, fieldNode) {
|
|
|
1349
1360
|
}
|
|
1350
1361
|
return parentType.getFields()[fieldName];
|
|
1351
1362
|
}
|
|
1352
|
-
exports.getFieldDef = getFieldDef;
|
|
1353
1363
|
function isIncrementalResult(result) {
|
|
1354
1364
|
return 'incremental' in result;
|
|
1355
1365
|
}
|
|
1356
|
-
exports.isIncrementalResult = isIncrementalResult;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.flattenAsyncIterable =
|
|
3
|
+
exports.flattenAsyncIterable = flattenAsyncIterable;
|
|
4
|
+
const disposablestack_1 = require("@whatwg-node/disposablestack");
|
|
4
5
|
/**
|
|
5
6
|
* Given an AsyncIterable of AsyncIterables, flatten all yielded results into a
|
|
6
7
|
* single AsyncIterable.
|
|
@@ -84,6 +85,12 @@ function flattenAsyncIterable(iterable) {
|
|
|
84
85
|
[Symbol.asyncIterator]() {
|
|
85
86
|
return this;
|
|
86
87
|
},
|
|
88
|
+
async [disposablestack_1.DisposableSymbols.asyncDispose]() {
|
|
89
|
+
done = true;
|
|
90
|
+
await Promise.all([
|
|
91
|
+
currentNestedIterator?.[disposablestack_1.DisposableSymbols.asyncDispose]?.(),
|
|
92
|
+
topIterator?.[disposablestack_1.DisposableSymbols.asyncDispose]?.(),
|
|
93
|
+
]);
|
|
94
|
+
},
|
|
87
95
|
};
|
|
88
96
|
}
|
|
89
|
-
exports.flattenAsyncIterable = flattenAsyncIterable;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.invariant =
|
|
3
|
+
exports.invariant = invariant;
|
|
4
4
|
function invariant(condition, message) {
|
|
5
5
|
if (!condition) {
|
|
6
6
|
throw new Error(message != null ? message : 'Unexpected invariant triggered.');
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
exports.invariant = invariant;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizedExecutor =
|
|
3
|
+
exports.normalizedExecutor = normalizedExecutor;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
5
|
const value_or_promise_1 = require("value-or-promise");
|
|
6
6
|
const execute_js_1 = require("./execute.js");
|
|
@@ -21,4 +21,3 @@ function normalizedExecutor(args) {
|
|
|
21
21
|
})
|
|
22
22
|
.resolve();
|
|
23
23
|
}
|
|
24
|
-
exports.normalizedExecutor = normalizedExecutor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.promiseForObject =
|
|
3
|
+
exports.promiseForObject = promiseForObject;
|
|
4
4
|
/**
|
|
5
5
|
* This function transforms a JS object `Record<string, Promise<T>>` into
|
|
6
6
|
* a `Promise<Record<string, T>>`
|
|
@@ -20,4 +20,3 @@ async function promiseForObject(object, signal) {
|
|
|
20
20
|
});
|
|
21
21
|
return resolvedObject;
|
|
22
22
|
}
|
|
23
|
-
exports.promiseForObject = promiseForObject;
|
package/cjs/execution/values.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getVariableValues =
|
|
3
|
+
exports.getVariableValues = getVariableValues;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
5
|
const utils_1 = require("@graphql-tools/utils");
|
|
6
6
|
/**
|
|
@@ -29,10 +29,8 @@ function getVariableValues(schema, varDefNodes, inputs, options) {
|
|
|
29
29
|
catch (error) {
|
|
30
30
|
errors.push(error);
|
|
31
31
|
}
|
|
32
|
-
// @ts-expect-error - We know that errors is an array of GraphQLError.
|
|
33
32
|
return { errors };
|
|
34
33
|
}
|
|
35
|
-
exports.getVariableValues = getVariableValues;
|
|
36
34
|
function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
37
35
|
const coercedValues = {};
|
|
38
36
|
for (const varDefNode of varDefNodes) {
|
package/esm/execution/execute.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { assertValidSchema, getDirectiveValues, GraphQLError, isAbstractType, isLeafType, isListType, isNonNullType, isObjectType, Kind, locatedError, SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, versionInfo, } from 'graphql';
|
|
2
2
|
import { ValueOrPromise } from 'value-or-promise';
|
|
3
3
|
import { collectSubFields as _collectSubfields, addPath, collectFields, createGraphQLError, fakePromise, getArgumentValues, getDefinedRootType, GraphQLStreamDirective, inspect, isAsyncIterable, isIterableObject, isObjectLike, isPromise, mapAsyncIterator, memoize1, memoize3, pathToArray, promiseReduce, } from '@graphql-tools/utils';
|
|
4
|
+
import { DisposableSymbols } from '@whatwg-node/disposablestack';
|
|
4
5
|
import { coerceError } from './coerceError.js';
|
|
5
6
|
import { flattenAsyncIterable } from './flattenAsyncIterable.js';
|
|
6
7
|
import { invariant } from './invariant.js';
|
|
@@ -843,6 +844,10 @@ export function flattenIncrementalResults(incrementalResults) {
|
|
|
843
844
|
done = true;
|
|
844
845
|
return subsequentIterator.throw(error);
|
|
845
846
|
},
|
|
847
|
+
[DisposableSymbols.asyncDispose]() {
|
|
848
|
+
done = true;
|
|
849
|
+
return subsequentIterator?.[DisposableSymbols.asyncDispose]?.();
|
|
850
|
+
},
|
|
846
851
|
};
|
|
847
852
|
}
|
|
848
853
|
async function* ensureAsyncIterable(someExecutionResult) {
|
|
@@ -1223,6 +1228,10 @@ function yieldSubsequentPayloads(exeContext) {
|
|
|
1223
1228
|
isDone = true;
|
|
1224
1229
|
return Promise.reject(error);
|
|
1225
1230
|
},
|
|
1231
|
+
async [DisposableSymbols.asyncDispose]() {
|
|
1232
|
+
await returnStreamIterators();
|
|
1233
|
+
isDone = true;
|
|
1234
|
+
},
|
|
1226
1235
|
};
|
|
1227
1236
|
}
|
|
1228
1237
|
class DeferredFragmentRecord {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DisposableSymbols } from '@whatwg-node/disposablestack';
|
|
1
2
|
/**
|
|
2
3
|
* Given an AsyncIterable of AsyncIterables, flatten all yielded results into a
|
|
3
4
|
* single AsyncIterable.
|
|
@@ -81,5 +82,12 @@ export function flattenAsyncIterable(iterable) {
|
|
|
81
82
|
[Symbol.asyncIterator]() {
|
|
82
83
|
return this;
|
|
83
84
|
},
|
|
85
|
+
async [DisposableSymbols.asyncDispose]() {
|
|
86
|
+
done = true;
|
|
87
|
+
await Promise.all([
|
|
88
|
+
currentNestedIterator?.[DisposableSymbols.asyncDispose]?.(),
|
|
89
|
+
topIterator?.[DisposableSymbols.asyncDispose]?.(),
|
|
90
|
+
]);
|
|
91
|
+
},
|
|
84
92
|
};
|
|
85
93
|
}
|
package/esm/execution/values.js
CHANGED
|
@@ -26,7 +26,6 @@ export function getVariableValues(schema, varDefNodes, inputs, options) {
|
|
|
26
26
|
catch (error) {
|
|
27
27
|
errors.push(error);
|
|
28
28
|
}
|
|
29
|
-
// @ts-expect-error - We know that errors is an array of GraphQLError.
|
|
30
29
|
return { errors };
|
|
31
30
|
}
|
|
32
31
|
function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/executor",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7-alpha-20241209101052-b0932c49214ceb915e4bebbab82ae2fee9dfba47",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@graphql-tools/utils": "^10.6.2",
|
|
10
|
-
"@graphql-typed-document-node/core": "3.2.0",
|
|
10
|
+
"@graphql-typed-document-node/core": "^3.2.0",
|
|
11
11
|
"@repeaterjs/repeater": "^3.0.4",
|
|
12
|
+
"@whatwg-node/disposablestack": "^0.0.5",
|
|
12
13
|
"tslib": "^2.4.0",
|
|
13
14
|
"value-or-promise": "^1.0.12"
|
|
14
15
|
},
|