graphql 16.14.2 → 16.15.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/error/GraphQLError.d.ts +5 -1
- package/error/GraphQLError.js +12 -7
- package/error/GraphQLError.mjs +13 -6
- package/error/locatedError.d.ts +6 -4
- package/error/locatedError.js +6 -4
- package/error/locatedError.mjs +6 -4
- package/execution/collectFields.d.ts +1 -0
- package/execution/collectFields.js +9 -0
- package/execution/collectFields.mjs +9 -0
- package/execution/execute.d.ts +9 -10
- package/execution/execute.js +44 -29
- package/execution/execute.mjs +44 -29
- package/execution/mapAsyncIterator.js +12 -11
- package/execution/mapAsyncIterator.mjs +12 -11
- package/execution/subscribe.d.ts +5 -2
- package/execution/subscribe.js +5 -2
- package/execution/subscribe.mjs +5 -2
- package/execution/values.d.ts +43 -21
- package/execution/values.js +52 -24
- package/execution/values.mjs +51 -23
- package/graphql.d.ts +8 -14
- package/graphql.js +16 -15
- package/graphql.mjs +11 -15
- package/jsutils/SetMap.d.ts +14 -0
- package/jsutils/SetMap.js +48 -0
- package/jsutils/SetMap.mjs +39 -0
- package/jsutils/isIterableObject.d.ts +2 -0
- package/jsutils/isIterableObject.js +2 -0
- package/jsutils/isIterableObject.mjs +2 -0
- package/jsutils/keyMap.d.ts +2 -0
- package/jsutils/keyMap.js +2 -0
- package/jsutils/keyMap.mjs +2 -0
- package/jsutils/keyValMap.d.ts +3 -3
- package/jsutils/keyValMap.js +3 -3
- package/jsutils/keyValMap.mjs +3 -3
- package/language/ast.d.ts +2 -6
- package/language/ast.js +2 -6
- package/language/ast.mjs +2 -6
- package/language/lexer.d.ts +6 -0
- package/language/lexer.js +22 -0
- package/language/lexer.mjs +22 -0
- package/language/location.d.ts +8 -3
- package/language/location.js +57 -17
- package/language/location.mjs +56 -16
- package/language/parser.d.ts +27 -13
- package/language/parser.js +31 -9
- package/language/parser.mjs +31 -9
- package/language/predicates.d.ts +10 -3
- package/language/predicates.js +10 -3
- package/language/predicates.mjs +10 -3
- package/language/printLocation.d.ts +2 -6
- package/language/printLocation.js +2 -6
- package/language/printLocation.mjs +2 -6
- package/language/printer.d.ts +22 -3
- package/language/printer.js +394 -308
- package/language/printer.mjs +394 -308
- package/language/reducer.d.ts +32 -0
- package/language/reducer.js +95 -0
- package/language/reducer.mjs +86 -0
- package/language/source.d.ts +4 -5
- package/language/source.js +4 -5
- package/language/source.mjs +4 -5
- package/language/visitor.d.ts +16 -10
- package/language/visitor.js +15 -7
- package/language/visitor.mjs +15 -7
- package/package.json +1 -4
- package/type/definition.d.ts +170 -102
- package/type/definition.js +169 -96
- package/type/definition.mjs +168 -95
- package/type/directives.d.ts +12 -6
- package/type/directives.js +12 -6
- package/type/directives.mjs +12 -6
- package/type/scalars.js +8 -11
- package/type/scalars.mjs +1 -1
- package/type/schema.d.ts +36 -11
- package/type/schema.js +35 -10
- package/type/schema.mjs +35 -10
- package/type/validate.d.ts +1 -3
- package/type/validate.js +1 -3
- package/type/validate.mjs +1 -3
- package/utilities/TypeInfo.d.ts +15 -11
- package/utilities/TypeInfo.js +15 -11
- package/utilities/TypeInfo.mjs +15 -11
- package/utilities/assertValidName.d.ts +1 -1
- package/utilities/assertValidName.js +1 -1
- package/utilities/assertValidName.mjs +1 -1
- package/utilities/astFromValue.d.ts +3 -1
- package/utilities/astFromValue.js +3 -1
- package/utilities/astFromValue.mjs +3 -1
- package/utilities/buildASTSchema.d.ts +8 -8
- package/utilities/buildASTSchema.js +9 -20
- package/utilities/buildASTSchema.mjs +9 -20
- package/utilities/buildClientSchema.d.ts +6 -2
- package/utilities/buildClientSchema.js +6 -2
- package/utilities/buildClientSchema.mjs +6 -2
- package/utilities/coerceInputValue.d.ts +9 -3
- package/utilities/coerceInputValue.js +60 -13
- package/utilities/coerceInputValue.mjs +58 -13
- package/utilities/concatAST.d.ts +4 -1
- package/utilities/concatAST.js +4 -1
- package/utilities/concatAST.mjs +4 -1
- package/utilities/extendSchema.d.ts +7 -4
- package/utilities/extendSchema.js +7 -4
- package/utilities/extendSchema.mjs +7 -4
- package/utilities/findBreakingChanges.d.ts +2 -2
- package/utilities/findBreakingChanges.js +2 -2
- package/utilities/findBreakingChanges.mjs +2 -2
- package/utilities/getIntrospectionQuery.d.ts +9 -9
- package/utilities/getIntrospectionQuery.js +8 -8
- package/utilities/getIntrospectionQuery.mjs +8 -8
- package/utilities/getOperationAST.d.ts +2 -2
- package/utilities/getOperationAST.js +2 -2
- package/utilities/getOperationAST.mjs +2 -2
- package/utilities/getOperationRootType.d.ts +3 -1
- package/utilities/getOperationRootType.js +3 -1
- package/utilities/getOperationRootType.mjs +3 -1
- package/utilities/introspectionFromSchema.d.ts +12 -4
- package/utilities/introspectionFromSchema.js +12 -4
- package/utilities/introspectionFromSchema.mjs +12 -4
- package/utilities/lexicographicSortSchema.d.ts +17 -13
- package/utilities/lexicographicSortSchema.js +17 -13
- package/utilities/lexicographicSortSchema.mjs +17 -13
- package/utilities/printSchema.d.ts +7 -4
- package/utilities/printSchema.js +7 -4
- package/utilities/printSchema.mjs +7 -4
- package/utilities/resolveSchemaCoordinate.d.ts +9 -8
- package/utilities/resolveSchemaCoordinate.js +9 -8
- package/utilities/resolveSchemaCoordinate.mjs +9 -8
- package/utilities/separateOperations.d.ts +2 -2
- package/utilities/separateOperations.js +2 -2
- package/utilities/separateOperations.mjs +2 -2
- package/utilities/stripIgnoredCharacters.d.ts +19 -5
- package/utilities/stripIgnoredCharacters.js +19 -5
- package/utilities/stripIgnoredCharacters.mjs +19 -5
- package/utilities/typeComparators.d.ts +1 -5
- package/utilities/typeComparators.js +1 -5
- package/utilities/typeComparators.mjs +1 -5
- package/utilities/valueFromAST.js +4 -4
- package/utilities/valueFromAST.mjs +4 -4
- package/utilities/valueFromASTUntyped.d.ts +1 -3
- package/utilities/valueFromASTUntyped.js +1 -3
- package/utilities/valueFromASTUntyped.mjs +1 -3
- package/validation/ValidationContext.d.ts +22 -3
- package/validation/ValidationContext.js +84 -27
- package/validation/ValidationContext.mjs +82 -27
- package/validation/rules/ExecutableDefinitionsRule.d.ts +6 -4
- package/validation/rules/ExecutableDefinitionsRule.js +6 -4
- package/validation/rules/ExecutableDefinitionsRule.mjs +6 -4
- package/validation/rules/FieldsOnCorrectTypeRule.d.ts +4 -4
- package/validation/rules/FieldsOnCorrectTypeRule.js +10 -6
- package/validation/rules/FieldsOnCorrectTypeRule.mjs +12 -6
- package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +6 -4
- package/validation/rules/FragmentsOnCompositeTypesRule.js +6 -4
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs +6 -4
- package/validation/rules/KnownArgumentNamesRule.d.ts +4 -4
- package/validation/rules/KnownArgumentNamesRule.js +26 -17
- package/validation/rules/KnownArgumentNamesRule.mjs +21 -11
- package/validation/rules/KnownDirectivesRule.d.ts +1 -3
- package/validation/rules/KnownDirectivesRule.js +1 -3
- package/validation/rules/KnownDirectivesRule.mjs +1 -3
- package/validation/rules/KnownFragmentNamesRule.d.ts +4 -4
- package/validation/rules/KnownFragmentNamesRule.js +4 -4
- package/validation/rules/KnownFragmentNamesRule.mjs +4 -4
- package/validation/rules/KnownTypeNamesRule.d.ts +1 -3
- package/validation/rules/KnownTypeNamesRule.js +7 -7
- package/validation/rules/KnownTypeNamesRule.mjs +7 -7
- package/validation/rules/LoneAnonymousOperationRule.d.ts +6 -4
- package/validation/rules/LoneAnonymousOperationRule.js +6 -4
- package/validation/rules/LoneAnonymousOperationRule.mjs +6 -4
- package/validation/rules/MaxIntrospectionDepthRule.d.ts +6 -4
- package/validation/rules/MaxIntrospectionDepthRule.js +44 -19
- package/validation/rules/MaxIntrospectionDepthRule.mjs +44 -19
- package/validation/rules/NoFragmentCyclesRule.d.ts +1 -3
- package/validation/rules/NoFragmentCyclesRule.js +1 -3
- package/validation/rules/NoFragmentCyclesRule.mjs +1 -3
- package/validation/rules/NoUndefinedVariablesRule.d.ts +4 -4
- package/validation/rules/NoUndefinedVariablesRule.js +4 -4
- package/validation/rules/NoUndefinedVariablesRule.mjs +4 -4
- package/validation/rules/NoUnusedFragmentsRule.d.ts +4 -4
- package/validation/rules/NoUnusedFragmentsRule.js +10 -14
- package/validation/rules/NoUnusedFragmentsRule.mjs +10 -14
- package/validation/rules/NoUnusedVariablesRule.d.ts +4 -4
- package/validation/rules/NoUnusedVariablesRule.js +4 -4
- package/validation/rules/NoUnusedVariablesRule.mjs +4 -4
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +8 -6
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +552 -354
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +545 -352
- package/validation/rules/PossibleFragmentSpreadsRule.d.ts +6 -4
- package/validation/rules/PossibleFragmentSpreadsRule.js +6 -4
- package/validation/rules/PossibleFragmentSpreadsRule.mjs +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.js +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs +6 -4
- package/validation/rules/ScalarLeafsRule.d.ts +1 -3
- package/validation/rules/ScalarLeafsRule.js +1 -3
- package/validation/rules/ScalarLeafsRule.mjs +1 -3
- package/validation/rules/SingleFieldSubscriptionsRule.d.ts +6 -4
- package/validation/rules/SingleFieldSubscriptionsRule.js +50 -9
- package/validation/rules/SingleFieldSubscriptionsRule.mjs +50 -9
- package/validation/rules/UniqueArgumentNamesRule.d.ts +4 -4
- package/validation/rules/UniqueArgumentNamesRule.js +4 -4
- package/validation/rules/UniqueArgumentNamesRule.mjs +4 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +6 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.js +6 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs +6 -4
- package/validation/rules/UniqueFragmentNamesRule.d.ts +4 -4
- package/validation/rules/UniqueFragmentNamesRule.js +4 -4
- package/validation/rules/UniqueFragmentNamesRule.mjs +4 -4
- package/validation/rules/UniqueInputFieldNamesRule.d.ts +6 -4
- package/validation/rules/UniqueInputFieldNamesRule.js +6 -4
- package/validation/rules/UniqueInputFieldNamesRule.mjs +6 -4
- package/validation/rules/UniqueOperationNamesRule.d.ts +4 -4
- package/validation/rules/UniqueOperationNamesRule.js +4 -4
- package/validation/rules/UniqueOperationNamesRule.mjs +4 -4
- package/validation/rules/UniqueVariableNamesRule.d.ts +4 -4
- package/validation/rules/UniqueVariableNamesRule.js +4 -4
- package/validation/rules/UniqueVariableNamesRule.mjs +4 -4
- package/validation/rules/ValuesOfCorrectTypeRule.d.ts +4 -4
- package/validation/rules/ValuesOfCorrectTypeRule.js +29 -23
- package/validation/rules/ValuesOfCorrectTypeRule.mjs +24 -14
- package/validation/rules/VariablesAreInputTypesRule.d.ts +6 -4
- package/validation/rules/VariablesAreInputTypesRule.js +6 -4
- package/validation/rules/VariablesAreInputTypesRule.mjs +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.d.ts +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.js +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.mjs +6 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +4 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.js +4 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs +4 -4
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +7 -5
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +7 -5
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +7 -5
- package/validation/validate.d.ts +2 -0
- package/validation/validate.js +14 -2
- package/validation/validate.mjs +13 -2
- package/validation/validationAbortedError.d.ts +3 -0
- package/validation/validationAbortedError.js +14 -0
- package/validation/validationAbortedError.mjs +4 -0
- package/version.js +3 -3
- package/version.mjs +3 -3
package/error/GraphQLError.d.ts
CHANGED
|
@@ -96,12 +96,16 @@ export declare class GraphQLError extends Error {
|
|
|
96
96
|
* `GraphQLError(message, options)` overload instead.
|
|
97
97
|
* @example
|
|
98
98
|
* ```ts
|
|
99
|
+
* import { Kind } from 'graphql/language';
|
|
100
|
+
* import assert from 'node:assert/strict';
|
|
99
101
|
* // Create an error from AST nodes and response metadata.
|
|
100
102
|
* import { parse } from 'graphql/language';
|
|
101
103
|
* import { GraphQLError } from 'graphql/error';
|
|
102
104
|
*
|
|
103
105
|
* const document = parse('{ greeting }');
|
|
104
|
-
* const
|
|
106
|
+
* const operation = document.definitions[0];
|
|
107
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
108
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
105
109
|
* const error = new GraphQLError('Cannot query this field.', {
|
|
106
110
|
* nodes: fieldNode,
|
|
107
111
|
* path: ['greeting'],
|
package/error/GraphQLError.js
CHANGED
|
@@ -82,12 +82,16 @@ class GraphQLError extends Error {
|
|
|
82
82
|
* `GraphQLError(message, options)` overload instead.
|
|
83
83
|
* @example
|
|
84
84
|
* ```ts
|
|
85
|
+
* import { Kind } from 'graphql/language';
|
|
86
|
+
* import assert from 'node:assert/strict';
|
|
85
87
|
* // Create an error from AST nodes and response metadata.
|
|
86
88
|
* import { parse } from 'graphql/language';
|
|
87
89
|
* import { GraphQLError } from 'graphql/error';
|
|
88
90
|
*
|
|
89
91
|
* const document = parse('{ greeting }');
|
|
90
|
-
* const
|
|
92
|
+
* const operation = document.definitions[0];
|
|
93
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
94
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
91
95
|
* const error = new GraphQLError('Cannot query this field.', {
|
|
92
96
|
* nodes: fieldNode,
|
|
93
97
|
* path: ['greeting'],
|
|
@@ -197,12 +201,13 @@ class GraphQLError extends Error {
|
|
|
197
201
|
: nodeLocations.map((loc) => loc.start);
|
|
198
202
|
this.locations =
|
|
199
203
|
positions && source
|
|
200
|
-
?
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
)
|
|
204
|
+
? (0, _location.getLocations)(
|
|
205
|
+
positions.map((start) => ({
|
|
206
|
+
source,
|
|
207
|
+
start,
|
|
208
|
+
})),
|
|
209
|
+
)
|
|
210
|
+
: nodeLocations && (0, _location.getLocations)(nodeLocations);
|
|
206
211
|
const originalExtensions = (0, _isObjectLike.isObjectLike)(
|
|
207
212
|
originalError === null || originalError === void 0
|
|
208
213
|
? void 0
|
package/error/GraphQLError.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @category Errors */
|
|
2
2
|
import { isObjectLike } from '../jsutils/isObjectLike.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { getLocations } from '../language/location.mjs';
|
|
4
4
|
import {
|
|
5
5
|
printLocation,
|
|
6
6
|
printSourceLocation,
|
|
@@ -74,12 +74,16 @@ export class GraphQLError extends Error {
|
|
|
74
74
|
* `GraphQLError(message, options)` overload instead.
|
|
75
75
|
* @example
|
|
76
76
|
* ```ts
|
|
77
|
+
* import { Kind } from 'graphql/language';
|
|
78
|
+
* import assert from 'node:assert/strict';
|
|
77
79
|
* // Create an error from AST nodes and response metadata.
|
|
78
80
|
* import { parse } from 'graphql/language';
|
|
79
81
|
* import { GraphQLError } from 'graphql/error';
|
|
80
82
|
*
|
|
81
83
|
* const document = parse('{ greeting }');
|
|
82
|
-
* const
|
|
84
|
+
* const operation = document.definitions[0];
|
|
85
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
86
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
83
87
|
* const error = new GraphQLError('Cannot query this field.', {
|
|
84
88
|
* nodes: fieldNode,
|
|
85
89
|
* path: ['greeting'],
|
|
@@ -189,10 +193,13 @@ export class GraphQLError extends Error {
|
|
|
189
193
|
: nodeLocations.map((loc) => loc.start);
|
|
190
194
|
this.locations =
|
|
191
195
|
positions && source
|
|
192
|
-
?
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
+
? getLocations(
|
|
197
|
+
positions.map((start) => ({
|
|
198
|
+
source,
|
|
199
|
+
start,
|
|
200
|
+
})),
|
|
201
|
+
)
|
|
202
|
+
: nodeLocations && getLocations(nodeLocations);
|
|
196
203
|
const originalExtensions = isObjectLike(
|
|
197
204
|
originalError === null || originalError === void 0
|
|
198
205
|
? void 0
|
package/error/locatedError.d.ts
CHANGED
|
@@ -12,14 +12,16 @@ import { GraphQLError } from './GraphQLError';
|
|
|
12
12
|
* @returns The GraphQL error.
|
|
13
13
|
* @example
|
|
14
14
|
* ```ts
|
|
15
|
+
* import { Kind } from 'graphql/language';
|
|
16
|
+
* import assert from 'node:assert/strict';
|
|
15
17
|
* import { parse } from 'graphql/language';
|
|
16
18
|
* import { locatedError } from 'graphql/error';
|
|
17
19
|
*
|
|
18
20
|
* const document = parse('{ viewer { name } }');
|
|
19
|
-
* const
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* ]);
|
|
21
|
+
* const operation = document.definitions[0];
|
|
22
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
23
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
24
|
+
* const error = locatedError(new Error('Resolver failed'), fieldNode, ['viewer']);
|
|
23
25
|
*
|
|
24
26
|
* error.message; // => 'Resolver failed'
|
|
25
27
|
* error.locations; // => [{ line: 1, column: 3 }]
|
package/error/locatedError.js
CHANGED
|
@@ -21,14 +21,16 @@ var _GraphQLError = require('./GraphQLError.js');
|
|
|
21
21
|
* @returns The GraphQL error.
|
|
22
22
|
* @example
|
|
23
23
|
* ```ts
|
|
24
|
+
* import { Kind } from 'graphql/language';
|
|
25
|
+
* import assert from 'node:assert/strict';
|
|
24
26
|
* import { parse } from 'graphql/language';
|
|
25
27
|
* import { locatedError } from 'graphql/error';
|
|
26
28
|
*
|
|
27
29
|
* const document = parse('{ viewer { name } }');
|
|
28
|
-
* const
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* ]);
|
|
30
|
+
* const operation = document.definitions[0];
|
|
31
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
32
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
33
|
+
* const error = locatedError(new Error('Resolver failed'), fieldNode, ['viewer']);
|
|
32
34
|
*
|
|
33
35
|
* error.message; // => 'Resolver failed'
|
|
34
36
|
* error.locations; // => [{ line: 1, column: 3 }]
|
package/error/locatedError.mjs
CHANGED
|
@@ -11,14 +11,16 @@ import { GraphQLError } from './GraphQLError.mjs';
|
|
|
11
11
|
* @returns The GraphQL error.
|
|
12
12
|
* @example
|
|
13
13
|
* ```ts
|
|
14
|
+
* import { Kind } from 'graphql/language';
|
|
15
|
+
* import assert from 'node:assert/strict';
|
|
14
16
|
* import { parse } from 'graphql/language';
|
|
15
17
|
* import { locatedError } from 'graphql/error';
|
|
16
18
|
*
|
|
17
19
|
* const document = parse('{ viewer { name } }');
|
|
18
|
-
* const
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* ]);
|
|
20
|
+
* const operation = document.definitions[0];
|
|
21
|
+
* assert(operation.kind === Kind.OPERATION_DEFINITION);
|
|
22
|
+
* const fieldNode = operation.selectionSet.selections[0];
|
|
23
|
+
* const error = locatedError(new Error('Resolver failed'), fieldNode, ['viewer']);
|
|
22
24
|
*
|
|
23
25
|
* error.message; // => 'Resolver failed'
|
|
24
26
|
* error.locations; // => [{ line: 1, column: 3 }]
|
|
@@ -23,6 +23,7 @@ export declare function collectFields(
|
|
|
23
23
|
},
|
|
24
24
|
runtimeType: GraphQLObjectType,
|
|
25
25
|
selectionSet: SelectionSetNode,
|
|
26
|
+
onSelectionSet?: (selectionSet: SelectionSetNode) => void,
|
|
26
27
|
): Map<string, ReadonlyArray<FieldNode>>;
|
|
27
28
|
/**
|
|
28
29
|
* Given an array of field nodes, collects all of the subfields of the passed
|
|
@@ -31,6 +31,7 @@ function collectFields(
|
|
|
31
31
|
variableValues,
|
|
32
32
|
runtimeType,
|
|
33
33
|
selectionSet,
|
|
34
|
+
onSelectionSet,
|
|
34
35
|
) {
|
|
35
36
|
const fields = new Map();
|
|
36
37
|
collectFieldsImpl(
|
|
@@ -41,6 +42,7 @@ function collectFields(
|
|
|
41
42
|
selectionSet,
|
|
42
43
|
fields,
|
|
43
44
|
new Set(),
|
|
45
|
+
onSelectionSet,
|
|
44
46
|
);
|
|
45
47
|
return fields;
|
|
46
48
|
}
|
|
@@ -90,7 +92,12 @@ function collectFieldsImpl(
|
|
|
90
92
|
selectionSet,
|
|
91
93
|
fields,
|
|
92
94
|
visitedFragmentNames,
|
|
95
|
+
onSelectionSet,
|
|
93
96
|
) {
|
|
97
|
+
onSelectionSet === null || onSelectionSet === void 0
|
|
98
|
+
? void 0
|
|
99
|
+
: onSelectionSet(selectionSet);
|
|
100
|
+
|
|
94
101
|
for (const selection of selectionSet.selections) {
|
|
95
102
|
switch (selection.kind) {
|
|
96
103
|
case _kinds.Kind.FIELD: {
|
|
@@ -126,6 +133,7 @@ function collectFieldsImpl(
|
|
|
126
133
|
selection.selectionSet,
|
|
127
134
|
fields,
|
|
128
135
|
visitedFragmentNames,
|
|
136
|
+
onSelectionSet,
|
|
129
137
|
);
|
|
130
138
|
break;
|
|
131
139
|
}
|
|
@@ -158,6 +166,7 @@ function collectFieldsImpl(
|
|
|
158
166
|
fragment.selectionSet,
|
|
159
167
|
fields,
|
|
160
168
|
visitedFragmentNames,
|
|
169
|
+
onSelectionSet,
|
|
161
170
|
);
|
|
162
171
|
break;
|
|
163
172
|
}
|
|
@@ -22,6 +22,7 @@ export function collectFields(
|
|
|
22
22
|
variableValues,
|
|
23
23
|
runtimeType,
|
|
24
24
|
selectionSet,
|
|
25
|
+
onSelectionSet,
|
|
25
26
|
) {
|
|
26
27
|
const fields = new Map();
|
|
27
28
|
collectFieldsImpl(
|
|
@@ -32,6 +33,7 @@ export function collectFields(
|
|
|
32
33
|
selectionSet,
|
|
33
34
|
fields,
|
|
34
35
|
new Set(),
|
|
36
|
+
onSelectionSet,
|
|
35
37
|
);
|
|
36
38
|
return fields;
|
|
37
39
|
}
|
|
@@ -81,7 +83,12 @@ function collectFieldsImpl(
|
|
|
81
83
|
selectionSet,
|
|
82
84
|
fields,
|
|
83
85
|
visitedFragmentNames,
|
|
86
|
+
onSelectionSet,
|
|
84
87
|
) {
|
|
88
|
+
onSelectionSet === null || onSelectionSet === void 0
|
|
89
|
+
? void 0
|
|
90
|
+
: onSelectionSet(selectionSet);
|
|
91
|
+
|
|
85
92
|
for (const selection of selectionSet.selections) {
|
|
86
93
|
switch (selection.kind) {
|
|
87
94
|
case Kind.FIELD: {
|
|
@@ -117,6 +124,7 @@ function collectFieldsImpl(
|
|
|
117
124
|
selection.selectionSet,
|
|
118
125
|
fields,
|
|
119
126
|
visitedFragmentNames,
|
|
127
|
+
onSelectionSet,
|
|
120
128
|
);
|
|
121
129
|
break;
|
|
122
130
|
}
|
|
@@ -149,6 +157,7 @@ function collectFieldsImpl(
|
|
|
149
157
|
fragment.selectionSet,
|
|
150
158
|
fields,
|
|
151
159
|
visitedFragmentNames,
|
|
160
|
+
onSelectionSet,
|
|
152
161
|
);
|
|
153
162
|
break;
|
|
154
163
|
}
|
package/execution/execute.d.ts
CHANGED
|
@@ -102,6 +102,8 @@ export interface FormattedExecutionResult<
|
|
|
102
102
|
}
|
|
103
103
|
/** Arguments accepted by execute and executeSync. */
|
|
104
104
|
export interface ExecutionArgs {
|
|
105
|
+
/** Omit suggestions from input coercion errors. */
|
|
106
|
+
hideSuggestions?: Maybe<boolean>;
|
|
105
107
|
/** The schema used for validation or execution. */
|
|
106
108
|
schema: GraphQLSchema;
|
|
107
109
|
/** The parsed GraphQL document to execute. */
|
|
@@ -162,12 +164,10 @@ export interface ExecutionArgs {
|
|
|
162
164
|
* schema,
|
|
163
165
|
* document: parse('query ($name: String!) { greeting(name: $name) }'),
|
|
164
166
|
* rootValue: {
|
|
165
|
-
* greeting: ({ name }) => `Hello, ${name}!`,
|
|
167
|
+
* greeting: ({ name }: { name: string }) => `Hello, ${name}!`,
|
|
166
168
|
* },
|
|
167
169
|
* variableValues: { name: 'Ada' },
|
|
168
|
-
* });
|
|
169
|
-
*
|
|
170
|
-
* result; // => { data: { greeting: 'Hello, Ada!' } }
|
|
170
|
+
* }); // => { data: { greeting: 'Hello, Ada!' } }
|
|
171
171
|
* ```
|
|
172
172
|
* @example
|
|
173
173
|
* ```ts
|
|
@@ -196,8 +196,7 @@ export interface ExecutionArgs {
|
|
|
196
196
|
* rootValue: { viewer: { kind: 'user', name: 'Ada' } },
|
|
197
197
|
* contextValue: { locale: 'en' },
|
|
198
198
|
* operationName: 'Viewer',
|
|
199
|
-
* fieldResolver: (source, _args,
|
|
200
|
-
* contextValue.locale; // => 'en'
|
|
199
|
+
* fieldResolver: (source, _args, _contextValue, info) => {
|
|
201
200
|
* return source[info.fieldName];
|
|
202
201
|
* },
|
|
203
202
|
* typeResolver: (value) => {
|
|
@@ -231,8 +230,8 @@ export interface ExecutionArgs {
|
|
|
231
230
|
* },
|
|
232
231
|
* });
|
|
233
232
|
*
|
|
234
|
-
* result.data
|
|
235
|
-
* result.errors[0].message; // => 'Resolver failed.'
|
|
233
|
+
* result.data?.broken; // => null
|
|
234
|
+
* result.errors?.[0].message; // => 'Resolver failed.'
|
|
236
235
|
* ```
|
|
237
236
|
* @example
|
|
238
237
|
* ```ts
|
|
@@ -267,8 +266,8 @@ export interface ExecutionArgs {
|
|
|
267
266
|
* options: { maxCoercionErrors: 1 },
|
|
268
267
|
* });
|
|
269
268
|
*
|
|
270
|
-
* result.errors
|
|
271
|
-
* result.errors[1].message; //
|
|
269
|
+
* result.errors?.length; // => 2
|
|
270
|
+
* result.errors?.[1].message.includes('error limit reached'); // => true
|
|
272
271
|
* ```
|
|
273
272
|
*/
|
|
274
273
|
export declare function execute(
|
package/execution/execute.js
CHANGED
|
@@ -175,12 +175,10 @@ class CollectedErrors {
|
|
|
175
175
|
* schema,
|
|
176
176
|
* document: parse('query ($name: String!) { greeting(name: $name) }'),
|
|
177
177
|
* rootValue: {
|
|
178
|
-
* greeting: ({ name }) => `Hello, ${name}!`,
|
|
178
|
+
* greeting: ({ name }: { name: string }) => `Hello, ${name}!`,
|
|
179
179
|
* },
|
|
180
180
|
* variableValues: { name: 'Ada' },
|
|
181
|
-
* });
|
|
182
|
-
*
|
|
183
|
-
* result; // => { data: { greeting: 'Hello, Ada!' } }
|
|
181
|
+
* }); // => { data: { greeting: 'Hello, Ada!' } }
|
|
184
182
|
* ```
|
|
185
183
|
* @example
|
|
186
184
|
* ```ts
|
|
@@ -209,8 +207,7 @@ class CollectedErrors {
|
|
|
209
207
|
* rootValue: { viewer: { kind: 'user', name: 'Ada' } },
|
|
210
208
|
* contextValue: { locale: 'en' },
|
|
211
209
|
* operationName: 'Viewer',
|
|
212
|
-
* fieldResolver: (source, _args,
|
|
213
|
-
* contextValue.locale; // => 'en'
|
|
210
|
+
* fieldResolver: (source, _args, _contextValue, info) => {
|
|
214
211
|
* return source[info.fieldName];
|
|
215
212
|
* },
|
|
216
213
|
* typeResolver: (value) => {
|
|
@@ -244,8 +241,8 @@ class CollectedErrors {
|
|
|
244
241
|
* },
|
|
245
242
|
* });
|
|
246
243
|
*
|
|
247
|
-
* result.data
|
|
248
|
-
* result.errors[0].message; // => 'Resolver failed.'
|
|
244
|
+
* result.data?.broken; // => null
|
|
245
|
+
* result.errors?.[0].message; // => 'Resolver failed.'
|
|
249
246
|
* ```
|
|
250
247
|
* @example
|
|
251
248
|
* ```ts
|
|
@@ -280,8 +277,8 @@ class CollectedErrors {
|
|
|
280
277
|
* options: { maxCoercionErrors: 1 },
|
|
281
278
|
* });
|
|
282
279
|
*
|
|
283
|
-
* result.errors
|
|
284
|
-
* result.errors[1].message; //
|
|
280
|
+
* result.errors?.length; // => 2
|
|
281
|
+
* result.errors?.[1].message.includes('error limit reached'); // => true
|
|
285
282
|
* ```
|
|
286
283
|
*/
|
|
287
284
|
function execute(args) {
|
|
@@ -435,7 +432,10 @@ function assertValidExecutionArguments(schema, document, rawVariableValues) {
|
|
|
435
432
|
*/
|
|
436
433
|
|
|
437
434
|
function buildExecutionContext(args) {
|
|
438
|
-
var _definition$name,
|
|
435
|
+
var _definition$name,
|
|
436
|
+
_operation$variableDe,
|
|
437
|
+
_options$maxCoercionE,
|
|
438
|
+
_args$hideSuggestions;
|
|
439
439
|
|
|
440
440
|
const {
|
|
441
441
|
schema,
|
|
@@ -518,6 +518,11 @@ function buildExecutionContext(args) {
|
|
|
518
518
|
_options$maxCoercionE !== void 0
|
|
519
519
|
? _options$maxCoercionE
|
|
520
520
|
: 50,
|
|
521
|
+
hideSuggestions:
|
|
522
|
+
(_args$hideSuggestions = args.hideSuggestions) !== null &&
|
|
523
|
+
_args$hideSuggestions !== void 0
|
|
524
|
+
? _args$hideSuggestions
|
|
525
|
+
: false,
|
|
521
526
|
},
|
|
522
527
|
);
|
|
523
528
|
|
|
@@ -1206,27 +1211,37 @@ const defaultTypeResolver = function (value, contextValue, info, abstractType) {
|
|
|
1206
1211
|
const possibleTypes = info.schema.getPossibleTypes(abstractType);
|
|
1207
1212
|
const promisedIsTypeOfResults = [];
|
|
1208
1213
|
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
if (
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1214
|
+
try {
|
|
1215
|
+
for (let i = 0; i < possibleTypes.length; i++) {
|
|
1216
|
+
const type = possibleTypes[i];
|
|
1217
|
+
|
|
1218
|
+
if (type.isTypeOf) {
|
|
1219
|
+
const isTypeOfResult = type.isTypeOf(value, contextValue, info);
|
|
1220
|
+
|
|
1221
|
+
if ((0, _isPromise.isPromise)(isTypeOfResult)) {
|
|
1222
|
+
promisedIsTypeOfResults[i] = isTypeOfResult;
|
|
1223
|
+
} else if (isTypeOfResult) {
|
|
1224
|
+
if (promisedIsTypeOfResults.length) {
|
|
1225
|
+
// Explicitly ignore any promise rejections
|
|
1226
|
+
Promise.allSettled(promisedIsTypeOfResults)
|
|
1227
|
+
/* c8 ignore next 3 */
|
|
1228
|
+
.catch(() => {
|
|
1229
|
+
// Do nothing
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1226
1232
|
|
|
1227
|
-
|
|
1233
|
+
return type.name;
|
|
1234
|
+
}
|
|
1228
1235
|
}
|
|
1229
1236
|
}
|
|
1237
|
+
} catch (error) {
|
|
1238
|
+
if (promisedIsTypeOfResults.length) {
|
|
1239
|
+
return Promise.allSettled(promisedIsTypeOfResults).then(() => {
|
|
1240
|
+
throw error;
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
throw error;
|
|
1230
1245
|
}
|
|
1231
1246
|
|
|
1232
1247
|
if (promisedIsTypeOfResults.length) {
|
package/execution/execute.mjs
CHANGED
|
@@ -155,12 +155,10 @@ class CollectedErrors {
|
|
|
155
155
|
* schema,
|
|
156
156
|
* document: parse('query ($name: String!) { greeting(name: $name) }'),
|
|
157
157
|
* rootValue: {
|
|
158
|
-
* greeting: ({ name }) => `Hello, ${name}!`,
|
|
158
|
+
* greeting: ({ name }: { name: string }) => `Hello, ${name}!`,
|
|
159
159
|
* },
|
|
160
160
|
* variableValues: { name: 'Ada' },
|
|
161
|
-
* });
|
|
162
|
-
*
|
|
163
|
-
* result; // => { data: { greeting: 'Hello, Ada!' } }
|
|
161
|
+
* }); // => { data: { greeting: 'Hello, Ada!' } }
|
|
164
162
|
* ```
|
|
165
163
|
* @example
|
|
166
164
|
* ```ts
|
|
@@ -189,8 +187,7 @@ class CollectedErrors {
|
|
|
189
187
|
* rootValue: { viewer: { kind: 'user', name: 'Ada' } },
|
|
190
188
|
* contextValue: { locale: 'en' },
|
|
191
189
|
* operationName: 'Viewer',
|
|
192
|
-
* fieldResolver: (source, _args,
|
|
193
|
-
* contextValue.locale; // => 'en'
|
|
190
|
+
* fieldResolver: (source, _args, _contextValue, info) => {
|
|
194
191
|
* return source[info.fieldName];
|
|
195
192
|
* },
|
|
196
193
|
* typeResolver: (value) => {
|
|
@@ -224,8 +221,8 @@ class CollectedErrors {
|
|
|
224
221
|
* },
|
|
225
222
|
* });
|
|
226
223
|
*
|
|
227
|
-
* result.data
|
|
228
|
-
* result.errors[0].message; // => 'Resolver failed.'
|
|
224
|
+
* result.data?.broken; // => null
|
|
225
|
+
* result.errors?.[0].message; // => 'Resolver failed.'
|
|
229
226
|
* ```
|
|
230
227
|
* @example
|
|
231
228
|
* ```ts
|
|
@@ -260,8 +257,8 @@ class CollectedErrors {
|
|
|
260
257
|
* options: { maxCoercionErrors: 1 },
|
|
261
258
|
* });
|
|
262
259
|
*
|
|
263
|
-
* result.errors
|
|
264
|
-
* result.errors[1].message; //
|
|
260
|
+
* result.errors?.length; // => 2
|
|
261
|
+
* result.errors?.[1].message.includes('error limit reached'); // => true
|
|
265
262
|
* ```
|
|
266
263
|
*/
|
|
267
264
|
export function execute(args) {
|
|
@@ -419,7 +416,10 @@ export function assertValidExecutionArguments(
|
|
|
419
416
|
*/
|
|
420
417
|
|
|
421
418
|
export function buildExecutionContext(args) {
|
|
422
|
-
var _definition$name,
|
|
419
|
+
var _definition$name,
|
|
420
|
+
_operation$variableDe,
|
|
421
|
+
_options$maxCoercionE,
|
|
422
|
+
_args$hideSuggestions;
|
|
423
423
|
|
|
424
424
|
const {
|
|
425
425
|
schema,
|
|
@@ -498,6 +498,11 @@ export function buildExecutionContext(args) {
|
|
|
498
498
|
_options$maxCoercionE !== void 0
|
|
499
499
|
? _options$maxCoercionE
|
|
500
500
|
: 50,
|
|
501
|
+
hideSuggestions:
|
|
502
|
+
(_args$hideSuggestions = args.hideSuggestions) !== null &&
|
|
503
|
+
_args$hideSuggestions !== void 0
|
|
504
|
+
? _args$hideSuggestions
|
|
505
|
+
: false,
|
|
501
506
|
},
|
|
502
507
|
);
|
|
503
508
|
|
|
@@ -1176,27 +1181,37 @@ export const defaultTypeResolver = function (
|
|
|
1176
1181
|
const possibleTypes = info.schema.getPossibleTypes(abstractType);
|
|
1177
1182
|
const promisedIsTypeOfResults = [];
|
|
1178
1183
|
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
if (
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1184
|
+
try {
|
|
1185
|
+
for (let i = 0; i < possibleTypes.length; i++) {
|
|
1186
|
+
const type = possibleTypes[i];
|
|
1187
|
+
|
|
1188
|
+
if (type.isTypeOf) {
|
|
1189
|
+
const isTypeOfResult = type.isTypeOf(value, contextValue, info);
|
|
1190
|
+
|
|
1191
|
+
if (isPromise(isTypeOfResult)) {
|
|
1192
|
+
promisedIsTypeOfResults[i] = isTypeOfResult;
|
|
1193
|
+
} else if (isTypeOfResult) {
|
|
1194
|
+
if (promisedIsTypeOfResults.length) {
|
|
1195
|
+
// Explicitly ignore any promise rejections
|
|
1196
|
+
Promise.allSettled(promisedIsTypeOfResults)
|
|
1197
|
+
/* c8 ignore next 3 */
|
|
1198
|
+
.catch(() => {
|
|
1199
|
+
// Do nothing
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1196
1202
|
|
|
1197
|
-
|
|
1203
|
+
return type.name;
|
|
1204
|
+
}
|
|
1198
1205
|
}
|
|
1199
1206
|
}
|
|
1207
|
+
} catch (error) {
|
|
1208
|
+
if (promisedIsTypeOfResults.length) {
|
|
1209
|
+
return Promise.allSettled(promisedIsTypeOfResults).then(() => {
|
|
1210
|
+
throw error;
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
throw error;
|
|
1200
1215
|
}
|
|
1201
1216
|
|
|
1202
1217
|
if (promisedIsTypeOfResults.length) {
|
|
@@ -25,18 +25,18 @@ function mapAsyncIterator(iterable, callback) {
|
|
|
25
25
|
done: false,
|
|
26
26
|
};
|
|
27
27
|
} catch (error) {
|
|
28
|
-
|
|
29
|
-
// FIXME: add test case
|
|
30
|
-
if (typeof iterator.return === 'function') {
|
|
31
|
-
try {
|
|
32
|
-
await iterator.return();
|
|
33
|
-
} catch (_e) {
|
|
34
|
-
/* ignore error */
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
28
|
+
await returnIgnoringErrors();
|
|
38
29
|
throw error;
|
|
39
|
-
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function returnIgnoringErrors() {
|
|
34
|
+
if (typeof iterator.return === 'function') {
|
|
35
|
+
try {
|
|
36
|
+
await iterator.return();
|
|
37
|
+
} catch (_error) {
|
|
38
|
+
// Keep the original error when closing the source also fails.
|
|
39
|
+
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -60,6 +60,7 @@ function mapAsyncIterator(iterable, callback) {
|
|
|
60
60
|
return mapResult(await iterator.throw(error));
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
await returnIgnoringErrors();
|
|
63
64
|
throw error;
|
|
64
65
|
},
|
|
65
66
|
|
|
@@ -18,18 +18,18 @@ export function mapAsyncIterator(iterable, callback) {
|
|
|
18
18
|
done: false,
|
|
19
19
|
};
|
|
20
20
|
} catch (error) {
|
|
21
|
-
|
|
22
|
-
// FIXME: add test case
|
|
23
|
-
if (typeof iterator.return === 'function') {
|
|
24
|
-
try {
|
|
25
|
-
await iterator.return();
|
|
26
|
-
} catch (_e) {
|
|
27
|
-
/* ignore error */
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
21
|
+
await returnIgnoringErrors();
|
|
31
22
|
throw error;
|
|
32
|
-
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function returnIgnoringErrors() {
|
|
27
|
+
if (typeof iterator.return === 'function') {
|
|
28
|
+
try {
|
|
29
|
+
await iterator.return();
|
|
30
|
+
} catch (_error) {
|
|
31
|
+
// Keep the original error when closing the source also fails.
|
|
32
|
+
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -53,6 +53,7 @@ export function mapAsyncIterator(iterable, callback) {
|
|
|
53
53
|
return mapResult(await iterator.throw(error));
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
await returnIgnoringErrors();
|
|
56
57
|
throw error;
|
|
57
58
|
},
|
|
58
59
|
|
package/execution/subscribe.d.ts
CHANGED
|
@@ -97,7 +97,10 @@ import type { ExecutionArgs, ExecutionResult } from './execute';
|
|
|
97
97
|
* 'subscription Greeting($locale: String) { greeting(locale: $locale) }',
|
|
98
98
|
* ),
|
|
99
99
|
* rootValue: {
|
|
100
|
-
* greeting: (
|
|
100
|
+
* greeting: (
|
|
101
|
+
* args: { locale?: string },
|
|
102
|
+
* contextValue: { defaultLocale: string },
|
|
103
|
+
* ) => {
|
|
101
104
|
* const locale = args.locale ?? contextValue.defaultLocale;
|
|
102
105
|
* return locale === 'fr' ? frenchGreetings() : defaultGreetings();
|
|
103
106
|
* },
|
|
@@ -137,7 +140,7 @@ import type { ExecutionArgs, ExecutionResult } from './execute';
|
|
|
137
140
|
*
|
|
138
141
|
* assert('errors' in result);
|
|
139
142
|
*
|
|
140
|
-
* result.errors[0].message; // => 'Schema is not configured to execute subscription operation.'
|
|
143
|
+
* result.errors?.[0].message; // => 'Schema is not configured to execute subscription operation.'
|
|
141
144
|
* ```
|
|
142
145
|
*/
|
|
143
146
|
export declare function subscribe(
|