graphql 16.5.0 → 17.0.0-alpha.1
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/NotSupportedTSVersion.d.ts +1 -1
- package/README.md +0 -1
- package/error/GraphQLError.d.ts +0 -30
- package/error/GraphQLError.js +33 -192
- package/error/index.d.ts +1 -1
- package/error/index.js +3 -41
- package/error/locatedError.js +7 -23
- package/error/syntaxError.js +3 -11
- package/execution/collectFields.js +24 -74
- package/execution/execute.js +201 -395
- package/execution/index.js +13 -73
- package/execution/mapAsyncIterator.js +3 -24
- package/execution/subscribe.js +50 -107
- package/execution/values.js +62 -162
- package/graphql.js +25 -58
- package/index.d.ts +1 -15
- package/index.js +288 -1269
- package/jsutils/AccumulatorMap.d.ts +7 -0
- package/jsutils/AccumulatorMap.js +16 -0
- package/jsutils/Maybe.js +1 -5
- package/jsutils/ObjMap.js +1 -5
- package/jsutils/Path.js +3 -18
- package/jsutils/PromiseOrValue.js +1 -5
- package/jsutils/capitalize.d.ts +4 -0
- package/jsutils/capitalize.js +6 -0
- package/jsutils/devAssert.d.ts +1 -1
- package/jsutils/devAssert.js +2 -11
- package/jsutils/didYouMean.js +10 -30
- package/jsutils/formatList.d.ts +8 -0
- package/jsutils/formatList.js +25 -0
- package/jsutils/groupBy.js +4 -19
- package/jsutils/identityFunc.js +1 -8
- package/jsutils/inspect.js +3 -34
- package/jsutils/instanceOf.js +10 -26
- package/jsutils/invariant.d.ts +1 -1
- package/jsutils/invariant.js +2 -11
- package/jsutils/isAsyncIterable.js +2 -13
- package/jsutils/isIterableObject.js +2 -11
- package/jsutils/isObjectLike.js +1 -8
- package/jsutils/isPromise.js +2 -12
- package/jsutils/keyMap.js +1 -10
- package/jsutils/keyValMap.js +1 -10
- package/jsutils/mapValue.js +1 -10
- package/jsutils/memoize3.js +1 -15
- package/jsutils/naturalCompare.js +1 -20
- package/jsutils/printPathArray.js +1 -8
- package/jsutils/promiseForObject.js +1 -10
- package/jsutils/promiseReduce.js +3 -13
- package/jsutils/suggestionList.js +8 -39
- package/jsutils/toError.js +3 -12
- package/jsutils/toObjMap.js +1 -12
- package/language/ast.js +12 -97
- package/language/blockString.js +31 -88
- package/language/characterClasses.js +5 -20
- package/language/directiveLocation.d.ts +0 -6
- package/language/directiveLocation.js +4 -17
- package/language/index.d.ts +1 -10
- package/language/index.js +28 -215
- package/language/kinds.d.ts +0 -6
- package/language/kinds.js +13 -17
- package/language/lexer.js +158 -422
- package/language/location.js +4 -23
- package/language/parser.js +166 -451
- package/language/predicates.js +46 -74
- package/language/printLocation.js +6 -20
- package/language/printString.js +25 -173
- package/language/printer.js +34 -96
- package/language/source.js +10 -31
- package/language/tokenKind.d.ts +0 -6
- package/language/tokenKind.js +2 -17
- package/language/visitor.d.ts +0 -13
- package/language/visitor.js +23 -211
- package/package.json +16 -6
- package/type/assertName.js +13 -35
- package/type/definition.js +174 -549
- package/type/directives.js +49 -114
- package/type/index.js +119 -547
- package/type/introspection.js +119 -214
- package/type/scalars.js +65 -189
- package/type/schema.js +55 -146
- package/type/validate.js +165 -360
- package/utilities/TypeInfo.js +85 -200
- package/utilities/astFromValue.js +50 -111
- package/utilities/buildASTSchema.js +23 -60
- package/utilities/buildClientSchema.js +89 -158
- package/utilities/coerceInputValue.js +54 -97
- package/utilities/concatAST.js +3 -16
- package/utilities/extendSchema.js +160 -436
- package/utilities/findBreakingChanges.js +68 -166
- package/utilities/getIntrospectionQuery.js +1 -10
- package/utilities/getOperationAST.js +4 -22
- package/utilities/index.d.ts +0 -2
- package/utilities/index.js +51 -233
- package/utilities/introspectionFromSchema.js +8 -24
- package/utilities/lexicographicSortSchema.js +52 -75
- package/utilities/printSchema.js +44 -118
- package/utilities/separateOperations.js +18 -34
- package/utilities/sortValueNode.js +21 -27
- package/utilities/stripIgnoredCharacters.js +12 -39
- package/utilities/typeComparators.js +39 -58
- package/utilities/typeFromAST.js +8 -19
- package/utilities/typedQueryDocumentNode.js +1 -5
- package/utilities/valueFromAST.js +30 -75
- package/utilities/valueFromASTUntyped.js +14 -31
- package/validation/ValidationContext.js +11 -74
- package/validation/index.js +68 -317
- package/validation/rules/ExecutableDefinitionsRule.js +10 -24
- package/validation/rules/FieldsOnCorrectTypeRule.js +35 -72
- package/validation/rules/FragmentsOnCompositeTypesRule.js +15 -40
- package/validation/rules/KnownArgumentNamesRule.js +18 -57
- package/validation/rules/KnownDirectivesRule.js +63 -114
- package/validation/rules/KnownFragmentNamesRule.js +5 -17
- package/validation/rules/KnownTypeNamesRule.js +21 -47
- package/validation/rules/LoneAnonymousOperationRule.js +6 -18
- package/validation/rules/LoneSchemaDefinitionRule.js +11 -42
- package/validation/rules/NoFragmentCyclesRule.js +10 -29
- package/validation/rules/NoUndefinedVariablesRule.js +4 -18
- package/validation/rules/NoUnusedFragmentsRule.js +5 -21
- package/validation/rules/NoUnusedVariablesRule.js +4 -19
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +102 -182
- package/validation/rules/PossibleFragmentSpreadsRule.js +20 -53
- package/validation/rules/PossibleTypeExtensionsRule.js +53 -102
- package/validation/rules/ProvidedRequiredArgumentsRule.js +29 -90
- package/validation/rules/ScalarLeafsRule.js +11 -26
- package/validation/rules/SingleFieldSubscriptionsRule.js +10 -30
- package/validation/rules/UniqueArgumentDefinitionNamesRule.js +13 -55
- package/validation/rules/UniqueArgumentNamesRule.js +7 -30
- package/validation/rules/UniqueDirectiveNamesRule.js +7 -26
- package/validation/rules/UniqueDirectivesPerLocationRule.js +15 -37
- package/validation/rules/UniqueEnumValueNamesRule.js +11 -38
- package/validation/rules/UniqueFieldDefinitionNamesRule.js +15 -41
- package/validation/rules/UniqueFragmentNamesRule.js +4 -17
- package/validation/rules/UniqueInputFieldNamesRule.js +6 -20
- package/validation/rules/UniqueOperationNamesRule.js +3 -14
- package/validation/rules/UniqueOperationTypesRule.js +7 -30
- package/validation/rules/UniqueTypeNamesRule.js +8 -25
- package/validation/rules/UniqueVariableNamesRule.js +7 -26
- package/validation/rules/ValuesOfCorrectTypeRule.js +56 -109
- package/validation/rules/VariablesAreInputTypesRule.js +10 -27
- package/validation/rules/VariablesInAllowedPositionRule.js +16 -47
- package/validation/rules/custom/NoDeprecatedCustomRule.js +24 -70
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +8 -21
- package/validation/specifiedRules.js +83 -122
- package/validation/validate.js +32 -65
- package/version.js +5 -15
- package/error/GraphQLError.mjs +0 -253
- package/error/index.mjs +0 -3
- package/error/locatedError.mjs +0 -32
- package/error/syntaxError.mjs +0 -12
- package/execution/collectFields.mjs +0 -213
- package/execution/execute.mjs +0 -998
- package/execution/index.mjs +0 -13
- package/execution/mapAsyncIterator.mjs +0 -61
- package/execution/subscribe.mjs +0 -243
- package/execution/values.mjs +0 -263
- package/graphql.mjs +0 -122
- package/index.mjs +0 -255
- package/jsutils/Maybe.mjs +0 -1
- package/jsutils/ObjMap.mjs +0 -1
- package/jsutils/Path.mjs +0 -25
- package/jsutils/PromiseOrValue.mjs +0 -1
- package/jsutils/devAssert.mjs +0 -7
- package/jsutils/didYouMean.mjs +0 -32
- package/jsutils/groupBy.mjs +0 -19
- package/jsutils/identityFunc.mjs +0 -6
- package/jsutils/inspect.mjs +0 -115
- package/jsutils/instanceOf.mjs +0 -53
- package/jsutils/invariant.mjs +0 -9
- package/jsutils/isAsyncIterable.mjs +0 -11
- package/jsutils/isIterableObject.mjs +0 -25
- package/jsutils/isObjectLike.mjs +0 -7
- package/jsutils/isPromise.mjs +0 -10
- package/jsutils/keyMap.mjs +0 -36
- package/jsutils/keyValMap.mjs +0 -26
- package/jsutils/mapValue.mjs +0 -13
- package/jsutils/memoize3.mjs +0 -34
- package/jsutils/naturalCompare.mjs +0 -61
- package/jsutils/printPathArray.mjs +0 -10
- package/jsutils/promiseForObject.mjs +0 -18
- package/jsutils/promiseReduce.mjs +0 -20
- package/jsutils/suggestionList.mjs +0 -130
- package/jsutils/toError.mjs +0 -18
- package/jsutils/toObjMap.mjs +0 -17
- package/language/ast.mjs +0 -206
- package/language/blockString.mjs +0 -178
- package/language/characterClasses.mjs +0 -64
- package/language/directiveLocation.mjs +0 -31
- package/language/index.mjs +0 -29
- package/language/kinds.mjs +0 -55
- package/language/lexer.mjs +0 -902
- package/language/location.mjs +0 -30
- package/language/parser.mjs +0 -1524
- package/language/predicates.mjs +0 -81
- package/language/printLocation.mjs +0 -66
- package/language/printString.mjs +0 -176
- package/language/printer.mjs +0 -339
- package/language/source.mjs +0 -50
- package/language/tokenKind.mjs +0 -35
- package/language/visitor.mjs +0 -361
- package/subscription/index.d.ts +0 -19
- package/subscription/index.js +0 -19
- package/subscription/index.mjs +0 -19
- package/type/assertName.mjs +0 -44
- package/type/definition.mjs +0 -1177
- package/type/directives.mjs +0 -190
- package/type/index.mjs +0 -103
- package/type/introspection.mjs +0 -550
- package/type/scalars.mjs +0 -309
- package/type/schema.mjs +0 -381
- package/type/validate.mjs +0 -651
- package/utilities/TypeInfo.mjs +0 -395
- package/utilities/assertValidName.d.ts +0 -13
- package/utilities/assertValidName.js +0 -51
- package/utilities/assertValidName.mjs +0 -40
- package/utilities/astFromValue.mjs +0 -177
- package/utilities/buildASTSchema.mjs +0 -97
- package/utilities/buildClientSchema.mjs +0 -363
- package/utilities/coerceInputValue.mjs +0 -167
- package/utilities/concatAST.mjs +0 -19
- package/utilities/extendSchema.mjs +0 -789
- package/utilities/findBreakingChanges.mjs +0 -516
- package/utilities/getIntrospectionQuery.mjs +0 -127
- package/utilities/getOperationAST.mjs +0 -36
- package/utilities/getOperationRootType.d.ts +0 -15
- package/utilities/getOperationRootType.js +0 -67
- package/utilities/getOperationRootType.mjs +0 -54
- package/utilities/index.mjs +0 -55
- package/utilities/introspectionFromSchema.mjs +0 -30
- package/utilities/lexicographicSortSchema.mjs +0 -172
- package/utilities/printSchema.mjs +0 -309
- package/utilities/separateOperations.mjs +0 -80
- package/utilities/sortValueNode.mjs +0 -39
- package/utilities/stripIgnoredCharacters.mjs +0 -104
- package/utilities/typeComparators.mjs +0 -106
- package/utilities/typeFromAST.mjs +0 -18
- package/utilities/typedQueryDocumentNode.mjs +0 -1
- package/utilities/valueFromAST.mjs +0 -172
- package/utilities/valueFromASTUntyped.mjs +0 -53
- package/validation/ValidationContext.mjs +0 -212
- package/validation/index.mjs +0 -68
- package/validation/rules/ExecutableDefinitionsRule.mjs +0 -34
- package/validation/rules/FieldsOnCorrectTypeRule.mjs +0 -127
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs +0 -53
- package/validation/rules/KnownArgumentNamesRule.mjs +0 -102
- package/validation/rules/KnownDirectivesRule.mjs +0 -150
- package/validation/rules/KnownFragmentNamesRule.mjs +0 -26
- package/validation/rules/KnownTypeNamesRule.mjs +0 -77
- package/validation/rules/LoneAnonymousOperationRule.mjs +0 -34
- package/validation/rules/LoneSchemaDefinitionRule.mjs +0 -57
- package/validation/rules/NoFragmentCyclesRule.mjs +0 -78
- package/validation/rules/NoUndefinedVariablesRule.mjs +0 -45
- package/validation/rules/NoUnusedFragmentsRule.mjs +0 -51
- package/validation/rules/NoUnusedVariablesRule.mjs +0 -50
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +0 -790
- package/validation/rules/PossibleFragmentSpreadsRule.mjs +0 -73
- package/validation/rules/PossibleTypeExtensionsRule.mjs +0 -148
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs +0 -142
- package/validation/rules/ScalarLeafsRule.mjs +0 -46
- package/validation/rules/SingleFieldSubscriptionsRule.mjs +0 -77
- package/validation/rules/UniqueArgumentDefinitionNamesRule.mjs +0 -81
- package/validation/rules/UniqueArgumentNamesRule.mjs +0 -44
- package/validation/rules/UniqueDirectiveNamesRule.mjs +0 -47
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs +0 -85
- package/validation/rules/UniqueEnumValueNamesRule.mjs +0 -64
- package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +0 -79
- package/validation/rules/UniqueFragmentNamesRule.mjs +0 -34
- package/validation/rules/UniqueInputFieldNamesRule.mjs +0 -46
- package/validation/rules/UniqueOperationNamesRule.mjs +0 -39
- package/validation/rules/UniqueOperationTypesRule.mjs +0 -64
- package/validation/rules/UniqueTypeNamesRule.mjs +0 -47
- package/validation/rules/UniqueVariableNamesRule.mjs +0 -41
- package/validation/rules/ValuesOfCorrectTypeRule.mjs +0 -173
- package/validation/rules/VariablesAreInputTypesRule.mjs +0 -33
- package/validation/rules/VariablesInAllowedPositionRule.mjs +0 -97
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs +0 -117
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +0 -32
- package/validation/specifiedRules.mjs +0 -123
- package/validation/validate.mjs +0 -133
- package/version.mjs +0 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
"Package 'graphql' support only TS versions that are >=4.
|
|
1
|
+
"Package 'graphql' support only TS versions that are >=4.4.0".
|
package/README.md
CHANGED
|
@@ -4,7 +4,6 @@ The JavaScript reference implementation for GraphQL, a query language for APIs c
|
|
|
4
4
|
|
|
5
5
|
[](https://badge.fury.io/js/graphql)
|
|
6
6
|
[](https://github.com/graphql/graphql-js/actions?query=branch%3Amain)
|
|
7
|
-
[](https://codecov.io/gh/graphql/graphql-js)
|
|
8
7
|
|
|
9
8
|
See more complete documentation at https://graphql.org/ and
|
|
10
9
|
https://graphql.org/graphql-js/.
|
package/error/GraphQLError.d.ts
CHANGED
|
@@ -76,22 +76,6 @@ export declare class GraphQLError extends Error {
|
|
|
76
76
|
*/
|
|
77
77
|
readonly extensions: GraphQLErrorExtensions;
|
|
78
78
|
constructor(message: string, options?: GraphQLErrorOptions);
|
|
79
|
-
/**
|
|
80
|
-
* @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
|
|
81
|
-
*/
|
|
82
|
-
constructor(
|
|
83
|
-
message: string,
|
|
84
|
-
nodes?: ReadonlyArray<ASTNode> | ASTNode | null,
|
|
85
|
-
source?: Maybe<Source>,
|
|
86
|
-
positions?: Maybe<ReadonlyArray<number>>,
|
|
87
|
-
path?: Maybe<ReadonlyArray<string | number>>,
|
|
88
|
-
originalError?: Maybe<
|
|
89
|
-
Error & {
|
|
90
|
-
readonly extensions?: unknown;
|
|
91
|
-
}
|
|
92
|
-
>,
|
|
93
|
-
extensions?: Maybe<GraphQLErrorExtensions>,
|
|
94
|
-
);
|
|
95
79
|
get [Symbol.toStringTag](): string;
|
|
96
80
|
toString(): string;
|
|
97
81
|
toJSON(): GraphQLFormattedError;
|
|
@@ -126,17 +110,3 @@ export interface GraphQLFormattedError {
|
|
|
126
110
|
[key: string]: unknown;
|
|
127
111
|
};
|
|
128
112
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Prints a GraphQLError to a string, representing useful location information
|
|
131
|
-
* about the error's position in the source.
|
|
132
|
-
*
|
|
133
|
-
* @deprecated Please use `error.toString` instead. Will be removed in v17
|
|
134
|
-
*/
|
|
135
|
-
export declare function printError(error: GraphQLError): string;
|
|
136
|
-
/**
|
|
137
|
-
* Given a GraphQLError, format it according to the rules described by the
|
|
138
|
-
* Response Format, Errors section of the GraphQL Specification.
|
|
139
|
-
*
|
|
140
|
-
* @deprecated Please use `error.toJSON` instead. Will be removed in v17
|
|
141
|
-
*/
|
|
142
|
-
export declare function formatError(error: GraphQLError): GraphQLFormattedError;
|
package/error/GraphQLError.js
CHANGED
|
@@ -1,180 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.formatError = formatError;
|
|
8
|
-
exports.printError = printError;
|
|
9
|
-
|
|
10
|
-
var _isObjectLike = require('../jsutils/isObjectLike.js');
|
|
11
|
-
|
|
12
|
-
var _location = require('../language/location.js');
|
|
13
|
-
|
|
14
|
-
var _printLocation = require('../language/printLocation.js');
|
|
15
|
-
|
|
16
|
-
function toNormalizedOptions(args) {
|
|
17
|
-
const firstArg = args[0];
|
|
18
|
-
|
|
19
|
-
if (firstArg == null || 'kind' in firstArg || 'length' in firstArg) {
|
|
20
|
-
return {
|
|
21
|
-
nodes: firstArg,
|
|
22
|
-
source: args[1],
|
|
23
|
-
positions: args[2],
|
|
24
|
-
path: args[3],
|
|
25
|
-
originalError: args[4],
|
|
26
|
-
extensions: args[5],
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return firstArg;
|
|
31
|
-
}
|
|
1
|
+
import { isObjectLike } from '../jsutils/isObjectLike.js';
|
|
2
|
+
import { getLocation } from '../language/location.js';
|
|
3
|
+
import {
|
|
4
|
+
printLocation,
|
|
5
|
+
printSourceLocation,
|
|
6
|
+
} from '../language/printLocation.js';
|
|
32
7
|
/**
|
|
33
8
|
* A GraphQLError describes an Error found during the parse, validate, or
|
|
34
9
|
* execute phases of performing a GraphQL operation. In addition to a message
|
|
35
10
|
* and stack trace, it also includes information about the locations in a
|
|
36
11
|
* GraphQL document and/or execution result that correspond to the Error.
|
|
37
12
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* An array of `{ line, column }` locations within the source GraphQL document
|
|
42
|
-
* which correspond to this error.
|
|
43
|
-
*
|
|
44
|
-
* Errors during validation often contain multiple locations, for example to
|
|
45
|
-
* point out two things with the same name. Errors during execution include a
|
|
46
|
-
* single location, the field which produced the error.
|
|
47
|
-
*
|
|
48
|
-
* Enumerable, and appears in the result of JSON.stringify().
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* An array describing the JSON-path into the execution response which
|
|
53
|
-
* corresponds to this error. Only included for errors during execution.
|
|
54
|
-
*
|
|
55
|
-
* Enumerable, and appears in the result of JSON.stringify().
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* An array of GraphQL AST Nodes corresponding to this error.
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The source GraphQL document for the first location of this error.
|
|
64
|
-
*
|
|
65
|
-
* Note that if this Error represents more than one node, the source may not
|
|
66
|
-
* represent nodes after the first node.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* An array of character offsets within the source GraphQL document
|
|
71
|
-
* which correspond to this error.
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* The original error thrown from a field resolver during execution.
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Extension fields to add to the formatted error.
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.
|
|
84
|
-
*/
|
|
85
|
-
constructor(message, ...rawArgs) {
|
|
86
|
-
var _this$nodes, _nodeLocations$, _ref;
|
|
87
|
-
|
|
13
|
+
export class GraphQLError extends Error {
|
|
14
|
+
constructor(message, options = {}) {
|
|
88
15
|
const { nodes, source, positions, path, originalError, extensions } =
|
|
89
|
-
|
|
16
|
+
options;
|
|
90
17
|
super(message);
|
|
91
18
|
this.name = 'GraphQLError';
|
|
92
|
-
this.path = path
|
|
93
|
-
this.originalError =
|
|
94
|
-
|
|
95
|
-
? originalError
|
|
96
|
-
: undefined; // Compute list of blame nodes.
|
|
97
|
-
|
|
19
|
+
this.path = path ?? undefined;
|
|
20
|
+
this.originalError = originalError ?? undefined;
|
|
21
|
+
// Compute list of blame nodes.
|
|
98
22
|
this.nodes = undefinedIfEmpty(
|
|
99
23
|
Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined,
|
|
100
24
|
);
|
|
101
25
|
const nodeLocations = undefinedIfEmpty(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this.source =
|
|
108
|
-
source !== null && source !== void 0
|
|
109
|
-
? source
|
|
110
|
-
: nodeLocations === null || nodeLocations === void 0
|
|
111
|
-
? void 0
|
|
112
|
-
: (_nodeLocations$ = nodeLocations[0]) === null ||
|
|
113
|
-
_nodeLocations$ === void 0
|
|
114
|
-
? void 0
|
|
115
|
-
: _nodeLocations$.source;
|
|
116
|
-
this.positions =
|
|
117
|
-
positions !== null && positions !== void 0
|
|
118
|
-
? positions
|
|
119
|
-
: nodeLocations === null || nodeLocations === void 0
|
|
120
|
-
? void 0
|
|
121
|
-
: nodeLocations.map((loc) => loc.start);
|
|
26
|
+
this.nodes?.map((node) => node.loc).filter((loc) => loc != null),
|
|
27
|
+
);
|
|
28
|
+
// Compute locations in the source for the given nodes/positions.
|
|
29
|
+
this.source = source ?? nodeLocations?.[0]?.source;
|
|
30
|
+
this.positions = positions ?? nodeLocations?.map((loc) => loc.start);
|
|
122
31
|
this.locations =
|
|
123
32
|
positions && source
|
|
124
|
-
? positions.map((pos) =>
|
|
125
|
-
: nodeLocations
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
(0, _location.getLocation)(loc.source, loc.start),
|
|
129
|
-
);
|
|
130
|
-
const originalExtensions = (0, _isObjectLike.isObjectLike)(
|
|
131
|
-
originalError === null || originalError === void 0
|
|
132
|
-
? void 0
|
|
133
|
-
: originalError.extensions,
|
|
134
|
-
)
|
|
135
|
-
? originalError === null || originalError === void 0
|
|
136
|
-
? void 0
|
|
137
|
-
: originalError.extensions
|
|
33
|
+
? positions.map((pos) => getLocation(source, pos))
|
|
34
|
+
: nodeLocations?.map((loc) => getLocation(loc.source, loc.start));
|
|
35
|
+
const originalExtensions = isObjectLike(originalError?.extensions)
|
|
36
|
+
? originalError?.extensions
|
|
138
37
|
: undefined;
|
|
139
|
-
this.extensions =
|
|
140
|
-
|
|
141
|
-
extensions !== null && extensions !== void 0
|
|
142
|
-
? extensions
|
|
143
|
-
: originalExtensions) !== null && _ref !== void 0
|
|
144
|
-
? _ref
|
|
145
|
-
: Object.create(null); // Only properties prescribed by the spec should be enumerable.
|
|
38
|
+
this.extensions = extensions ?? originalExtensions ?? Object.create(null);
|
|
39
|
+
// Only properties prescribed by the spec should be enumerable.
|
|
146
40
|
// Keep the rest as non-enumerable.
|
|
147
|
-
|
|
148
41
|
Object.defineProperties(this, {
|
|
149
42
|
message: {
|
|
150
43
|
writable: true,
|
|
151
44
|
enumerable: true,
|
|
152
45
|
},
|
|
153
|
-
name: {
|
|
154
|
-
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
enumerable: false,
|
|
161
|
-
},
|
|
162
|
-
positions: {
|
|
163
|
-
enumerable: false,
|
|
164
|
-
},
|
|
165
|
-
originalError: {
|
|
166
|
-
enumerable: false,
|
|
167
|
-
},
|
|
168
|
-
}); // Include (non-enumerable) stack trace.
|
|
169
|
-
|
|
46
|
+
name: { enumerable: false },
|
|
47
|
+
nodes: { enumerable: false },
|
|
48
|
+
source: { enumerable: false },
|
|
49
|
+
positions: { enumerable: false },
|
|
50
|
+
originalError: { enumerable: false },
|
|
51
|
+
});
|
|
52
|
+
// Include (non-enumerable) stack trace.
|
|
170
53
|
/* c8 ignore start */
|
|
171
54
|
// FIXME: https://github.com/graphql/graphql-js/issues/2317
|
|
172
|
-
|
|
173
|
-
if (
|
|
174
|
-
originalError !== null &&
|
|
175
|
-
originalError !== void 0 &&
|
|
176
|
-
originalError.stack
|
|
177
|
-
) {
|
|
55
|
+
if (originalError?.stack) {
|
|
178
56
|
Object.defineProperty(this, 'stack', {
|
|
179
57
|
value: originalError.stack,
|
|
180
58
|
writable: true,
|
|
@@ -191,77 +69,40 @@ class GraphQLError extends Error {
|
|
|
191
69
|
}
|
|
192
70
|
/* c8 ignore stop */
|
|
193
71
|
}
|
|
194
|
-
|
|
195
72
|
get [Symbol.toStringTag]() {
|
|
196
73
|
return 'GraphQLError';
|
|
197
74
|
}
|
|
198
|
-
|
|
199
75
|
toString() {
|
|
200
76
|
let output = this.message;
|
|
201
|
-
|
|
202
77
|
if (this.nodes) {
|
|
203
78
|
for (const node of this.nodes) {
|
|
204
79
|
if (node.loc) {
|
|
205
|
-
output += '\n\n' +
|
|
80
|
+
output += '\n\n' + printLocation(node.loc);
|
|
206
81
|
}
|
|
207
82
|
}
|
|
208
83
|
} else if (this.source && this.locations) {
|
|
209
84
|
for (const location of this.locations) {
|
|
210
|
-
output +=
|
|
211
|
-
'\n\n' +
|
|
212
|
-
(0, _printLocation.printSourceLocation)(this.source, location);
|
|
85
|
+
output += '\n\n' + printSourceLocation(this.source, location);
|
|
213
86
|
}
|
|
214
87
|
}
|
|
215
|
-
|
|
216
88
|
return output;
|
|
217
89
|
}
|
|
218
|
-
|
|
219
90
|
toJSON() {
|
|
220
91
|
const formattedError = {
|
|
221
92
|
message: this.message,
|
|
222
93
|
};
|
|
223
|
-
|
|
224
94
|
if (this.locations != null) {
|
|
225
95
|
formattedError.locations = this.locations;
|
|
226
96
|
}
|
|
227
|
-
|
|
228
97
|
if (this.path != null) {
|
|
229
98
|
formattedError.path = this.path;
|
|
230
99
|
}
|
|
231
|
-
|
|
232
100
|
if (this.extensions != null && Object.keys(this.extensions).length > 0) {
|
|
233
101
|
formattedError.extensions = this.extensions;
|
|
234
102
|
}
|
|
235
|
-
|
|
236
103
|
return formattedError;
|
|
237
104
|
}
|
|
238
105
|
}
|
|
239
|
-
|
|
240
|
-
exports.GraphQLError = GraphQLError;
|
|
241
|
-
|
|
242
106
|
function undefinedIfEmpty(array) {
|
|
243
107
|
return array === undefined || array.length === 0 ? undefined : array;
|
|
244
108
|
}
|
|
245
|
-
/**
|
|
246
|
-
* See: https://spec.graphql.org/draft/#sec-Errors
|
|
247
|
-
*/
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Prints a GraphQLError to a string, representing useful location information
|
|
251
|
-
* about the error's position in the source.
|
|
252
|
-
*
|
|
253
|
-
* @deprecated Please use `error.toString` instead. Will be removed in v17
|
|
254
|
-
*/
|
|
255
|
-
function printError(error) {
|
|
256
|
-
return error.toString();
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Given a GraphQLError, format it according to the rules described by the
|
|
260
|
-
* Response Format, Errors section of the GraphQL Specification.
|
|
261
|
-
*
|
|
262
|
-
* @deprecated Please use `error.toJSON` instead. Will be removed in v17
|
|
263
|
-
*/
|
|
264
|
-
|
|
265
|
-
function formatError(error) {
|
|
266
|
-
return error.toJSON();
|
|
267
|
-
}
|
package/error/index.d.ts
CHANGED
package/error/index.js
CHANGED
|
@@ -1,41 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true,
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, 'GraphQLError', {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _GraphQLError.GraphQLError;
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, 'formatError', {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _GraphQLError.formatError;
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, 'locatedError', {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _locatedError.locatedError;
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, 'printError', {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _GraphQLError.printError;
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, 'syntaxError', {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _syntaxError.syntaxError;
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
var _GraphQLError = require('./GraphQLError.js');
|
|
38
|
-
|
|
39
|
-
var _syntaxError = require('./syntaxError.js');
|
|
40
|
-
|
|
41
|
-
var _locatedError = require('./locatedError.js');
|
|
1
|
+
export { GraphQLError } from './GraphQLError.js';
|
|
2
|
+
export { syntaxError } from './syntaxError.js';
|
|
3
|
+
export { locatedError } from './locatedError.js';
|
package/error/locatedError.js
CHANGED
|
@@ -1,40 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true,
|
|
5
|
-
});
|
|
6
|
-
exports.locatedError = locatedError;
|
|
7
|
-
|
|
8
|
-
var _toError = require('../jsutils/toError.js');
|
|
9
|
-
|
|
10
|
-
var _GraphQLError = require('./GraphQLError.js');
|
|
11
|
-
|
|
1
|
+
import { toError } from '../jsutils/toError.js';
|
|
2
|
+
import { GraphQLError } from './GraphQLError.js';
|
|
12
3
|
/**
|
|
13
4
|
* Given an arbitrary value, presumably thrown while attempting to execute a
|
|
14
5
|
* GraphQL operation, produce a new GraphQLError aware of the location in the
|
|
15
6
|
* document responsible for the original Error.
|
|
16
7
|
*/
|
|
17
|
-
function locatedError(rawOriginalError, nodes, path) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const originalError = (0, _toError.toError)(rawOriginalError); // Note: this uses a brand-check to support GraphQL errors originating from other contexts.
|
|
21
|
-
|
|
8
|
+
export function locatedError(rawOriginalError, nodes, path) {
|
|
9
|
+
const originalError = toError(rawOriginalError);
|
|
10
|
+
// Note: this uses a brand-check to support GraphQL errors originating from other contexts.
|
|
22
11
|
if (isLocatedGraphQLError(originalError)) {
|
|
23
12
|
return originalError;
|
|
24
13
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
nodes:
|
|
28
|
-
(_nodes = originalError.nodes) !== null && _nodes !== void 0
|
|
29
|
-
? _nodes
|
|
30
|
-
: nodes,
|
|
14
|
+
return new GraphQLError(originalError.message, {
|
|
15
|
+
nodes: originalError.nodes ?? nodes,
|
|
31
16
|
source: originalError.source,
|
|
32
17
|
positions: originalError.positions,
|
|
33
18
|
path,
|
|
34
19
|
originalError,
|
|
35
20
|
});
|
|
36
21
|
}
|
|
37
|
-
|
|
38
22
|
function isLocatedGraphQLError(error) {
|
|
39
23
|
return Array.isArray(error.path);
|
|
40
24
|
}
|
package/error/syntaxError.js
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', {
|
|
4
|
-
value: true,
|
|
5
|
-
});
|
|
6
|
-
exports.syntaxError = syntaxError;
|
|
7
|
-
|
|
8
|
-
var _GraphQLError = require('./GraphQLError.js');
|
|
9
|
-
|
|
1
|
+
import { GraphQLError } from './GraphQLError.js';
|
|
10
2
|
/**
|
|
11
3
|
* Produces a GraphQLError representing a syntax error, containing useful
|
|
12
4
|
* descriptive information about the syntax error's position in the source.
|
|
13
5
|
*/
|
|
14
|
-
function syntaxError(source, position, description) {
|
|
15
|
-
return new
|
|
6
|
+
export function syntaxError(source, position, description) {
|
|
7
|
+
return new GraphQLError(`Syntax Error: ${description}`, {
|
|
16
8
|
source,
|
|
17
9
|
positions: [position],
|
|
18
10
|
});
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _definition = require('../type/definition.js');
|
|
12
|
-
|
|
13
|
-
var _directives = require('../type/directives.js');
|
|
14
|
-
|
|
15
|
-
var _typeFromAST = require('../utilities/typeFromAST.js');
|
|
16
|
-
|
|
17
|
-
var _values = require('./values.js');
|
|
18
|
-
|
|
1
|
+
import { AccumulatorMap } from '../jsutils/AccumulatorMap.js';
|
|
2
|
+
import { Kind } from '../language/kinds.js';
|
|
3
|
+
import { isAbstractType } from '../type/definition.js';
|
|
4
|
+
import {
|
|
5
|
+
GraphQLIncludeDirective,
|
|
6
|
+
GraphQLSkipDirective,
|
|
7
|
+
} from '../type/directives.js';
|
|
8
|
+
import { typeFromAST } from '../utilities/typeFromAST.js';
|
|
9
|
+
import { getDirectiveValues } from './values.js';
|
|
19
10
|
/**
|
|
20
11
|
* Given a selectionSet, collects all of the fields and returns them.
|
|
21
12
|
*
|
|
@@ -25,14 +16,14 @@ var _values = require('./values.js');
|
|
|
25
16
|
*
|
|
26
17
|
* @internal
|
|
27
18
|
*/
|
|
28
|
-
function collectFields(
|
|
19
|
+
export function collectFields(
|
|
29
20
|
schema,
|
|
30
21
|
fragments,
|
|
31
22
|
variableValues,
|
|
32
23
|
runtimeType,
|
|
33
24
|
selectionSet,
|
|
34
25
|
) {
|
|
35
|
-
const fields = new
|
|
26
|
+
const fields = new AccumulatorMap();
|
|
36
27
|
collectFieldsImpl(
|
|
37
28
|
schema,
|
|
38
29
|
fragments,
|
|
@@ -54,17 +45,15 @@ function collectFields(
|
|
|
54
45
|
*
|
|
55
46
|
* @internal
|
|
56
47
|
*/
|
|
57
|
-
|
|
58
|
-
function collectSubfields(
|
|
48
|
+
export function collectSubfields(
|
|
59
49
|
schema,
|
|
60
50
|
fragments,
|
|
61
51
|
variableValues,
|
|
62
52
|
returnType,
|
|
63
53
|
fieldNodes,
|
|
64
54
|
) {
|
|
65
|
-
const subFieldNodes = new
|
|
55
|
+
const subFieldNodes = new AccumulatorMap();
|
|
66
56
|
const visitedFragmentNames = new Set();
|
|
67
|
-
|
|
68
57
|
for (const node of fieldNodes) {
|
|
69
58
|
if (node.selectionSet) {
|
|
70
59
|
collectFieldsImpl(
|
|
@@ -78,10 +67,8 @@ function collectSubfields(
|
|
|
78
67
|
);
|
|
79
68
|
}
|
|
80
69
|
}
|
|
81
|
-
|
|
82
70
|
return subFieldNodes;
|
|
83
71
|
}
|
|
84
|
-
|
|
85
72
|
function collectFieldsImpl(
|
|
86
73
|
schema,
|
|
87
74
|
fragments,
|
|
@@ -93,31 +80,20 @@ function collectFieldsImpl(
|
|
|
93
80
|
) {
|
|
94
81
|
for (const selection of selectionSet.selections) {
|
|
95
82
|
switch (selection.kind) {
|
|
96
|
-
case
|
|
83
|
+
case Kind.FIELD: {
|
|
97
84
|
if (!shouldIncludeNode(variableValues, selection)) {
|
|
98
85
|
continue;
|
|
99
86
|
}
|
|
100
|
-
|
|
101
|
-
const name = getFieldEntryKey(selection);
|
|
102
|
-
const fieldList = fields.get(name);
|
|
103
|
-
|
|
104
|
-
if (fieldList !== undefined) {
|
|
105
|
-
fieldList.push(selection);
|
|
106
|
-
} else {
|
|
107
|
-
fields.set(name, [selection]);
|
|
108
|
-
}
|
|
109
|
-
|
|
87
|
+
fields.add(getFieldEntryKey(selection), selection);
|
|
110
88
|
break;
|
|
111
89
|
}
|
|
112
|
-
|
|
113
|
-
case _kinds.Kind.INLINE_FRAGMENT: {
|
|
90
|
+
case Kind.INLINE_FRAGMENT: {
|
|
114
91
|
if (
|
|
115
92
|
!shouldIncludeNode(variableValues, selection) ||
|
|
116
93
|
!doesFragmentConditionMatch(schema, selection, runtimeType)
|
|
117
94
|
) {
|
|
118
95
|
continue;
|
|
119
96
|
}
|
|
120
|
-
|
|
121
97
|
collectFieldsImpl(
|
|
122
98
|
schema,
|
|
123
99
|
fragments,
|
|
@@ -129,27 +105,22 @@ function collectFieldsImpl(
|
|
|
129
105
|
);
|
|
130
106
|
break;
|
|
131
107
|
}
|
|
132
|
-
|
|
133
|
-
case _kinds.Kind.FRAGMENT_SPREAD: {
|
|
108
|
+
case Kind.FRAGMENT_SPREAD: {
|
|
134
109
|
const fragName = selection.name.value;
|
|
135
|
-
|
|
136
110
|
if (
|
|
137
111
|
visitedFragmentNames.has(fragName) ||
|
|
138
112
|
!shouldIncludeNode(variableValues, selection)
|
|
139
113
|
) {
|
|
140
114
|
continue;
|
|
141
115
|
}
|
|
142
|
-
|
|
143
116
|
visitedFragmentNames.add(fragName);
|
|
144
117
|
const fragment = fragments[fragName];
|
|
145
|
-
|
|
146
118
|
if (
|
|
147
119
|
!fragment ||
|
|
148
120
|
!doesFragmentConditionMatch(schema, fragment, runtimeType)
|
|
149
121
|
) {
|
|
150
122
|
continue;
|
|
151
123
|
}
|
|
152
|
-
|
|
153
124
|
collectFieldsImpl(
|
|
154
125
|
schema,
|
|
155
126
|
fragments,
|
|
@@ -168,62 +139,41 @@ function collectFieldsImpl(
|
|
|
168
139
|
* Determines if a field should be included based on the `@include` and `@skip`
|
|
169
140
|
* directives, where `@skip` has higher precedence than `@include`.
|
|
170
141
|
*/
|
|
171
|
-
|
|
172
142
|
function shouldIncludeNode(variableValues, node) {
|
|
173
|
-
const skip = (
|
|
174
|
-
|
|
175
|
-
node,
|
|
176
|
-
variableValues,
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
if ((skip === null || skip === void 0 ? void 0 : skip.if) === true) {
|
|
143
|
+
const skip = getDirectiveValues(GraphQLSkipDirective, node, variableValues);
|
|
144
|
+
if (skip?.if === true) {
|
|
180
145
|
return false;
|
|
181
146
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
_directives.GraphQLIncludeDirective,
|
|
147
|
+
const include = getDirectiveValues(
|
|
148
|
+
GraphQLIncludeDirective,
|
|
185
149
|
node,
|
|
186
150
|
variableValues,
|
|
187
151
|
);
|
|
188
|
-
|
|
189
|
-
if (
|
|
190
|
-
(include === null || include === void 0 ? void 0 : include.if) === false
|
|
191
|
-
) {
|
|
152
|
+
if (include?.if === false) {
|
|
192
153
|
return false;
|
|
193
154
|
}
|
|
194
|
-
|
|
195
155
|
return true;
|
|
196
156
|
}
|
|
197
157
|
/**
|
|
198
158
|
* Determines if a fragment is applicable to the given type.
|
|
199
159
|
*/
|
|
200
|
-
|
|
201
160
|
function doesFragmentConditionMatch(schema, fragment, type) {
|
|
202
161
|
const typeConditionNode = fragment.typeCondition;
|
|
203
|
-
|
|
204
162
|
if (!typeConditionNode) {
|
|
205
163
|
return true;
|
|
206
164
|
}
|
|
207
|
-
|
|
208
|
-
const conditionalType = (0, _typeFromAST.typeFromAST)(
|
|
209
|
-
schema,
|
|
210
|
-
typeConditionNode,
|
|
211
|
-
);
|
|
212
|
-
|
|
165
|
+
const conditionalType = typeFromAST(schema, typeConditionNode);
|
|
213
166
|
if (conditionalType === type) {
|
|
214
167
|
return true;
|
|
215
168
|
}
|
|
216
|
-
|
|
217
|
-
if ((0, _definition.isAbstractType)(conditionalType)) {
|
|
169
|
+
if (isAbstractType(conditionalType)) {
|
|
218
170
|
return schema.isSubType(conditionalType, type);
|
|
219
171
|
}
|
|
220
|
-
|
|
221
172
|
return false;
|
|
222
173
|
}
|
|
223
174
|
/**
|
|
224
175
|
* Implements the logic to compute the key of a given field's entry
|
|
225
176
|
*/
|
|
226
|
-
|
|
227
177
|
function getFieldEntryKey(node) {
|
|
228
178
|
return node.alias ? node.alias.value : node.name.value;
|
|
229
179
|
}
|