@graphql-tools/utils 8.6.9 → 8.6.12-alpha-a2f32d26.0
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/createGraphQLError.d.ts +14 -0
- package/errors.d.ts +14 -1
- package/index.js +81 -17
- package/index.mjs +81 -18
- package/package.json +2 -2
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ASTNode, GraphQLError, GraphQLErrorExtensions, Source } from 'graphql';
|
|
2
|
+
import { Maybe } from './types';
|
|
3
|
+
interface GraphQLErrorOptions {
|
|
4
|
+
nodes?: ReadonlyArray<ASTNode> | ASTNode | null;
|
|
5
|
+
source?: Maybe<Source>;
|
|
6
|
+
positions?: Maybe<ReadonlyArray<number>>;
|
|
7
|
+
path?: Maybe<ReadonlyArray<string | number>>;
|
|
8
|
+
originalError?: Maybe<Error & {
|
|
9
|
+
readonly extensions?: unknown;
|
|
10
|
+
}>;
|
|
11
|
+
extensions?: Maybe<GraphQLErrorExtensions>;
|
|
12
|
+
}
|
|
13
|
+
export declare function createGraphQLError(message: string, options: GraphQLErrorOptions): GraphQLError;
|
|
14
|
+
export {};
|
package/errors.d.ts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
import { GraphQLError } from 'graphql';
|
|
1
|
+
import { ASTNode, GraphQLError, GraphQLErrorExtensions, Source } from 'graphql';
|
|
2
|
+
import { Maybe } from './types';
|
|
3
|
+
interface GraphQLErrorOptions {
|
|
4
|
+
nodes?: ReadonlyArray<ASTNode> | ASTNode | null;
|
|
5
|
+
source?: Maybe<Source>;
|
|
6
|
+
positions?: Maybe<ReadonlyArray<number>>;
|
|
7
|
+
path?: Maybe<ReadonlyArray<string | number>>;
|
|
8
|
+
originalError?: Maybe<Error & {
|
|
9
|
+
readonly extensions?: unknown;
|
|
10
|
+
}>;
|
|
11
|
+
extensions?: Maybe<GraphQLErrorExtensions>;
|
|
12
|
+
}
|
|
13
|
+
export declare function createGraphQLError(message: string, options: GraphQLErrorOptions): GraphQLError;
|
|
2
14
|
export declare function relocatedError(originalError: GraphQLError, path?: ReadonlyArray<string | number>): GraphQLError;
|
|
15
|
+
export {};
|
package/index.js
CHANGED
|
@@ -69,6 +69,19 @@ function assertSome(input, message = 'Value should be something') {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
function createGraphQLError(message, options) {
|
|
73
|
+
if (graphql.versionInfo.major > 15) {
|
|
74
|
+
const error = new graphql.GraphQLError(message, options);
|
|
75
|
+
Object.defineProperty(error, 'extensions', {
|
|
76
|
+
value: options.extensions || {},
|
|
77
|
+
});
|
|
78
|
+
return error;
|
|
79
|
+
}
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
return new graphql.GraphQLError(message, options.nodes, options.source, options.positions, options.path, options.originalError, options.extensions);
|
|
83
|
+
}
|
|
84
|
+
|
|
72
85
|
if (typeof AggregateError === 'undefined') {
|
|
73
86
|
class AggregateErrorClass extends Error {
|
|
74
87
|
constructor(errors, message = '') {
|
|
@@ -217,7 +230,9 @@ function getArgumentValues(def, node, variableValues = {}) {
|
|
|
217
230
|
coercedValues[name] = defaultValue;
|
|
218
231
|
}
|
|
219
232
|
else if (graphql.isNonNullType(argType)) {
|
|
220
|
-
throw
|
|
233
|
+
throw createGraphQLError(`Argument "${name}" of required type "${inspect(argType)}" ` + 'was not provided.', {
|
|
234
|
+
nodes: [node],
|
|
235
|
+
});
|
|
221
236
|
}
|
|
222
237
|
continue;
|
|
223
238
|
}
|
|
@@ -230,22 +245,28 @@ function getArgumentValues(def, node, variableValues = {}) {
|
|
|
230
245
|
coercedValues[name] = defaultValue;
|
|
231
246
|
}
|
|
232
247
|
else if (graphql.isNonNullType(argType)) {
|
|
233
|
-
throw
|
|
234
|
-
`was provided the variable "$${variableName}" which was not provided a runtime value.`,
|
|
248
|
+
throw createGraphQLError(`Argument "${name}" of required type "${inspect(argType)}" ` +
|
|
249
|
+
`was provided the variable "$${variableName}" which was not provided a runtime value.`, {
|
|
250
|
+
nodes: [valueNode],
|
|
251
|
+
});
|
|
235
252
|
}
|
|
236
253
|
continue;
|
|
237
254
|
}
|
|
238
255
|
isNull = variableValues[variableName] == null;
|
|
239
256
|
}
|
|
240
257
|
if (isNull && graphql.isNonNullType(argType)) {
|
|
241
|
-
throw
|
|
258
|
+
throw createGraphQLError(`Argument "${name}" of non-null type "${inspect(argType)}" ` + 'must not be null.', {
|
|
259
|
+
nodes: [valueNode],
|
|
260
|
+
});
|
|
242
261
|
}
|
|
243
262
|
const coercedValue = graphql.valueFromAST(valueNode, argType, variableValues);
|
|
244
263
|
if (coercedValue === undefined) {
|
|
245
264
|
// Note: ValuesOfCorrectTypeRule validation should catch this before
|
|
246
265
|
// execution. This is a runtime check to ensure execution does not
|
|
247
266
|
// continue with an invalid argument value.
|
|
248
|
-
throw
|
|
267
|
+
throw createGraphQLError(`Argument "${name}" has invalid value ${graphql.print(valueNode)}.`, {
|
|
268
|
+
nodes: [valueNode],
|
|
269
|
+
});
|
|
249
270
|
}
|
|
250
271
|
coercedValues[name] = coercedValue;
|
|
251
272
|
}
|
|
@@ -3287,11 +3308,13 @@ function visitSchema(schema) {
|
|
|
3287
3308
|
return visitQueue(queue, schema);
|
|
3288
3309
|
}
|
|
3289
3310
|
function visitQueue(queue, schema, visited = new Set()) {
|
|
3311
|
+
// Interfaces encountered that are field return types need to be revisited to add their implementations
|
|
3312
|
+
const revisit = new Map();
|
|
3290
3313
|
// Navigate all types starting with pre-queued types (root types)
|
|
3291
3314
|
while (queue.length) {
|
|
3292
3315
|
const typeName = queue.pop();
|
|
3293
|
-
// Skip types we already visited
|
|
3294
|
-
if (visited.has(typeName)) {
|
|
3316
|
+
// Skip types we already visited unless it is an interface type that needs revisiting
|
|
3317
|
+
if (visited.has(typeName) && revisit[typeName] !== true) {
|
|
3295
3318
|
continue;
|
|
3296
3319
|
}
|
|
3297
3320
|
const type = schema.getType(typeName);
|
|
@@ -3300,6 +3323,17 @@ function visitQueue(queue, schema, visited = new Set()) {
|
|
|
3300
3323
|
if (graphql.isUnionType(type)) {
|
|
3301
3324
|
queue.push(...type.getTypes().map(type => type.name));
|
|
3302
3325
|
}
|
|
3326
|
+
// If it is an interface and it is a returned type, grab all implementations so we can use proper __typename in fragments
|
|
3327
|
+
if (graphql.isInterfaceType(type) && revisit[typeName] === true) {
|
|
3328
|
+
queue.push(...getImplementingTypes(type.name, schema));
|
|
3329
|
+
// No need to revisit this interface again
|
|
3330
|
+
revisit[typeName] = false;
|
|
3331
|
+
}
|
|
3332
|
+
// Visit interfaces this type is implementing if they haven't been visited yet
|
|
3333
|
+
if ('getInterfaces' in type) {
|
|
3334
|
+
// Only pushes to queue to visit but not return types
|
|
3335
|
+
queue.push(...type.getInterfaces().map(iface => iface.name));
|
|
3336
|
+
}
|
|
3303
3337
|
// If the type has files visit those field types
|
|
3304
3338
|
if ('getFields' in type) {
|
|
3305
3339
|
const fields = type.getFields();
|
|
@@ -3309,17 +3343,17 @@ function visitQueue(queue, schema, visited = new Set()) {
|
|
|
3309
3343
|
}
|
|
3310
3344
|
for (const [, field] of entries) {
|
|
3311
3345
|
if (graphql.isObjectType(type)) {
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3346
|
+
// Visit arg types
|
|
3347
|
+
queue.push(...field.args.map(arg => graphql.getNamedType(arg.type).name));
|
|
3348
|
+
}
|
|
3349
|
+
const namedType = graphql.getNamedType(field.type);
|
|
3350
|
+
queue.push(namedType.name);
|
|
3351
|
+
// Interfaces returned on fields need to be revisited to add their implementations
|
|
3352
|
+
if (graphql.isInterfaceType(namedType) && !(namedType.name in revisit)) {
|
|
3353
|
+
revisit[namedType.name] = true;
|
|
3315
3354
|
}
|
|
3316
|
-
queue.push(graphql.getNamedType(field.type).name);
|
|
3317
3355
|
}
|
|
3318
3356
|
}
|
|
3319
|
-
// Visit interfaces this type is implementing if they haven't been visited yet
|
|
3320
|
-
if ('getInterfaces' in type) {
|
|
3321
|
-
queue.push(...type.getInterfaces().map(iface => iface.name));
|
|
3322
|
-
}
|
|
3323
3357
|
visited.add(typeName); // Mark as visited (and therefore it is used and should be kept)
|
|
3324
3358
|
}
|
|
3325
3359
|
}
|
|
@@ -3745,8 +3779,27 @@ function implementsAbstractType(schema, typeA, typeB) {
|
|
|
3745
3779
|
return false;
|
|
3746
3780
|
}
|
|
3747
3781
|
|
|
3782
|
+
function createGraphQLError$1(message, options) {
|
|
3783
|
+
if (graphql.versionInfo.major > 15) {
|
|
3784
|
+
const error = new graphql.GraphQLError(message, options);
|
|
3785
|
+
Object.defineProperty(error, 'extensions', {
|
|
3786
|
+
value: options.extensions || {},
|
|
3787
|
+
});
|
|
3788
|
+
return error;
|
|
3789
|
+
}
|
|
3790
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3791
|
+
// @ts-ignore
|
|
3792
|
+
return new graphql.GraphQLError(message, options.nodes, options.source, options.positions, options.path, options.originalError, options.extensions);
|
|
3793
|
+
}
|
|
3748
3794
|
function relocatedError(originalError, path) {
|
|
3749
|
-
return
|
|
3795
|
+
return createGraphQLError$1(originalError.message, {
|
|
3796
|
+
nodes: originalError.nodes,
|
|
3797
|
+
source: originalError.source,
|
|
3798
|
+
positions: originalError.positions,
|
|
3799
|
+
path: path == null ? originalError.path : path,
|
|
3800
|
+
originalError,
|
|
3801
|
+
extensions: originalError.extensions,
|
|
3802
|
+
});
|
|
3750
3803
|
}
|
|
3751
3804
|
|
|
3752
3805
|
function observableToAsyncIterable(observable) {
|
|
@@ -4003,8 +4056,18 @@ function visitErrorsByType(errors, errorVisitorMap, errorInfo) {
|
|
|
4003
4056
|
return newError;
|
|
4004
4057
|
});
|
|
4005
4058
|
}
|
|
4059
|
+
function getOperationRootType(schema, operationDef) {
|
|
4060
|
+
switch (operationDef.operation) {
|
|
4061
|
+
case 'query':
|
|
4062
|
+
return schema.getQueryType();
|
|
4063
|
+
case 'mutation':
|
|
4064
|
+
return schema.getMutationType();
|
|
4065
|
+
case 'subscription':
|
|
4066
|
+
return schema.getSubscriptionType();
|
|
4067
|
+
}
|
|
4068
|
+
}
|
|
4006
4069
|
function visitRoot(root, operation, schema, fragments, variableValues, resultVisitorMap, errors, errorInfo) {
|
|
4007
|
-
const operationRootType =
|
|
4070
|
+
const operationRootType = getOperationRootType(schema, operation);
|
|
4008
4071
|
const collectedFields = collectFields(schema, fragments, variableValues, operationRootType, operation.selectionSet, new Map(), new Set());
|
|
4009
4072
|
return visitObjectValue(root, operationRootType, collectedFields, schema, fragments, variableValues, resultVisitorMap, 0, errors, errorInfo);
|
|
4010
4073
|
}
|
|
@@ -4262,6 +4325,7 @@ exports.compareNodes = compareNodes;
|
|
|
4262
4325
|
exports.compareStrings = compareStrings;
|
|
4263
4326
|
exports.correctASTNodes = correctASTNodes;
|
|
4264
4327
|
exports.createDefaultRules = createDefaultRules;
|
|
4328
|
+
exports.createGraphQLError = createGraphQLError$1;
|
|
4265
4329
|
exports.createNamedStub = createNamedStub;
|
|
4266
4330
|
exports.createStub = createStub;
|
|
4267
4331
|
exports.createVariableNameGenerator = createVariableNameGenerator;
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parse, GraphQLError, isNonNullType, Kind, valueFromAST, print, isObjectType, isListType, isSpecifiedDirective, astFromValue, isSpecifiedScalarType, isIntrospectionType, isInterfaceType, isUnionType, isInputObjectType, isEnumType, isScalarType, GraphQLDeprecatedDirective, specifiedRules, concatAST, validate,
|
|
1
|
+
import { parse, versionInfo, GraphQLError, isNonNullType, Kind, valueFromAST, print, isObjectType, isListType, isSpecifiedDirective, astFromValue, isSpecifiedScalarType, isIntrospectionType, isInterfaceType, isUnionType, isInputObjectType, isEnumType, isScalarType, GraphQLDeprecatedDirective, specifiedRules, concatAST, validate, buildClientSchema, visit, TokenKind, Source, isTypeSystemDefinitionNode, getNamedType, GraphQLString, GraphQLNonNull, GraphQLList, GraphQLID, GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLDirective, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, isNamedType, getNullableType, isLeafType, GraphQLSchema, isDirective, isCompositeType, doTypesOverlap, getOperationAST, getDirectiveValues, GraphQLSkipDirective, GraphQLIncludeDirective, typeFromAST, isAbstractType, TypeNameMetaFieldDef, buildASTSchema } from 'graphql';
|
|
2
2
|
|
|
3
3
|
const asArray = (fns) => (Array.isArray(fns) ? fns : fns ? [fns] : []);
|
|
4
4
|
const invalidDocRegex = /\.[a-z0-9]+$/i;
|
|
@@ -65,6 +65,19 @@ function assertSome(input, message = 'Value should be something') {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
function createGraphQLError(message, options) {
|
|
69
|
+
if (versionInfo.major > 15) {
|
|
70
|
+
const error = new GraphQLError(message, options);
|
|
71
|
+
Object.defineProperty(error, 'extensions', {
|
|
72
|
+
value: options.extensions || {},
|
|
73
|
+
});
|
|
74
|
+
return error;
|
|
75
|
+
}
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
return new GraphQLError(message, options.nodes, options.source, options.positions, options.path, options.originalError, options.extensions);
|
|
79
|
+
}
|
|
80
|
+
|
|
68
81
|
let AggregateErrorImpl;
|
|
69
82
|
if (typeof AggregateError === 'undefined') {
|
|
70
83
|
class AggregateErrorClass extends Error {
|
|
@@ -214,7 +227,9 @@ function getArgumentValues(def, node, variableValues = {}) {
|
|
|
214
227
|
coercedValues[name] = defaultValue;
|
|
215
228
|
}
|
|
216
229
|
else if (isNonNullType(argType)) {
|
|
217
|
-
throw
|
|
230
|
+
throw createGraphQLError(`Argument "${name}" of required type "${inspect(argType)}" ` + 'was not provided.', {
|
|
231
|
+
nodes: [node],
|
|
232
|
+
});
|
|
218
233
|
}
|
|
219
234
|
continue;
|
|
220
235
|
}
|
|
@@ -227,22 +242,28 @@ function getArgumentValues(def, node, variableValues = {}) {
|
|
|
227
242
|
coercedValues[name] = defaultValue;
|
|
228
243
|
}
|
|
229
244
|
else if (isNonNullType(argType)) {
|
|
230
|
-
throw
|
|
231
|
-
`was provided the variable "$${variableName}" which was not provided a runtime value.`,
|
|
245
|
+
throw createGraphQLError(`Argument "${name}" of required type "${inspect(argType)}" ` +
|
|
246
|
+
`was provided the variable "$${variableName}" which was not provided a runtime value.`, {
|
|
247
|
+
nodes: [valueNode],
|
|
248
|
+
});
|
|
232
249
|
}
|
|
233
250
|
continue;
|
|
234
251
|
}
|
|
235
252
|
isNull = variableValues[variableName] == null;
|
|
236
253
|
}
|
|
237
254
|
if (isNull && isNonNullType(argType)) {
|
|
238
|
-
throw
|
|
255
|
+
throw createGraphQLError(`Argument "${name}" of non-null type "${inspect(argType)}" ` + 'must not be null.', {
|
|
256
|
+
nodes: [valueNode],
|
|
257
|
+
});
|
|
239
258
|
}
|
|
240
259
|
const coercedValue = valueFromAST(valueNode, argType, variableValues);
|
|
241
260
|
if (coercedValue === undefined) {
|
|
242
261
|
// Note: ValuesOfCorrectTypeRule validation should catch this before
|
|
243
262
|
// execution. This is a runtime check to ensure execution does not
|
|
244
263
|
// continue with an invalid argument value.
|
|
245
|
-
throw
|
|
264
|
+
throw createGraphQLError(`Argument "${name}" has invalid value ${print(valueNode)}.`, {
|
|
265
|
+
nodes: [valueNode],
|
|
266
|
+
});
|
|
246
267
|
}
|
|
247
268
|
coercedValues[name] = coercedValue;
|
|
248
269
|
}
|
|
@@ -3285,11 +3306,13 @@ function visitSchema(schema) {
|
|
|
3285
3306
|
return visitQueue(queue, schema);
|
|
3286
3307
|
}
|
|
3287
3308
|
function visitQueue(queue, schema, visited = new Set()) {
|
|
3309
|
+
// Interfaces encountered that are field return types need to be revisited to add their implementations
|
|
3310
|
+
const revisit = new Map();
|
|
3288
3311
|
// Navigate all types starting with pre-queued types (root types)
|
|
3289
3312
|
while (queue.length) {
|
|
3290
3313
|
const typeName = queue.pop();
|
|
3291
|
-
// Skip types we already visited
|
|
3292
|
-
if (visited.has(typeName)) {
|
|
3314
|
+
// Skip types we already visited unless it is an interface type that needs revisiting
|
|
3315
|
+
if (visited.has(typeName) && revisit[typeName] !== true) {
|
|
3293
3316
|
continue;
|
|
3294
3317
|
}
|
|
3295
3318
|
const type = schema.getType(typeName);
|
|
@@ -3298,6 +3321,17 @@ function visitQueue(queue, schema, visited = new Set()) {
|
|
|
3298
3321
|
if (isUnionType(type)) {
|
|
3299
3322
|
queue.push(...type.getTypes().map(type => type.name));
|
|
3300
3323
|
}
|
|
3324
|
+
// If it is an interface and it is a returned type, grab all implementations so we can use proper __typename in fragments
|
|
3325
|
+
if (isInterfaceType(type) && revisit[typeName] === true) {
|
|
3326
|
+
queue.push(...getImplementingTypes(type.name, schema));
|
|
3327
|
+
// No need to revisit this interface again
|
|
3328
|
+
revisit[typeName] = false;
|
|
3329
|
+
}
|
|
3330
|
+
// Visit interfaces this type is implementing if they haven't been visited yet
|
|
3331
|
+
if ('getInterfaces' in type) {
|
|
3332
|
+
// Only pushes to queue to visit but not return types
|
|
3333
|
+
queue.push(...type.getInterfaces().map(iface => iface.name));
|
|
3334
|
+
}
|
|
3301
3335
|
// If the type has files visit those field types
|
|
3302
3336
|
if ('getFields' in type) {
|
|
3303
3337
|
const fields = type.getFields();
|
|
@@ -3307,17 +3341,17 @@ function visitQueue(queue, schema, visited = new Set()) {
|
|
|
3307
3341
|
}
|
|
3308
3342
|
for (const [, field] of entries) {
|
|
3309
3343
|
if (isObjectType(type)) {
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3344
|
+
// Visit arg types
|
|
3345
|
+
queue.push(...field.args.map(arg => getNamedType(arg.type).name));
|
|
3346
|
+
}
|
|
3347
|
+
const namedType = getNamedType(field.type);
|
|
3348
|
+
queue.push(namedType.name);
|
|
3349
|
+
// Interfaces returned on fields need to be revisited to add their implementations
|
|
3350
|
+
if (isInterfaceType(namedType) && !(namedType.name in revisit)) {
|
|
3351
|
+
revisit[namedType.name] = true;
|
|
3313
3352
|
}
|
|
3314
|
-
queue.push(getNamedType(field.type).name);
|
|
3315
3353
|
}
|
|
3316
3354
|
}
|
|
3317
|
-
// Visit interfaces this type is implementing if they haven't been visited yet
|
|
3318
|
-
if ('getInterfaces' in type) {
|
|
3319
|
-
queue.push(...type.getInterfaces().map(iface => iface.name));
|
|
3320
|
-
}
|
|
3321
3355
|
visited.add(typeName); // Mark as visited (and therefore it is used and should be kept)
|
|
3322
3356
|
}
|
|
3323
3357
|
}
|
|
@@ -3743,8 +3777,27 @@ function implementsAbstractType(schema, typeA, typeB) {
|
|
|
3743
3777
|
return false;
|
|
3744
3778
|
}
|
|
3745
3779
|
|
|
3780
|
+
function createGraphQLError$1(message, options) {
|
|
3781
|
+
if (versionInfo.major > 15) {
|
|
3782
|
+
const error = new GraphQLError(message, options);
|
|
3783
|
+
Object.defineProperty(error, 'extensions', {
|
|
3784
|
+
value: options.extensions || {},
|
|
3785
|
+
});
|
|
3786
|
+
return error;
|
|
3787
|
+
}
|
|
3788
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3789
|
+
// @ts-ignore
|
|
3790
|
+
return new GraphQLError(message, options.nodes, options.source, options.positions, options.path, options.originalError, options.extensions);
|
|
3791
|
+
}
|
|
3746
3792
|
function relocatedError(originalError, path) {
|
|
3747
|
-
return
|
|
3793
|
+
return createGraphQLError$1(originalError.message, {
|
|
3794
|
+
nodes: originalError.nodes,
|
|
3795
|
+
source: originalError.source,
|
|
3796
|
+
positions: originalError.positions,
|
|
3797
|
+
path: path == null ? originalError.path : path,
|
|
3798
|
+
originalError,
|
|
3799
|
+
extensions: originalError.extensions,
|
|
3800
|
+
});
|
|
3748
3801
|
}
|
|
3749
3802
|
|
|
3750
3803
|
function observableToAsyncIterable(observable) {
|
|
@@ -4001,6 +4054,16 @@ function visitErrorsByType(errors, errorVisitorMap, errorInfo) {
|
|
|
4001
4054
|
return newError;
|
|
4002
4055
|
});
|
|
4003
4056
|
}
|
|
4057
|
+
function getOperationRootType(schema, operationDef) {
|
|
4058
|
+
switch (operationDef.operation) {
|
|
4059
|
+
case 'query':
|
|
4060
|
+
return schema.getQueryType();
|
|
4061
|
+
case 'mutation':
|
|
4062
|
+
return schema.getMutationType();
|
|
4063
|
+
case 'subscription':
|
|
4064
|
+
return schema.getSubscriptionType();
|
|
4065
|
+
}
|
|
4066
|
+
}
|
|
4004
4067
|
function visitRoot(root, operation, schema, fragments, variableValues, resultVisitorMap, errors, errorInfo) {
|
|
4005
4068
|
const operationRootType = getOperationRootType(schema, operation);
|
|
4006
4069
|
const collectedFields = collectFields(schema, fragments, variableValues, operationRootType, operation.selectionSet, new Map(), new Set());
|
|
@@ -4234,4 +4297,4 @@ function fixSchemaAst(schema, options) {
|
|
|
4234
4297
|
return schema;
|
|
4235
4298
|
}
|
|
4236
4299
|
|
|
4237
|
-
export { AggregateErrorImpl as AggregateError, MapperKind, addTypes, appendObjectFields, asArray, assertSome, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, collectComment, collectFields, collectSubFields, compareNodes, compareStrings, correctASTNodes, createDefaultRules, createNamedStub, createStub, createVariableNameGenerator, dedentBlockStringValue, filterSchema, fixSchemaAst, forEachDefaultValue, forEachField, getArgumentValues, getAsyncIterableWithCancel, getAsyncIteratorWithCancel, getBlockStringIndentation, getBuiltInForStub, getComment, getDefinedRootType, getDeprecatableDirectiveNodes, getDescription, getDirective, getDirectiveInExtensions, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getOperationASTFromDocument, getOperationASTFromRequest, getResolversFromSchema, getResponseKeyFromInfo, getRootTypeMap, getRootTypeNames, getRootTypes, healSchema, healTypes, implementsAbstractType, inspect, isAggregateError, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isNamedStub, isSome, isValidPath, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, memoize1, memoize2, memoize2of4, memoize3, memoize4, memoize5, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printComment, printSchemaWithDirectives, printWithComments, pruneSchema, pushComment, relocatedError, removeObjectFields, renameType, resetComments, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, getAsyncIterableWithCancel as withCancel };
|
|
4300
|
+
export { AggregateErrorImpl as AggregateError, MapperKind, addTypes, appendObjectFields, asArray, assertSome, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, collectComment, collectFields, collectSubFields, compareNodes, compareStrings, correctASTNodes, createDefaultRules, createGraphQLError$1 as createGraphQLError, createNamedStub, createStub, createVariableNameGenerator, dedentBlockStringValue, filterSchema, fixSchemaAst, forEachDefaultValue, forEachField, getArgumentValues, getAsyncIterableWithCancel, getAsyncIteratorWithCancel, getBlockStringIndentation, getBuiltInForStub, getComment, getDefinedRootType, getDeprecatableDirectiveNodes, getDescription, getDirective, getDirectiveInExtensions, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getOperationASTFromDocument, getOperationASTFromRequest, getResolversFromSchema, getResponseKeyFromInfo, getRootTypeMap, getRootTypeNames, getRootTypes, healSchema, healTypes, implementsAbstractType, inspect, isAggregateError, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isNamedStub, isSome, isValidPath, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, memoize1, memoize2, memoize2of4, memoize3, memoize4, memoize5, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printComment, printSchemaWithDirectives, printWithComments, pruneSchema, pushComment, relocatedError, removeObjectFields, renameType, resetComments, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, getAsyncIterableWithCancel as withCancel };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/utils",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.12-alpha-a2f32d26.0",
|
|
4
4
|
"description": "Common package containing utils and types for GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"tslib": "~2.
|
|
10
|
+
"tslib": "~2.4.0"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|