@graphql-tools/executor 1.5.7 → 1.5.8-alpha-20260805104220-afd9ce934fb96bca17c99dca2e98db84c0b782c1
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/execute.js +38 -7
- package/cjs/execution/values.js +6 -70
- package/esm/execution/execute.js +38 -7
- package/esm/execution/values.js +7 -71
- package/package.json +2 -2
- package/typings/execution/execute.d.cts +2 -2
- package/typings/execution/execute.d.ts +2 -2
- package/typings/execution/values.d.cts +4 -18
- package/typings/execution/values.d.ts +4 -18
package/cjs/execution/execute.js
CHANGED
|
@@ -19,7 +19,6 @@ const coerceError_js_1 = require("./coerceError.js");
|
|
|
19
19
|
const flattenAsyncIterable_js_1 = require("./flattenAsyncIterable.js");
|
|
20
20
|
const invariant_js_1 = require("./invariant.js");
|
|
21
21
|
const promiseForObject_js_1 = require("./promiseForObject.js");
|
|
22
|
-
const values_js_1 = require("./values.js");
|
|
23
22
|
/**
|
|
24
23
|
* A memoized collection of relevant subfields with regard to the return
|
|
25
24
|
* type. Memoizing ensures the subfields are not repeatedly calculated, which
|
|
@@ -199,7 +198,7 @@ function buildExecutionContext(args) {
|
|
|
199
198
|
// FIXME: https://github.com/graphql/graphql-js/issues/2203
|
|
200
199
|
/* c8 ignore next */
|
|
201
200
|
const variableDefinitions = operation.variableDefinitions ?? [];
|
|
202
|
-
const coercedVariableValues = (0,
|
|
201
|
+
const coercedVariableValues = (0, graphql_1.getVariableValues)(schema, variableDefinitions, rawVariableValues ?? {}, {
|
|
203
202
|
maxErrors: 50,
|
|
204
203
|
});
|
|
205
204
|
if (coercedVariableValues.errors) {
|
|
@@ -227,13 +226,26 @@ function buildExecutionContext(args) {
|
|
|
227
226
|
listeners.add(handler);
|
|
228
227
|
};
|
|
229
228
|
}
|
|
229
|
+
// If GraphQL v17, use `variableValues`
|
|
230
|
+
let variableValues;
|
|
231
|
+
if (graphql_1.versionInfo.major >= 17) {
|
|
232
|
+
variableValues = coercedVariableValues.variableValues;
|
|
233
|
+
// Older versions use `coerced`
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
variableValues = {
|
|
237
|
+
coerced: coercedVariableValues.coerced,
|
|
238
|
+
sources: {},
|
|
239
|
+
errors: coercedVariableValues.errors,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
230
242
|
return {
|
|
231
243
|
schema,
|
|
232
244
|
fragments,
|
|
233
245
|
rootValue,
|
|
234
246
|
contextValue,
|
|
235
247
|
operation,
|
|
236
|
-
variableValues
|
|
248
|
+
variableValues,
|
|
237
249
|
fieldResolver: fieldResolver ?? exports.defaultFieldResolver,
|
|
238
250
|
typeResolver: typeResolver ?? exports.defaultTypeResolver,
|
|
239
251
|
subscribeFieldResolver: subscribeFieldResolver ?? exports.defaultFieldResolver,
|
|
@@ -357,7 +369,7 @@ function executeField(exeContext, parentType, source, fieldNodes, path, asyncPay
|
|
|
357
369
|
// Build a JS object of arguments from the field.arguments AST, using the
|
|
358
370
|
// variables scope to fulfill any variable references.
|
|
359
371
|
// TODO: find a way to memoize, in case this field is within a List type.
|
|
360
|
-
const args = (0, utils_1.getArgumentValues)(fieldDef, fieldNodes[0], exeContext.variableValues);
|
|
372
|
+
const args = (0, utils_1.getArgumentValues)(fieldDef, fieldNodes[0], exeContext.variableValues.coerced);
|
|
361
373
|
// The resolve function's optional third argument is a context value that
|
|
362
374
|
// is provided to every resolve function within an execution. It is commonly
|
|
363
375
|
// used to represent an authenticated user, or request-specific caches.
|
|
@@ -418,6 +430,10 @@ function executeField(exeContext, parentType, source, fieldNodes, path, asyncPay
|
|
|
418
430
|
function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) {
|
|
419
431
|
// The resolve function's optional fourth argument is a collection of
|
|
420
432
|
// information about the current execution state.
|
|
433
|
+
// GraphQL.js v17 requires getAbortSignal / getAsyncHelpers on GraphQLResolveInfo.
|
|
434
|
+
// track() mirrors Yoga/Cloudflare waitUntil via context.waitUntil when available.
|
|
435
|
+
let asyncHelpers;
|
|
436
|
+
const variableValues = graphql_1.versionInfo.major >= 17 ? exeContext.variableValues : exeContext.variableValues.coerced;
|
|
421
437
|
return {
|
|
422
438
|
fieldName: fieldDef.name,
|
|
423
439
|
fieldNodes,
|
|
@@ -428,8 +444,23 @@ function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) {
|
|
|
428
444
|
fragments: exeContext.fragments,
|
|
429
445
|
rootValue: exeContext.rootValue,
|
|
430
446
|
operation: exeContext.operation,
|
|
431
|
-
variableValues:
|
|
447
|
+
variableValues: variableValues,
|
|
432
448
|
signal: exeContext.signal,
|
|
449
|
+
getAbortSignal: () => exeContext.signal,
|
|
450
|
+
getAsyncHelpers: () => (asyncHelpers ??= {
|
|
451
|
+
promiseAll: Promise.all.bind(Promise),
|
|
452
|
+
track: maybePromises => {
|
|
453
|
+
const waitUntil = exeContext.contextValue?.waitUntil;
|
|
454
|
+
if (typeof waitUntil !== 'function') {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
for (const value of maybePromises) {
|
|
458
|
+
if ((0, utils_1.isPromise)(value)) {
|
|
459
|
+
waitUntil(value);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
}),
|
|
433
464
|
};
|
|
434
465
|
}
|
|
435
466
|
exports.CRITICAL_ERROR = 'CRITICAL_ERROR';
|
|
@@ -520,7 +551,7 @@ function getStreamValues(exeContext, fieldNodes, path) {
|
|
|
520
551
|
}
|
|
521
552
|
// validation only allows equivalent streams on multiple fields, so it is
|
|
522
553
|
// safe to only check the first fieldNode for the stream directive
|
|
523
|
-
const stream = (0,
|
|
554
|
+
const stream = (0, utils_1.getDirectiveValues)(utils_1.GraphQLStreamDirective, fieldNodes[0], exeContext.variableValues);
|
|
524
555
|
if (!stream) {
|
|
525
556
|
return;
|
|
526
557
|
}
|
|
@@ -973,7 +1004,7 @@ function executeSubscription(exeContext) {
|
|
|
973
1004
|
// It differs from "ResolveFieldValue" due to providing a different `resolveFn`.
|
|
974
1005
|
// Build a JS object of arguments from the field.arguments AST, using the
|
|
975
1006
|
// variables scope to fulfill any variable references.
|
|
976
|
-
const args = (0, utils_1.getArgumentValues)(fieldDef, fieldNodes[0], variableValues);
|
|
1007
|
+
const args = (0, utils_1.getArgumentValues)(fieldDef, fieldNodes[0], variableValues.coerced);
|
|
977
1008
|
// The resolve function's optional third argument is a context value that
|
|
978
1009
|
// is provided to every resolve function within an execution. It is commonly
|
|
979
1010
|
// used to represent an authenticated user, or request-specific caches.
|
package/cjs/execution/values.js
CHANGED
|
@@ -2,77 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getVariableValues = getVariableValues;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
-
const utils_1 = require("@graphql-tools/utils");
|
|
6
|
-
/**
|
|
7
|
-
* Prepares an object map of variableValues of the correct type based on the
|
|
8
|
-
* provided variable definitions and arbitrary input. If the input cannot be
|
|
9
|
-
* parsed to match the variable definitions, a GraphQLError will be thrown.
|
|
10
|
-
*
|
|
11
|
-
* Note: The returned value is a plain Object with a prototype, since it is
|
|
12
|
-
* exposed to user code. Care should be taken to not pull values from the
|
|
13
|
-
* Object prototype.
|
|
14
|
-
*/
|
|
15
5
|
function getVariableValues(schema, varDefNodes, inputs, options) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const coerced = coerceVariableValues(schema, varDefNodes, inputs, error => {
|
|
20
|
-
if (maxErrors != null && errors.length >= maxErrors) {
|
|
21
|
-
throw (0, utils_1.createGraphQLError)('Too many errors processing variables, error limit reached. Execution aborted.');
|
|
22
|
-
}
|
|
23
|
-
errors.push(error);
|
|
24
|
-
});
|
|
25
|
-
if (errors.length === 0) {
|
|
26
|
-
return { coerced };
|
|
27
|
-
}
|
|
6
|
+
const result = (0, graphql_1.getVariableValues)(schema, varDefNodes, inputs, options);
|
|
7
|
+
if (result.errors?.length) {
|
|
8
|
+
return { errors: result.errors };
|
|
28
9
|
}
|
|
29
|
-
|
|
30
|
-
|
|
10
|
+
if (graphql_1.versionInfo.major >= 17) {
|
|
11
|
+
return result.variableValues;
|
|
31
12
|
}
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
35
|
-
const coercedValues = {};
|
|
36
|
-
for (const varDefNode of varDefNodes) {
|
|
37
|
-
const varName = varDefNode.variable.name.value;
|
|
38
|
-
const varType = (0, graphql_1.typeFromAST)(schema, varDefNode.type);
|
|
39
|
-
if (!(0, graphql_1.isInputType)(varType)) {
|
|
40
|
-
// Must use input types for variables. This should be caught during
|
|
41
|
-
// validation, however is checked again here for safety.
|
|
42
|
-
const varTypeStr = (0, graphql_1.print)(varDefNode.type);
|
|
43
|
-
onError((0, utils_1.createGraphQLError)(`Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`, { nodes: varDefNode.type }));
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
if (!(0, utils_1.hasOwnProperty)(inputs, varName)) {
|
|
47
|
-
if (varDefNode.defaultValue) {
|
|
48
|
-
coercedValues[varName] = (0, graphql_1.valueFromAST)(varDefNode.defaultValue, varType);
|
|
49
|
-
}
|
|
50
|
-
else if ((0, graphql_1.isNonNullType)(varType)) {
|
|
51
|
-
const varTypeStr = (0, utils_1.inspect)(varType);
|
|
52
|
-
onError((0, utils_1.createGraphQLError)(`Variable "$${varName}" of required type "${varTypeStr}" was not provided.`, {
|
|
53
|
-
nodes: varDefNode,
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
const value = inputs[varName];
|
|
59
|
-
if (value === null && (0, graphql_1.isNonNullType)(varType)) {
|
|
60
|
-
const varTypeStr = (0, utils_1.inspect)(varType);
|
|
61
|
-
onError((0, utils_1.createGraphQLError)(`Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`, {
|
|
62
|
-
nodes: varDefNode,
|
|
63
|
-
}));
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
coercedValues[varName] = (0, graphql_1.coerceInputValue)(value, varType, (path, invalidValue, error) => {
|
|
67
|
-
let prefix = `Variable "$${varName}" got invalid value ` + (0, utils_1.inspect)(invalidValue);
|
|
68
|
-
if (path.length > 0) {
|
|
69
|
-
prefix += ` at "${varName}${(0, utils_1.printPathArray)(path)}"`;
|
|
70
|
-
}
|
|
71
|
-
onError((0, utils_1.createGraphQLError)(prefix + '; ' + error.message, {
|
|
72
|
-
nodes: varDefNode,
|
|
73
|
-
originalError: error,
|
|
74
|
-
}));
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return coercedValues;
|
|
13
|
+
return result;
|
|
78
14
|
}
|
package/esm/execution/execute.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { assertValidSchema,
|
|
2
|
-
import { collectSubFields as _collectSubfields, addPath, collectFields, createGraphQLError, fakePromise, getArgumentValues, getDefinedRootType, GraphQLStreamDirective, inspect, isAsyncIterable, isIterableObject, isObjectLike, isPromise, locatedError, mapAsyncIterator, memoize1, memoize3, pathToArray, promiseReduce, } from '@graphql-tools/utils';
|
|
1
|
+
import { assertValidSchema, getVariableValues, GraphQLError, isAbstractType, isLeafType, isListType, isNonNullType, isObjectType, Kind, SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, versionInfo, } from 'graphql';
|
|
2
|
+
import { collectSubFields as _collectSubfields, addPath, collectFields, createGraphQLError, fakePromise, getArgumentValues, getDefinedRootType, getDirectiveValues, GraphQLStreamDirective, inspect, isAsyncIterable, isIterableObject, isObjectLike, isPromise, locatedError, mapAsyncIterator, memoize1, memoize3, pathToArray, promiseReduce, } from '@graphql-tools/utils';
|
|
3
3
|
import { DisposableSymbols } from '@whatwg-node/disposablestack';
|
|
4
4
|
import { createDeferredPromise, handleMaybePromise } from '@whatwg-node/promise-helpers';
|
|
5
5
|
import { coerceError } from './coerceError.js';
|
|
6
6
|
import { flattenAsyncIterable } from './flattenAsyncIterable.js';
|
|
7
7
|
import { invariant } from './invariant.js';
|
|
8
8
|
import { promiseForObject } from './promiseForObject.js';
|
|
9
|
-
import { getVariableValues } from './values.js';
|
|
10
9
|
/**
|
|
11
10
|
* A memoized collection of relevant subfields with regard to the return
|
|
12
11
|
* type. Memoizing ensures the subfields are not repeatedly calculated, which
|
|
@@ -214,13 +213,26 @@ export function buildExecutionContext(args) {
|
|
|
214
213
|
listeners.add(handler);
|
|
215
214
|
};
|
|
216
215
|
}
|
|
216
|
+
// If GraphQL v17, use `variableValues`
|
|
217
|
+
let variableValues;
|
|
218
|
+
if (versionInfo.major >= 17) {
|
|
219
|
+
variableValues = coercedVariableValues.variableValues;
|
|
220
|
+
// Older versions use `coerced`
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
variableValues = {
|
|
224
|
+
coerced: coercedVariableValues.coerced,
|
|
225
|
+
sources: {},
|
|
226
|
+
errors: coercedVariableValues.errors,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
217
229
|
return {
|
|
218
230
|
schema,
|
|
219
231
|
fragments,
|
|
220
232
|
rootValue,
|
|
221
233
|
contextValue,
|
|
222
234
|
operation,
|
|
223
|
-
variableValues
|
|
235
|
+
variableValues,
|
|
224
236
|
fieldResolver: fieldResolver ?? defaultFieldResolver,
|
|
225
237
|
typeResolver: typeResolver ?? defaultTypeResolver,
|
|
226
238
|
subscribeFieldResolver: subscribeFieldResolver ?? defaultFieldResolver,
|
|
@@ -344,7 +356,7 @@ function executeField(exeContext, parentType, source, fieldNodes, path, asyncPay
|
|
|
344
356
|
// Build a JS object of arguments from the field.arguments AST, using the
|
|
345
357
|
// variables scope to fulfill any variable references.
|
|
346
358
|
// TODO: find a way to memoize, in case this field is within a List type.
|
|
347
|
-
const args = getArgumentValues(fieldDef, fieldNodes[0], exeContext.variableValues);
|
|
359
|
+
const args = getArgumentValues(fieldDef, fieldNodes[0], exeContext.variableValues.coerced);
|
|
348
360
|
// The resolve function's optional third argument is a context value that
|
|
349
361
|
// is provided to every resolve function within an execution. It is commonly
|
|
350
362
|
// used to represent an authenticated user, or request-specific caches.
|
|
@@ -405,6 +417,10 @@ function executeField(exeContext, parentType, source, fieldNodes, path, asyncPay
|
|
|
405
417
|
export function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) {
|
|
406
418
|
// The resolve function's optional fourth argument is a collection of
|
|
407
419
|
// information about the current execution state.
|
|
420
|
+
// GraphQL.js v17 requires getAbortSignal / getAsyncHelpers on GraphQLResolveInfo.
|
|
421
|
+
// track() mirrors Yoga/Cloudflare waitUntil via context.waitUntil when available.
|
|
422
|
+
let asyncHelpers;
|
|
423
|
+
const variableValues = versionInfo.major >= 17 ? exeContext.variableValues : exeContext.variableValues.coerced;
|
|
408
424
|
return {
|
|
409
425
|
fieldName: fieldDef.name,
|
|
410
426
|
fieldNodes,
|
|
@@ -415,8 +431,23 @@ export function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, p
|
|
|
415
431
|
fragments: exeContext.fragments,
|
|
416
432
|
rootValue: exeContext.rootValue,
|
|
417
433
|
operation: exeContext.operation,
|
|
418
|
-
variableValues:
|
|
434
|
+
variableValues: variableValues,
|
|
419
435
|
signal: exeContext.signal,
|
|
436
|
+
getAbortSignal: () => exeContext.signal,
|
|
437
|
+
getAsyncHelpers: () => (asyncHelpers ??= {
|
|
438
|
+
promiseAll: Promise.all.bind(Promise),
|
|
439
|
+
track: maybePromises => {
|
|
440
|
+
const waitUntil = exeContext.contextValue?.waitUntil;
|
|
441
|
+
if (typeof waitUntil !== 'function') {
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
for (const value of maybePromises) {
|
|
445
|
+
if (isPromise(value)) {
|
|
446
|
+
waitUntil(value);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
}),
|
|
420
451
|
};
|
|
421
452
|
}
|
|
422
453
|
export const CRITICAL_ERROR = 'CRITICAL_ERROR';
|
|
@@ -958,7 +989,7 @@ function executeSubscription(exeContext) {
|
|
|
958
989
|
// It differs from "ResolveFieldValue" due to providing a different `resolveFn`.
|
|
959
990
|
// Build a JS object of arguments from the field.arguments AST, using the
|
|
960
991
|
// variables scope to fulfill any variable references.
|
|
961
|
-
const args = getArgumentValues(fieldDef, fieldNodes[0], variableValues);
|
|
992
|
+
const args = getArgumentValues(fieldDef, fieldNodes[0], variableValues.coerced);
|
|
962
993
|
// The resolve function's optional third argument is a context value that
|
|
963
994
|
// is provided to every resolve function within an execution. It is commonly
|
|
964
995
|
// used to represent an authenticated user, or request-specific caches.
|
package/esm/execution/values.js
CHANGED
|
@@ -1,75 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createGraphQLError, hasOwnProperty, inspect, printPathArray } from '@graphql-tools/utils';
|
|
3
|
-
/**
|
|
4
|
-
* Prepares an object map of variableValues of the correct type based on the
|
|
5
|
-
* provided variable definitions and arbitrary input. If the input cannot be
|
|
6
|
-
* parsed to match the variable definitions, a GraphQLError will be thrown.
|
|
7
|
-
*
|
|
8
|
-
* Note: The returned value is a plain Object with a prototype, since it is
|
|
9
|
-
* exposed to user code. Care should be taken to not pull values from the
|
|
10
|
-
* Object prototype.
|
|
11
|
-
*/
|
|
1
|
+
import { getVariableValues as graphqlGetVariableValues, versionInfo, } from 'graphql';
|
|
12
2
|
export function getVariableValues(schema, varDefNodes, inputs, options) {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const coerced = coerceVariableValues(schema, varDefNodes, inputs, error => {
|
|
17
|
-
if (maxErrors != null && errors.length >= maxErrors) {
|
|
18
|
-
throw createGraphQLError('Too many errors processing variables, error limit reached. Execution aborted.');
|
|
19
|
-
}
|
|
20
|
-
errors.push(error);
|
|
21
|
-
});
|
|
22
|
-
if (errors.length === 0) {
|
|
23
|
-
return { coerced };
|
|
24
|
-
}
|
|
3
|
+
const result = graphqlGetVariableValues(schema, varDefNodes, inputs, options);
|
|
4
|
+
if (result.errors?.length) {
|
|
5
|
+
return { errors: result.errors };
|
|
25
6
|
}
|
|
26
|
-
|
|
27
|
-
|
|
7
|
+
if (versionInfo.major >= 17) {
|
|
8
|
+
return result.variableValues;
|
|
28
9
|
}
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
function coerceVariableValues(schema, varDefNodes, inputs, onError) {
|
|
32
|
-
const coercedValues = {};
|
|
33
|
-
for (const varDefNode of varDefNodes) {
|
|
34
|
-
const varName = varDefNode.variable.name.value;
|
|
35
|
-
const varType = typeFromAST(schema, varDefNode.type);
|
|
36
|
-
if (!isInputType(varType)) {
|
|
37
|
-
// Must use input types for variables. This should be caught during
|
|
38
|
-
// validation, however is checked again here for safety.
|
|
39
|
-
const varTypeStr = print(varDefNode.type);
|
|
40
|
-
onError(createGraphQLError(`Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`, { nodes: varDefNode.type }));
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
if (!hasOwnProperty(inputs, varName)) {
|
|
44
|
-
if (varDefNode.defaultValue) {
|
|
45
|
-
coercedValues[varName] = valueFromAST(varDefNode.defaultValue, varType);
|
|
46
|
-
}
|
|
47
|
-
else if (isNonNullType(varType)) {
|
|
48
|
-
const varTypeStr = inspect(varType);
|
|
49
|
-
onError(createGraphQLError(`Variable "$${varName}" of required type "${varTypeStr}" was not provided.`, {
|
|
50
|
-
nodes: varDefNode,
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
const value = inputs[varName];
|
|
56
|
-
if (value === null && isNonNullType(varType)) {
|
|
57
|
-
const varTypeStr = inspect(varType);
|
|
58
|
-
onError(createGraphQLError(`Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`, {
|
|
59
|
-
nodes: varDefNode,
|
|
60
|
-
}));
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
coercedValues[varName] = coerceInputValue(value, varType, (path, invalidValue, error) => {
|
|
64
|
-
let prefix = `Variable "$${varName}" got invalid value ` + inspect(invalidValue);
|
|
65
|
-
if (path.length > 0) {
|
|
66
|
-
prefix += ` at "${varName}${printPathArray(path)}"`;
|
|
67
|
-
}
|
|
68
|
-
onError(createGraphQLError(prefix + '; ' + error.message, {
|
|
69
|
-
nodes: varDefNode,
|
|
70
|
-
originalError: error,
|
|
71
|
-
}));
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
return coercedValues;
|
|
10
|
+
return result;
|
|
75
11
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/executor",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8-alpha-20260805104220-afd9ce934fb96bca17c99dca2e98db84c0b782c1",
|
|
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
|
-
"@graphql-tools/utils": "
|
|
9
|
+
"@graphql-tools/utils": "11.2.3-alpha-20260805104220-afd9ce934fb96bca17c99dca2e98db84c0b782c1",
|
|
10
10
|
"@graphql-typed-document-node/core": "^3.2.0",
|
|
11
11
|
"@repeaterjs/repeater": "^3.1.0",
|
|
12
12
|
"@whatwg-node/disposablestack": "^0.0.6",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DocumentNode, FieldNode, FragmentDefinitionNode, GraphQLError, GraphQLField, GraphQLFieldResolver, GraphQLFormattedError, GraphQLObjectType, GraphQLSchema, GraphQLTypeResolver, OperationDefinitionNode } from 'graphql';
|
|
2
|
-
import { GraphQLResolveInfo, Maybe, MaybePromise, Path } from '@graphql-tools/utils';
|
|
2
|
+
import { GraphQLResolveInfo, Maybe, MaybePromise, Path, VariableValues } from '@graphql-tools/utils';
|
|
3
3
|
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
4
4
|
export interface SingularExecutionResult<TData = any, TExtensions = any> {
|
|
5
5
|
errors?: ReadonlyArray<GraphQLError>;
|
|
@@ -37,7 +37,7 @@ export interface ExecutionContext<TVariables = any, TContext = any> {
|
|
|
37
37
|
rootValue: unknown;
|
|
38
38
|
contextValue: TContext;
|
|
39
39
|
operation: OperationDefinitionNode;
|
|
40
|
-
variableValues: TVariables
|
|
40
|
+
variableValues: VariableValues<TVariables>;
|
|
41
41
|
fieldResolver: GraphQLFieldResolver<any, TContext>;
|
|
42
42
|
typeResolver: GraphQLTypeResolver<any, TContext>;
|
|
43
43
|
subscribeFieldResolver: GraphQLFieldResolver<any, TContext>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DocumentNode, FieldNode, FragmentDefinitionNode, GraphQLError, GraphQLField, GraphQLFieldResolver, GraphQLFormattedError, GraphQLObjectType, GraphQLSchema, GraphQLTypeResolver, OperationDefinitionNode } from 'graphql';
|
|
2
|
-
import { GraphQLResolveInfo, Maybe, MaybePromise, Path } from '@graphql-tools/utils';
|
|
2
|
+
import { GraphQLResolveInfo, Maybe, MaybePromise, Path, VariableValues } from '@graphql-tools/utils';
|
|
3
3
|
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
4
4
|
export interface SingularExecutionResult<TData = any, TExtensions = any> {
|
|
5
5
|
errors?: ReadonlyArray<GraphQLError>;
|
|
@@ -37,7 +37,7 @@ export interface ExecutionContext<TVariables = any, TContext = any> {
|
|
|
37
37
|
rootValue: unknown;
|
|
38
38
|
contextValue: TContext;
|
|
39
39
|
operation: OperationDefinitionNode;
|
|
40
|
-
variableValues: TVariables
|
|
40
|
+
variableValues: VariableValues<TVariables>;
|
|
41
41
|
fieldResolver: GraphQLFieldResolver<any, TContext>;
|
|
42
42
|
typeResolver: GraphQLTypeResolver<any, TContext>;
|
|
43
43
|
subscribeFieldResolver: GraphQLFieldResolver<any, TContext>;
|
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
import { GraphQLError, GraphQLSchema, VariableDefinitionNode } from 'graphql';
|
|
2
|
-
|
|
2
|
+
import { VariableValues } from '@graphql-tools/utils';
|
|
3
|
+
export type VariableValuesOrErrors = VariableValues | {
|
|
3
4
|
errors: ReadonlyArray<GraphQLError>;
|
|
4
|
-
coerced?: never;
|
|
5
|
-
} | {
|
|
6
|
-
coerced: {
|
|
7
|
-
[variable: string]: unknown;
|
|
8
|
-
};
|
|
9
|
-
errors?: never;
|
|
10
5
|
};
|
|
11
|
-
/**
|
|
12
|
-
* Prepares an object map of variableValues of the correct type based on the
|
|
13
|
-
* provided variable definitions and arbitrary input. If the input cannot be
|
|
14
|
-
* parsed to match the variable definitions, a GraphQLError will be thrown.
|
|
15
|
-
*
|
|
16
|
-
* Note: The returned value is a plain Object with a prototype, since it is
|
|
17
|
-
* exposed to user code. Care should be taken to not pull values from the
|
|
18
|
-
* Object prototype.
|
|
19
|
-
*/
|
|
20
6
|
export declare function getVariableValues(schema: GraphQLSchema, varDefNodes: ReadonlyArray<VariableDefinitionNode>, inputs: {
|
|
21
7
|
readonly [variable: string]: unknown;
|
|
22
8
|
}, options?: {
|
|
23
9
|
maxErrors?: number;
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
hideSuggestions?: boolean;
|
|
11
|
+
}): VariableValuesOrErrors;
|
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
import { GraphQLError, GraphQLSchema, VariableDefinitionNode } from 'graphql';
|
|
2
|
-
|
|
2
|
+
import { VariableValues } from '@graphql-tools/utils';
|
|
3
|
+
export type VariableValuesOrErrors = VariableValues | {
|
|
3
4
|
errors: ReadonlyArray<GraphQLError>;
|
|
4
|
-
coerced?: never;
|
|
5
|
-
} | {
|
|
6
|
-
coerced: {
|
|
7
|
-
[variable: string]: unknown;
|
|
8
|
-
};
|
|
9
|
-
errors?: never;
|
|
10
5
|
};
|
|
11
|
-
/**
|
|
12
|
-
* Prepares an object map of variableValues of the correct type based on the
|
|
13
|
-
* provided variable definitions and arbitrary input. If the input cannot be
|
|
14
|
-
* parsed to match the variable definitions, a GraphQLError will be thrown.
|
|
15
|
-
*
|
|
16
|
-
* Note: The returned value is a plain Object with a prototype, since it is
|
|
17
|
-
* exposed to user code. Care should be taken to not pull values from the
|
|
18
|
-
* Object prototype.
|
|
19
|
-
*/
|
|
20
6
|
export declare function getVariableValues(schema: GraphQLSchema, varDefNodes: ReadonlyArray<VariableDefinitionNode>, inputs: {
|
|
21
7
|
readonly [variable: string]: unknown;
|
|
22
8
|
}, options?: {
|
|
23
9
|
maxErrors?: number;
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
hideSuggestions?: boolean;
|
|
11
|
+
}): VariableValuesOrErrors;
|