graphql 14.4.2 → 14.5.3
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/README.md +5 -10
- package/error/GraphQLError.d.ts +87 -0
- package/error/GraphQLError.js +7 -45
- package/error/GraphQLError.js.flow +1 -0
- package/error/GraphQLError.mjs +7 -45
- package/error/formatError.d.ts +39 -0
- package/error/formatError.js +5 -2
- package/error/formatError.js.flow +27 -3
- package/error/formatError.mjs +5 -2
- package/error/index.d.ts +4 -0
- package/error/locatedError.d.ts +13 -0
- package/error/locatedError.js.flow +2 -1
- package/error/locatedError.mjs +1 -1
- package/error/syntaxError.d.ts +12 -0
- package/error/syntaxError.js.flow +1 -0
- package/execution/execute.d.ts +190 -0
- package/execution/execute.js +55 -89
- package/execution/execute.js.flow +95 -133
- package/execution/execute.mjs +75 -80
- package/execution/index.d.ts +11 -0
- package/execution/index.js +8 -6
- package/execution/index.js.flow +3 -6
- package/execution/index.mjs +2 -1
- package/execution/values.d.ts +68 -0
- package/execution/values.js +119 -128
- package/execution/values.js.flow +150 -127
- package/execution/values.mjs +117 -125
- package/graphql.d.ts +88 -0
- package/graphql.js +5 -5
- package/graphql.js.flow +9 -5
- package/graphql.mjs +41 -1
- package/index.d.ts +446 -0
- package/index.js +6 -0
- package/index.js.flow +3 -1
- package/index.mjs +2 -1
- package/jsutils/ObjMap.js.flow +6 -0
- package/jsutils/Path.d.ts +14 -0
- package/jsutils/Path.js +33 -0
- package/jsutils/Path.js.flow +26 -0
- package/jsutils/Path.mjs +24 -0
- package/jsutils/PromiseOrValue.d.ts +1 -0
- package/jsutils/dedent.js +6 -24
- package/jsutils/dedent.mjs +6 -24
- package/jsutils/defineToStringTag.js.flow +1 -1
- package/jsutils/devAssert.js +14 -0
- package/jsutils/devAssert.js.flow +8 -0
- package/jsutils/devAssert.mjs +7 -0
- package/jsutils/inspect.js +1 -1
- package/jsutils/inspect.js.flow +1 -1
- package/jsutils/inspect.mjs +1 -1
- package/jsutils/invariant.js +1 -2
- package/jsutils/invariant.js.flow +2 -3
- package/jsutils/invariant.mjs +1 -2
- package/jsutils/mapValue.js +6 -24
- package/jsutils/mapValue.js.flow +2 -1
- package/jsutils/mapValue.mjs +6 -24
- package/jsutils/printPathArray.js +15 -0
- package/jsutils/printPathArray.js.flow +14 -0
- package/jsutils/printPathArray.mjs +8 -0
- package/jsutils/suggestionList.js +14 -34
- package/jsutils/suggestionList.js.flow +4 -6
- package/jsutils/suggestionList.mjs +14 -34
- package/jsutils/toObjMap.js +28 -0
- package/jsutils/toObjMap.js.flow +26 -0
- package/jsutils/toObjMap.mjs +18 -0
- package/language/ast.d.ts +573 -0
- package/language/blockString.d.ts +21 -0
- package/language/directiveLocation.d.ts +35 -0
- package/language/index.d.ts +96 -0
- package/language/kinds.d.ts +77 -0
- package/language/lexer.d.ts +60 -0
- package/language/lexer.js +2 -12
- package/language/lexer.js.flow +6 -12
- package/language/lexer.mjs +1 -9
- package/language/location.d.ts +15 -0
- package/language/parser.d.ts +89 -0
- package/language/parser.js +1329 -1302
- package/language/parser.js.flow +1289 -1298
- package/language/parser.mjs +1326 -1297
- package/language/predicates.d.ts +36 -0
- package/language/predicates.js.flow +1 -1
- package/language/printLocation.d.ts +16 -0
- package/language/printLocation.js.flow +1 -1
- package/language/printer.d.ts +7 -0
- package/language/printer.js.flow +1 -1
- package/language/source.d.ts +19 -0
- package/language/source.js +3 -3
- package/language/source.js.flow +3 -3
- package/language/source.mjs +3 -3
- package/language/tokenKind.d.ts +35 -0
- package/language/visitor.d.ts +264 -0
- package/language/visitor.js +2 -2
- package/language/visitor.js.flow +3 -1
- package/language/visitor.mjs +2 -2
- package/package.json +1 -1
- package/polyfills/find.js +2 -2
- package/polyfills/find.js.flow +1 -2
- package/polyfills/find.mjs +2 -2
- package/polyfills/flatMap.js +3 -3
- package/polyfills/flatMap.js.flow +2 -3
- package/polyfills/flatMap.mjs +3 -3
- package/subscription/asyncIteratorReject.d.ts +6 -0
- package/subscription/index.d.ts +5 -0
- package/subscription/mapAsyncIterator.d.ts +9 -0
- package/subscription/mapAsyncIterator.js.flow +1 -0
- package/subscription/subscribe.d.ts +86 -0
- package/subscription/subscribe.js +29 -10
- package/subscription/subscribe.js.flow +45 -24
- package/subscription/subscribe.mjs +27 -9
- package/tsutils/Maybe.d.ts +4 -0
- package/type/definition.d.ts +805 -0
- package/type/definition.js +154 -70
- package/type/definition.js.flow +217 -160
- package/type/definition.mjs +149 -66
- package/type/directives.d.ts +72 -0
- package/type/directives.js +20 -12
- package/type/directives.js.flow +34 -19
- package/type/directives.mjs +17 -10
- package/type/index.d.ts +155 -0
- package/type/index.js.flow +2 -2
- package/type/introspection.d.ts +40 -0
- package/type/introspection.js +24 -10
- package/type/introspection.js.flow +29 -8
- package/type/introspection.mjs +23 -10
- package/type/scalars.d.ts +11 -0
- package/type/scalars.js +2 -2
- package/type/scalars.js.flow +4 -1
- package/type/scalars.mjs +2 -2
- package/type/schema.d.ts +108 -0
- package/type/schema.js +74 -151
- package/type/schema.js.flow +75 -73
- package/type/schema.mjs +75 -149
- package/type/validate.d.ts +19 -0
- package/type/validate.js +227 -486
- package/type/validate.js.flow +13 -8
- package/type/validate.mjs +218 -477
- package/utilities/TypeInfo.d.ts +49 -0
- package/utilities/TypeInfo.js.flow +9 -6
- package/utilities/assertValidName.d.ts +15 -0
- package/utilities/assertValidName.js +3 -3
- package/utilities/assertValidName.js.flow +3 -2
- package/utilities/assertValidName.mjs +2 -2
- package/utilities/astFromValue.d.ts +25 -0
- package/utilities/astFromValue.js +22 -38
- package/utilities/astFromValue.js.flow +7 -4
- package/utilities/astFromValue.mjs +19 -36
- package/utilities/buildASTSchema.d.ts +114 -0
- package/utilities/buildASTSchema.js +37 -68
- package/utilities/buildASTSchema.js.flow +32 -30
- package/utilities/buildASTSchema.mjs +32 -64
- package/utilities/buildClientSchema.d.ts +21 -0
- package/utilities/buildClientSchema.js +23 -15
- package/utilities/buildClientSchema.js.flow +17 -16
- package/utilities/buildClientSchema.mjs +20 -12
- package/utilities/coerceInputValue.d.ts +17 -0
- package/utilities/coerceInputValue.js +161 -0
- package/utilities/coerceInputValue.js.flow +214 -0
- package/utilities/coerceInputValue.mjs +142 -0
- package/utilities/coerceValue.d.ts +23 -0
- package/utilities/coerceValue.js +21 -199
- package/utilities/coerceValue.js.flow +31 -223
- package/utilities/coerceValue.mjs +20 -195
- package/utilities/concatAST.d.ts +8 -0
- package/utilities/concatAST.js.flow +1 -0
- package/utilities/extendSchema.d.ts +45 -0
- package/utilities/extendSchema.js +64 -131
- package/utilities/extendSchema.js.flow +27 -24
- package/utilities/extendSchema.mjs +61 -129
- package/utilities/findBreakingChanges.d.ts +64 -0
- package/utilities/findBreakingChanges.js +194 -619
- package/utilities/findBreakingChanges.js.flow +8 -5
- package/utilities/findBreakingChanges.mjs +194 -619
- package/utilities/findDeprecatedUsages.d.ts +13 -0
- package/utilities/findDeprecatedUsages.js.flow +4 -1
- package/utilities/getOperationAST.d.ts +12 -0
- package/utilities/getOperationAST.js +13 -31
- package/utilities/getOperationAST.mjs +13 -31
- package/utilities/getOperationRootType.d.ts +14 -0
- package/utilities/getOperationRootType.js.flow +2 -0
- package/utilities/index.d.ts +127 -0
- package/utilities/index.js +8 -0
- package/utilities/index.js.flow +4 -1
- package/utilities/index.mjs +3 -1
- package/utilities/introspectionFromSchema.d.ts +16 -0
- package/utilities/introspectionFromSchema.js +5 -3
- package/utilities/introspectionFromSchema.js.flow +4 -2
- package/utilities/introspectionFromSchema.mjs +4 -2
- package/utilities/introspectionQuery.d.ts +177 -0
- package/utilities/isValidJSValue.d.ts +8 -0
- package/utilities/isValidJSValue.js +1 -1
- package/utilities/isValidJSValue.js.flow +3 -2
- package/utilities/isValidJSValue.mjs +2 -2
- package/utilities/isValidLiteralValue.d.ts +15 -0
- package/utilities/isValidLiteralValue.js +4 -4
- package/utilities/isValidLiteralValue.js.flow +8 -4
- package/utilities/isValidLiteralValue.mjs +2 -2
- package/utilities/lexicographicSortSchema.d.ts +6 -0
- package/utilities/lexicographicSortSchema.js +11 -8
- package/utilities/lexicographicSortSchema.js.flow +5 -3
- package/utilities/lexicographicSortSchema.mjs +9 -7
- package/utilities/schemaPrinter.d.ts +30 -0
- package/utilities/schemaPrinter.js +15 -32
- package/utilities/schemaPrinter.js.flow +14 -10
- package/utilities/schemaPrinter.mjs +14 -32
- package/utilities/separateOperations.d.ts +11 -0
- package/utilities/separateOperations.js +6 -6
- package/utilities/separateOperations.js.flow +2 -1
- package/utilities/separateOperations.mjs +6 -6
- package/utilities/stripIgnoredCharacters.d.ts +55 -0
- package/utilities/stripIgnoredCharacters.js.flow +1 -0
- package/utilities/typeComparators.d.ts +32 -0
- package/utilities/typeComparators.js.flow +1 -1
- package/utilities/typeComparators.mjs +1 -1
- package/utilities/typeFromAST.d.ts +29 -0
- package/utilities/typeFromAST.js +5 -3
- package/utilities/typeFromAST.js.flow +5 -3
- package/utilities/typeFromAST.mjs +14 -3
- package/utilities/valueFromAST.d.ts +29 -0
- package/utilities/valueFromAST.js +40 -74
- package/utilities/valueFromAST.js.flow +7 -4
- package/utilities/valueFromAST.mjs +39 -74
- package/utilities/valueFromASTUntyped.d.ts +23 -0
- package/utilities/valueFromASTUntyped.js +4 -3
- package/utilities/valueFromASTUntyped.js.flow +3 -2
- package/utilities/valueFromASTUntyped.mjs +3 -3
- package/validation/ValidationContext.d.ts +96 -0
- package/validation/ValidationContext.js +38 -86
- package/validation/ValidationContext.js.flow +22 -7
- package/validation/ValidationContext.mjs +37 -85
- package/validation/index.d.ts +126 -0
- package/validation/rules/ExecutableDefinitions.d.ts +14 -0
- package/validation/rules/ExecutableDefinitions.js +4 -23
- package/validation/rules/ExecutableDefinitions.js.flow +4 -2
- package/validation/rules/ExecutableDefinitions.mjs +4 -23
- package/validation/rules/FieldsOnCorrectType.d.ts +17 -0
- package/validation/rules/FieldsOnCorrectType.js +21 -57
- package/validation/rules/FieldsOnCorrectType.js.flow +7 -3
- package/validation/rules/FieldsOnCorrectType.mjs +21 -57
- package/validation/rules/FragmentsOnCompositeTypes.d.ts +20 -0
- package/validation/rules/FragmentsOnCompositeTypes.js.flow +5 -1
- package/validation/rules/KnownArgumentNames.d.ts +28 -0
- package/validation/rules/KnownArgumentNames.js +26 -79
- package/validation/rules/KnownArgumentNames.js.flow +10 -6
- package/validation/rules/KnownArgumentNames.mjs +22 -75
- package/validation/rules/KnownDirectives.d.ts +19 -0
- package/validation/rules/KnownDirectives.js +12 -48
- package/validation/rules/KnownDirectives.js.flow +8 -5
- package/validation/rules/KnownDirectives.mjs +12 -48
- package/validation/rules/KnownFragmentNames.d.ts +12 -0
- package/validation/rules/KnownFragmentNames.js.flow +2 -1
- package/validation/rules/KnownTypeNames.d.ts +15 -0
- package/validation/rules/KnownTypeNames.js +6 -24
- package/validation/rules/KnownTypeNames.js.flow +10 -6
- package/validation/rules/KnownTypeNames.mjs +6 -24
- package/validation/rules/LoneAnonymousOperation.d.ts +14 -0
- package/validation/rules/LoneAnonymousOperation.js.flow +3 -1
- package/validation/rules/LoneSchemaDefinition.d.ts +13 -0
- package/validation/rules/LoneSchemaDefinition.js.flow +2 -1
- package/validation/rules/NoFragmentCycles.d.ts +9 -0
- package/validation/rules/NoFragmentCycles.js +17 -35
- package/validation/rules/NoFragmentCycles.js.flow +4 -2
- package/validation/rules/NoFragmentCycles.mjs +17 -35
- package/validation/rules/NoUndefinedVariables.d.ts +16 -0
- package/validation/rules/NoUndefinedVariables.js +6 -24
- package/validation/rules/NoUndefinedVariables.js.flow +2 -1
- package/validation/rules/NoUndefinedVariables.mjs +6 -24
- package/validation/rules/NoUnusedFragments.d.ts +12 -0
- package/validation/rules/NoUnusedFragments.js +7 -25
- package/validation/rules/NoUnusedFragments.js.flow +2 -1
- package/validation/rules/NoUnusedFragments.mjs +7 -25
- package/validation/rules/NoUnusedVariables.d.ts +16 -0
- package/validation/rules/NoUnusedVariables.js +6 -24
- package/validation/rules/NoUnusedVariables.js.flow +2 -1
- package/validation/rules/NoUnusedVariables.mjs +6 -24
- package/validation/rules/OverlappingFieldsCanBeMerged.d.ts +24 -0
- package/validation/rules/OverlappingFieldsCanBeMerged.js +27 -46
- package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +17 -8
- package/validation/rules/OverlappingFieldsCanBeMerged.mjs +25 -44
- package/validation/rules/PossibleFragmentSpreads.d.ts +22 -0
- package/validation/rules/PossibleFragmentSpreads.js +2 -2
- package/validation/rules/PossibleFragmentSpreads.js.flow +8 -3
- package/validation/rules/PossibleFragmentSpreads.mjs +2 -2
- package/validation/rules/PossibleTypeExtensions.d.ts +21 -0
- package/validation/rules/PossibleTypeExtensions.js +4 -22
- package/validation/rules/PossibleTypeExtensions.js.flow +6 -2
- package/validation/rules/PossibleTypeExtensions.mjs +4 -22
- package/validation/rules/ProvidedRequiredArguments.d.ts +29 -0
- package/validation/rules/ProvidedRequiredArguments.js +27 -79
- package/validation/rules/ProvidedRequiredArguments.js.flow +12 -8
- package/validation/rules/ProvidedRequiredArguments.mjs +25 -77
- package/validation/rules/ScalarLeafs.d.ts +20 -0
- package/validation/rules/ScalarLeafs.js.flow +6 -2
- package/validation/rules/SingleFieldSubscriptions.d.ts +14 -0
- package/validation/rules/SingleFieldSubscriptions.js.flow +4 -2
- package/validation/rules/UniqueArgumentNames.d.ts +12 -0
- package/validation/rules/UniqueArgumentNames.js.flow +2 -1
- package/validation/rules/UniqueDirectiveNames.d.ts +13 -0
- package/validation/rules/UniqueDirectiveNames.js.flow +2 -1
- package/validation/rules/UniqueDirectivesPerLocation.d.ts +14 -0
- package/validation/rules/UniqueDirectivesPerLocation.js +15 -69
- package/validation/rules/UniqueDirectivesPerLocation.js.flow +7 -4
- package/validation/rules/UniqueDirectivesPerLocation.mjs +15 -69
- package/validation/rules/UniqueEnumValueNames.d.ts +19 -0
- package/validation/rules/UniqueEnumValueNames.js +10 -28
- package/validation/rules/UniqueEnumValueNames.js.flow +2 -1
- package/validation/rules/UniqueEnumValueNames.mjs +10 -28
- package/validation/rules/UniqueFieldDefinitionNames.d.ts +21 -0
- package/validation/rules/UniqueFieldDefinitionNames.js +9 -27
- package/validation/rules/UniqueFieldDefinitionNames.js.flow +2 -1
- package/validation/rules/UniqueFieldDefinitionNames.mjs +9 -27
- package/validation/rules/UniqueFragmentNames.d.ts +11 -0
- package/validation/rules/UniqueFragmentNames.js.flow +2 -1
- package/validation/rules/UniqueInputFieldNames.d.ts +14 -0
- package/validation/rules/UniqueInputFieldNames.js.flow +2 -1
- package/validation/rules/UniqueOperationNames.d.ts +11 -0
- package/validation/rules/UniqueOperationNames.js.flow +2 -1
- package/validation/rules/UniqueOperationTypes.d.ts +13 -0
- package/validation/rules/UniqueOperationTypes.js +11 -30
- package/validation/rules/UniqueOperationTypes.js.flow +2 -1
- package/validation/rules/UniqueOperationTypes.mjs +10 -29
- package/validation/rules/UniqueTypeNames.d.ts +13 -0
- package/validation/rules/UniqueTypeNames.js.flow +3 -1
- package/validation/rules/UniqueVariableNames.d.ts +11 -0
- package/validation/rules/UniqueVariableNames.js.flow +4 -2
- package/validation/rules/ValuesOfCorrectType.d.ts +34 -0
- package/validation/rules/ValuesOfCorrectType.js +16 -34
- package/validation/rules/ValuesOfCorrectType.js.flow +11 -6
- package/validation/rules/ValuesOfCorrectType.mjs +12 -30
- package/validation/rules/VariablesAreInputTypes.d.ts +15 -0
- package/validation/rules/VariablesAreInputTypes.js.flow +6 -2
- package/validation/rules/VariablesInAllowedPosition.d.ts +15 -0
- package/validation/rules/VariablesInAllowedPosition.js +22 -40
- package/validation/rules/VariablesInAllowedPosition.js.flow +8 -3
- package/validation/rules/VariablesInAllowedPosition.mjs +18 -36
- package/validation/specifiedRules.d.ts +98 -0
- package/validation/validate.d.ts +56 -0
- package/validation/validate.js +35 -7
- package/validation/validate.js.flow +51 -9
- package/validation/validate.mjs +30 -7
- package/version.d.ts +14 -0
- package/version.js +3 -3
- package/version.js.flow +3 -3
- package/version.mjs +3 -3
package/README.md
CHANGED
|
@@ -11,7 +11,6 @@ https://graphql.org/graphql-js/.
|
|
|
11
11
|
|
|
12
12
|
Looking for help? Find resources [from the community](https://graphql.org/community/).
|
|
13
13
|
|
|
14
|
-
|
|
15
14
|
## Getting Started
|
|
16
15
|
|
|
17
16
|
An overview of GraphQL in general is available in the
|
|
@@ -47,7 +46,7 @@ import {
|
|
|
47
46
|
graphql,
|
|
48
47
|
GraphQLSchema,
|
|
49
48
|
GraphQLObjectType,
|
|
50
|
-
GraphQLString
|
|
49
|
+
GraphQLString,
|
|
51
50
|
} from 'graphql';
|
|
52
51
|
|
|
53
52
|
var schema = new GraphQLSchema({
|
|
@@ -58,10 +57,10 @@ var schema = new GraphQLSchema({
|
|
|
58
57
|
type: GraphQLString,
|
|
59
58
|
resolve() {
|
|
60
59
|
return 'world';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
})
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
65
64
|
});
|
|
66
65
|
```
|
|
67
66
|
|
|
@@ -76,13 +75,11 @@ Then, serve the result of a query against that type schema.
|
|
|
76
75
|
var query = '{ hello }';
|
|
77
76
|
|
|
78
77
|
graphql(schema, query).then(result => {
|
|
79
|
-
|
|
80
78
|
// Prints
|
|
81
79
|
// {
|
|
82
80
|
// data: { hello: "world" }
|
|
83
81
|
// }
|
|
84
82
|
console.log(result);
|
|
85
|
-
|
|
86
83
|
});
|
|
87
84
|
```
|
|
88
85
|
|
|
@@ -94,7 +91,6 @@ it, reporting errors otherwise.
|
|
|
94
91
|
var query = '{ boyhowdy }';
|
|
95
92
|
|
|
96
93
|
graphql(schema, query).then(result => {
|
|
97
|
-
|
|
98
94
|
// Prints
|
|
99
95
|
// {
|
|
100
96
|
// errors: [
|
|
@@ -103,7 +99,6 @@ graphql(schema, query).then(result => {
|
|
|
103
99
|
// ]
|
|
104
100
|
// }
|
|
105
101
|
console.log(result);
|
|
106
|
-
|
|
107
102
|
});
|
|
108
103
|
```
|
|
109
104
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import Maybe from '../tsutils/Maybe';
|
|
2
|
+
|
|
3
|
+
import { ASTNode } from '../language/ast';
|
|
4
|
+
import { Source } from '../language/source';
|
|
5
|
+
import { SourceLocation, getLocation } from '../language/location';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A GraphQLError describes an Error found during the parse, validate, or
|
|
9
|
+
* execute phases of performing a GraphQL operation. In addition to a message
|
|
10
|
+
* and stack trace, it also includes information about the locations in a
|
|
11
|
+
* GraphQL document and/or execution result that correspond to the Error.
|
|
12
|
+
*/
|
|
13
|
+
export class GraphQLError extends Error {
|
|
14
|
+
constructor(
|
|
15
|
+
message: string,
|
|
16
|
+
nodes?: ReadonlyArray<ASTNode> | ASTNode | undefined,
|
|
17
|
+
source?: Maybe<Source>,
|
|
18
|
+
positions?: Maybe<ReadonlyArray<number>>,
|
|
19
|
+
path?: Maybe<ReadonlyArray<string | number>>,
|
|
20
|
+
originalError?: Maybe<Error>,
|
|
21
|
+
extensions?: Maybe<{ [key: string]: any }>,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A message describing the Error for debugging purposes.
|
|
26
|
+
*
|
|
27
|
+
* Enumerable, and appears in the result of JSON.stringify().
|
|
28
|
+
*
|
|
29
|
+
* Note: should be treated as readonly, despite invariant usage.
|
|
30
|
+
*/
|
|
31
|
+
message: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* An array of { line, column } locations within the source GraphQL document
|
|
35
|
+
* which correspond to this error.
|
|
36
|
+
*
|
|
37
|
+
* Errors during validation often contain multiple locations, for example to
|
|
38
|
+
* point out two things with the same name. Errors during execution include a
|
|
39
|
+
* single location, the field which produced the error.
|
|
40
|
+
*
|
|
41
|
+
* Enumerable, and appears in the result of JSON.stringify().
|
|
42
|
+
*/
|
|
43
|
+
readonly locations: ReadonlyArray<SourceLocation> | undefined;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* An array describing the JSON-path into the execution response which
|
|
47
|
+
* corresponds to this error. Only included for errors during execution.
|
|
48
|
+
*
|
|
49
|
+
* Enumerable, and appears in the result of JSON.stringify().
|
|
50
|
+
*/
|
|
51
|
+
readonly path: ReadonlyArray<string | number> | undefined;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* An array of GraphQL AST Nodes corresponding to this error.
|
|
55
|
+
*/
|
|
56
|
+
readonly nodes: ReadonlyArray<ASTNode> | undefined;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The source GraphQL document corresponding to this error.
|
|
60
|
+
*
|
|
61
|
+
* Note that if this Error represents more than one node, the source may not
|
|
62
|
+
* represent nodes after the first node.
|
|
63
|
+
*/
|
|
64
|
+
readonly source: Source | undefined;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* An array of character offsets within the source GraphQL document
|
|
68
|
+
* which correspond to this error.
|
|
69
|
+
*/
|
|
70
|
+
readonly positions: ReadonlyArray<number> | undefined;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The original error thrown from a field resolver during execution.
|
|
74
|
+
*/
|
|
75
|
+
readonly originalError: Maybe<Error>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Extension fields to add to the formatted error.
|
|
79
|
+
*/
|
|
80
|
+
readonly extensions: { [key: string]: any } | undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Prints a GraphQLError to a string, representing useful location information
|
|
85
|
+
* about the error's position in the source.
|
|
86
|
+
*/
|
|
87
|
+
export function printError(error: GraphQLError): string;
|
package/error/GraphQLError.js
CHANGED
|
@@ -158,55 +158,17 @@ function printError(error) {
|
|
|
158
158
|
var output = error.message;
|
|
159
159
|
|
|
160
160
|
if (error.nodes) {
|
|
161
|
-
var
|
|
162
|
-
|
|
163
|
-
var _iteratorError = undefined;
|
|
161
|
+
for (var _i2 = 0, _error$nodes2 = error.nodes; _i2 < _error$nodes2.length; _i2++) {
|
|
162
|
+
var node = _error$nodes2[_i2];
|
|
164
163
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
var node = _step.value;
|
|
168
|
-
|
|
169
|
-
if (node.loc) {
|
|
170
|
-
output += '\n\n' + (0, _printLocation.printLocation)(node.loc);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
} catch (err) {
|
|
174
|
-
_didIteratorError = true;
|
|
175
|
-
_iteratorError = err;
|
|
176
|
-
} finally {
|
|
177
|
-
try {
|
|
178
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
179
|
-
_iterator.return();
|
|
180
|
-
}
|
|
181
|
-
} finally {
|
|
182
|
-
if (_didIteratorError) {
|
|
183
|
-
throw _iteratorError;
|
|
184
|
-
}
|
|
164
|
+
if (node.loc) {
|
|
165
|
+
output += '\n\n' + (0, _printLocation.printLocation)(node.loc);
|
|
185
166
|
}
|
|
186
167
|
}
|
|
187
168
|
} else if (error.source && error.locations) {
|
|
188
|
-
var
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
try {
|
|
193
|
-
for (var _iterator2 = error.locations[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
194
|
-
var location = _step2.value;
|
|
195
|
-
output += '\n\n' + (0, _printLocation.printSourceLocation)(error.source, location);
|
|
196
|
-
}
|
|
197
|
-
} catch (err) {
|
|
198
|
-
_didIteratorError2 = true;
|
|
199
|
-
_iteratorError2 = err;
|
|
200
|
-
} finally {
|
|
201
|
-
try {
|
|
202
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
203
|
-
_iterator2.return();
|
|
204
|
-
}
|
|
205
|
-
} finally {
|
|
206
|
-
if (_didIteratorError2) {
|
|
207
|
-
throw _iteratorError2;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
169
|
+
for (var _i4 = 0, _error$locations2 = error.locations; _i4 < _error$locations2.length; _i4++) {
|
|
170
|
+
var location = _error$locations2[_i4];
|
|
171
|
+
output += '\n\n' + (0, _printLocation.printSourceLocation)(error.source, location);
|
|
210
172
|
}
|
|
211
173
|
}
|
|
212
174
|
|
package/error/GraphQLError.mjs
CHANGED
|
@@ -151,55 +151,17 @@ export function printError(error) {
|
|
|
151
151
|
var output = error.message;
|
|
152
152
|
|
|
153
153
|
if (error.nodes) {
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
var _iteratorError = undefined;
|
|
154
|
+
for (var _i2 = 0, _error$nodes2 = error.nodes; _i2 < _error$nodes2.length; _i2++) {
|
|
155
|
+
var node = _error$nodes2[_i2];
|
|
157
156
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
var node = _step.value;
|
|
161
|
-
|
|
162
|
-
if (node.loc) {
|
|
163
|
-
output += '\n\n' + printLocation(node.loc);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
} catch (err) {
|
|
167
|
-
_didIteratorError = true;
|
|
168
|
-
_iteratorError = err;
|
|
169
|
-
} finally {
|
|
170
|
-
try {
|
|
171
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
172
|
-
_iterator.return();
|
|
173
|
-
}
|
|
174
|
-
} finally {
|
|
175
|
-
if (_didIteratorError) {
|
|
176
|
-
throw _iteratorError;
|
|
177
|
-
}
|
|
157
|
+
if (node.loc) {
|
|
158
|
+
output += '\n\n' + printLocation(node.loc);
|
|
178
159
|
}
|
|
179
160
|
}
|
|
180
161
|
} else if (error.source && error.locations) {
|
|
181
|
-
var
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
try {
|
|
186
|
-
for (var _iterator2 = error.locations[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
187
|
-
var location = _step2.value;
|
|
188
|
-
output += '\n\n' + printSourceLocation(error.source, location);
|
|
189
|
-
}
|
|
190
|
-
} catch (err) {
|
|
191
|
-
_didIteratorError2 = true;
|
|
192
|
-
_iteratorError2 = err;
|
|
193
|
-
} finally {
|
|
194
|
-
try {
|
|
195
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
196
|
-
_iterator2.return();
|
|
197
|
-
}
|
|
198
|
-
} finally {
|
|
199
|
-
if (_didIteratorError2) {
|
|
200
|
-
throw _iteratorError2;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
162
|
+
for (var _i4 = 0, _error$locations2 = error.locations; _i4 < _error$locations2.length; _i4++) {
|
|
163
|
+
var location = _error$locations2[_i4];
|
|
164
|
+
output += '\n\n' + printSourceLocation(error.source, location);
|
|
203
165
|
}
|
|
204
166
|
}
|
|
205
167
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SourceLocation } from '../language/location';
|
|
2
|
+
import { GraphQLError } from './GraphQLError';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Given a GraphQLError, format it according to the rules described by the
|
|
6
|
+
* Response Format, Errors section of the GraphQL Specification.
|
|
7
|
+
*/
|
|
8
|
+
export function formatError(error: GraphQLError): GraphQLFormattedError;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
|
12
|
+
*/
|
|
13
|
+
export interface GraphQLFormattedError<
|
|
14
|
+
TExtensions extends Record<string, any> = Record<string, any>
|
|
15
|
+
> {
|
|
16
|
+
/**
|
|
17
|
+
* A short, human-readable summary of the problem that **SHOULD NOT** change
|
|
18
|
+
* from occurrence to occurrence of the problem, except for purposes of
|
|
19
|
+
* localization.
|
|
20
|
+
*/
|
|
21
|
+
readonly message: string;
|
|
22
|
+
/**
|
|
23
|
+
* If an error can be associated to a particular point in the requested
|
|
24
|
+
* GraphQL document, it should contain a list of locations.
|
|
25
|
+
*/
|
|
26
|
+
readonly locations?: ReadonlyArray<SourceLocation>;
|
|
27
|
+
/**
|
|
28
|
+
* If an error can be associated to a particular field in the GraphQL result,
|
|
29
|
+
* it _must_ contain an entry with the key `path` that details the path of
|
|
30
|
+
* the response field which experienced the error. This allows clients to
|
|
31
|
+
* identify whether a null result is intentional or caused by a runtime error.
|
|
32
|
+
*/
|
|
33
|
+
readonly path?: ReadonlyArray<string | number>;
|
|
34
|
+
/**
|
|
35
|
+
* Reserved for implementors to extend the protocol however they see fit,
|
|
36
|
+
* and hence there are no additional restrictions on its contents.
|
|
37
|
+
*/
|
|
38
|
+
readonly extensions?: TExtensions;
|
|
39
|
+
}
|
package/error/formatError.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.formatError = formatError;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _devAssert = _interopRequireDefault(require("../jsutils/devAssert"));
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
@@ -14,7 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
14
14
|
* Response Format, Errors section of the GraphQL Specification.
|
|
15
15
|
*/
|
|
16
16
|
function formatError(error) {
|
|
17
|
-
|
|
17
|
+
error || (0, _devAssert.default)(0, 'Received null or undefined error.');
|
|
18
18
|
var message = error.message || 'An unknown error occurred.';
|
|
19
19
|
var locations = error.locations;
|
|
20
20
|
var path = error.path;
|
|
@@ -30,3 +30,6 @@ function formatError(error) {
|
|
|
30
30
|
path: path
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
|
35
|
+
*/
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
// @flow strict
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import devAssert from '../jsutils/devAssert';
|
|
4
|
+
|
|
5
5
|
import { type SourceLocation } from '../language/location';
|
|
6
6
|
|
|
7
|
+
import { type GraphQLError } from './GraphQLError';
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* Given a GraphQLError, format it according to the rules described by the
|
|
9
11
|
* Response Format, Errors section of the GraphQL Specification.
|
|
10
12
|
*/
|
|
11
13
|
export function formatError(error: GraphQLError): GraphQLFormattedError {
|
|
12
|
-
|
|
14
|
+
devAssert(error, 'Received null or undefined error.');
|
|
13
15
|
const message = error.message || 'An unknown error occurred.';
|
|
14
16
|
const locations = error.locations;
|
|
15
17
|
const path = error.path;
|
|
@@ -20,9 +22,31 @@ export function formatError(error: GraphQLError): GraphQLFormattedError {
|
|
|
20
22
|
: { message, locations, path };
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
/**
|
|
26
|
+
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
|
27
|
+
*/
|
|
23
28
|
export type GraphQLFormattedError = {|
|
|
29
|
+
/**
|
|
30
|
+
* A short, human-readable summary of the problem that **SHOULD NOT** change
|
|
31
|
+
* from occurrence to occurrence of the problem, except for purposes of
|
|
32
|
+
* localization.
|
|
33
|
+
*/
|
|
24
34
|
+message: string,
|
|
35
|
+
/**
|
|
36
|
+
* If an error can be associated to a particular point in the requested
|
|
37
|
+
* GraphQL document, it should contain a list of locations.
|
|
38
|
+
*/
|
|
25
39
|
+locations: $ReadOnlyArray<SourceLocation> | void,
|
|
40
|
+
/**
|
|
41
|
+
* If an error can be associated to a particular field in the GraphQL result,
|
|
42
|
+
* it _must_ contain an entry with the key `path` that details the path of
|
|
43
|
+
* the response field which experienced the error. This allows clients to
|
|
44
|
+
* identify whether a null result is intentional or caused by a runtime error.
|
|
45
|
+
*/
|
|
26
46
|
+path: $ReadOnlyArray<string | number> | void,
|
|
47
|
+
/**
|
|
48
|
+
* Reserved for implementors to extend the protocol however they see fit,
|
|
49
|
+
* and hence there are no additional restrictions on its contents.
|
|
50
|
+
*/
|
|
27
51
|
+extensions?: { [key: string]: mixed, ... },
|
|
28
52
|
|};
|
package/error/formatError.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import devAssert from '../jsutils/devAssert';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Given a GraphQLError, format it according to the rules described by the
|
|
5
5
|
* Response Format, Errors section of the GraphQL Specification.
|
|
6
6
|
*/
|
|
7
7
|
export function formatError(error) {
|
|
8
|
-
|
|
8
|
+
error || devAssert(0, 'Received null or undefined error.');
|
|
9
9
|
var message = error.message || 'An unknown error occurred.';
|
|
10
10
|
var locations = error.locations;
|
|
11
11
|
var path = error.path;
|
|
@@ -21,3 +21,6 @@ export function formatError(error) {
|
|
|
21
21
|
path: path
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
|
|
26
|
+
*/
|
package/error/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ASTNode } from '../language/ast';
|
|
2
|
+
import { GraphQLError } from './GraphQLError';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Given an arbitrary Error, presumably thrown while attempting to execute a
|
|
6
|
+
* GraphQL operation, produce a new GraphQLError aware of the location in the
|
|
7
|
+
* document responsible for the original Error.
|
|
8
|
+
*/
|
|
9
|
+
export function locatedError(
|
|
10
|
+
originalError: Error | GraphQLError,
|
|
11
|
+
nodes: ReadonlyArray<ASTNode>,
|
|
12
|
+
path: ReadonlyArray<string | number>,
|
|
13
|
+
): GraphQLError;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// @flow strict
|
|
2
2
|
|
|
3
|
-
import { GraphQLError } from './GraphQLError';
|
|
4
3
|
import { type ASTNode } from '../language/ast';
|
|
5
4
|
|
|
5
|
+
import { GraphQLError } from './GraphQLError';
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* Given an arbitrary Error, presumably thrown while attempting to execute a
|
|
8
9
|
* GraphQL operation, produce a new GraphQLError aware of the location in the
|
package/error/locatedError.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { GraphQLError } from './GraphQLError';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Given an arbitrary Error, presumably thrown while attempting to execute a
|
|
5
4
|
* GraphQL operation, produce a new GraphQLError aware of the location in the
|
|
6
5
|
* document responsible for the original Error.
|
|
7
6
|
*/
|
|
7
|
+
|
|
8
8
|
export function locatedError(originalError, nodes, path) {
|
|
9
9
|
// Note: this uses a brand-check to support GraphQL errors originating from
|
|
10
10
|
// other contexts.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Source } from '../language/source';
|
|
2
|
+
import { GraphQLError } from './GraphQLError';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Produces a GraphQLError representing a syntax error, containing useful
|
|
6
|
+
* descriptive information about the syntax error's position in the source.
|
|
7
|
+
*/
|
|
8
|
+
export function syntaxError(
|
|
9
|
+
source: Source,
|
|
10
|
+
position: number,
|
|
11
|
+
description: string,
|
|
12
|
+
): GraphQLError;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import Maybe from '../tsutils/Maybe';
|
|
2
|
+
import { PromiseOrValue } from '../jsutils/PromiseOrValue';
|
|
3
|
+
import { Path, addPath, pathToArray } from '../jsutils/Path';
|
|
4
|
+
|
|
5
|
+
import { GraphQLError, locatedError } from '../error';
|
|
6
|
+
import {
|
|
7
|
+
DirectiveNode,
|
|
8
|
+
DocumentNode,
|
|
9
|
+
OperationDefinitionNode,
|
|
10
|
+
SelectionSetNode,
|
|
11
|
+
FieldNode,
|
|
12
|
+
InlineFragmentNode,
|
|
13
|
+
FragmentDefinitionNode,
|
|
14
|
+
} from '../language/ast';
|
|
15
|
+
import { GraphQLSchema } from '../type/schema';
|
|
16
|
+
import {
|
|
17
|
+
GraphQLField,
|
|
18
|
+
GraphQLFieldResolver,
|
|
19
|
+
GraphQLResolveInfo,
|
|
20
|
+
GraphQLTypeResolver,
|
|
21
|
+
GraphQLObjectType,
|
|
22
|
+
} from '../type/definition';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Data that must be available at all points during query execution.
|
|
26
|
+
*
|
|
27
|
+
* Namely, schema of the type system that is currently executing,
|
|
28
|
+
* and the fragments defined in the query document
|
|
29
|
+
*/
|
|
30
|
+
export interface ExecutionContext {
|
|
31
|
+
schema: GraphQLSchema;
|
|
32
|
+
fragments: { [key: string]: FragmentDefinitionNode };
|
|
33
|
+
rootValue: any;
|
|
34
|
+
contextValue: any;
|
|
35
|
+
operation: OperationDefinitionNode;
|
|
36
|
+
variableValues: { [key: string]: any };
|
|
37
|
+
fieldResolver: GraphQLFieldResolver<any, any>;
|
|
38
|
+
errors: GraphQLError[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ExecutionResultDataDefault {
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The result of GraphQL execution.
|
|
47
|
+
*
|
|
48
|
+
* - `errors` is included when any errors occurred as a non-empty array.
|
|
49
|
+
* - `data` is the result of a successful execution of the query.
|
|
50
|
+
*/
|
|
51
|
+
// TS_SPECIFIC: TData and ExecutionResultDataDefault
|
|
52
|
+
export interface ExecutionResult<TData = ExecutionResultDataDefault> {
|
|
53
|
+
errors?: ReadonlyArray<GraphQLError>;
|
|
54
|
+
data?: TData | null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type ExecutionArgs = {
|
|
58
|
+
schema: GraphQLSchema;
|
|
59
|
+
document: DocumentNode;
|
|
60
|
+
rootValue?: any;
|
|
61
|
+
contextValue?: any;
|
|
62
|
+
variableValues?: Maybe<{ [key: string]: any }>;
|
|
63
|
+
operationName?: Maybe<string>;
|
|
64
|
+
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
|
|
65
|
+
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Implements the "Evaluating requests" section of the GraphQL specification.
|
|
70
|
+
*
|
|
71
|
+
* Returns either a synchronous ExecutionResult (if all encountered resolvers
|
|
72
|
+
* are synchronous), or a Promise of an ExecutionResult that will eventually be
|
|
73
|
+
* resolved and never rejected.
|
|
74
|
+
*
|
|
75
|
+
* If the arguments to this function do not result in a legal execution context,
|
|
76
|
+
* a GraphQLError will be thrown immediately explaining the invalid input.
|
|
77
|
+
*
|
|
78
|
+
* Accepts either an object with named arguments, or individual arguments.
|
|
79
|
+
*/
|
|
80
|
+
export function execute<TData = ExecutionResultDataDefault>(
|
|
81
|
+
args: ExecutionArgs,
|
|
82
|
+
): PromiseOrValue<ExecutionResult<TData>>;
|
|
83
|
+
export function execute<TData = ExecutionResultDataDefault>(
|
|
84
|
+
schema: GraphQLSchema,
|
|
85
|
+
document: DocumentNode,
|
|
86
|
+
rootValue?: any,
|
|
87
|
+
contextValue?: any,
|
|
88
|
+
variableValues?: Maybe<{ [key: string]: any }>,
|
|
89
|
+
operationName?: Maybe<string>,
|
|
90
|
+
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>,
|
|
91
|
+
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>,
|
|
92
|
+
): PromiseOrValue<ExecutionResult<TData>>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Essential assertions before executing to provide developer feedback for
|
|
96
|
+
* improper use of the GraphQL library.
|
|
97
|
+
*/
|
|
98
|
+
export function assertValidExecutionArguments(
|
|
99
|
+
schema: GraphQLSchema,
|
|
100
|
+
document: DocumentNode,
|
|
101
|
+
rawVariableValues: Maybe<{ [key: string]: any }>,
|
|
102
|
+
): void;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Constructs a ExecutionContext object from the arguments passed to
|
|
106
|
+
* execute, which we will pass throughout the other execution methods.
|
|
107
|
+
*
|
|
108
|
+
* Throws a GraphQLError if a valid execution context cannot be created.
|
|
109
|
+
*/
|
|
110
|
+
export function buildExecutionContext(
|
|
111
|
+
schema: GraphQLSchema,
|
|
112
|
+
document: DocumentNode,
|
|
113
|
+
rootValue: any,
|
|
114
|
+
contextValue: any,
|
|
115
|
+
rawVariableValues: Maybe<{ [key: string]: any }>,
|
|
116
|
+
operationName: Maybe<string>,
|
|
117
|
+
fieldResolver: Maybe<GraphQLFieldResolver<any, any>>,
|
|
118
|
+
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>,
|
|
119
|
+
): ReadonlyArray<GraphQLError> | ExecutionContext;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Given a selectionSet, adds all of the fields in that selection to
|
|
123
|
+
* the passed in map of fields, and returns it at the end.
|
|
124
|
+
*
|
|
125
|
+
* CollectFields requires the "runtime type" of an object. For a field which
|
|
126
|
+
* returns an Interface or Union type, the "runtime type" will be the actual
|
|
127
|
+
* Object type returned by that field.
|
|
128
|
+
*/
|
|
129
|
+
export function collectFields(
|
|
130
|
+
exeContext: ExecutionContext,
|
|
131
|
+
runtimeType: GraphQLObjectType,
|
|
132
|
+
selectionSet: SelectionSetNode,
|
|
133
|
+
fields: { [key: string]: Array<FieldNode> },
|
|
134
|
+
visitedFragmentNames: { [key: string]: boolean },
|
|
135
|
+
): { [key: string]: Array<FieldNode> };
|
|
136
|
+
|
|
137
|
+
export function buildResolveInfo(
|
|
138
|
+
exeContext: ExecutionContext,
|
|
139
|
+
fieldDef: GraphQLField<any, any>,
|
|
140
|
+
fieldNodes: ReadonlyArray<FieldNode>,
|
|
141
|
+
parentType: GraphQLObjectType,
|
|
142
|
+
path: Path,
|
|
143
|
+
): GraphQLResolveInfo;
|
|
144
|
+
|
|
145
|
+
// Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
|
|
146
|
+
// function. Returns the result of resolveFn or the abrupt-return Error object.
|
|
147
|
+
// TS_SPECIFIC: TSource
|
|
148
|
+
export function resolveFieldValueOrError<TSource>(
|
|
149
|
+
exeContext: ExecutionContext,
|
|
150
|
+
fieldDef: GraphQLField<TSource, any>,
|
|
151
|
+
fieldNodes: ReadonlyArray<FieldNode>,
|
|
152
|
+
resolveFn: GraphQLFieldResolver<TSource, any>,
|
|
153
|
+
source: TSource,
|
|
154
|
+
info: GraphQLResolveInfo,
|
|
155
|
+
): Error | any;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* If a resolveType function is not given, then a default resolve behavior is
|
|
159
|
+
* used which attempts two strategies:
|
|
160
|
+
*
|
|
161
|
+
* First, See if the provided value has a `__typename` field defined, if so, use
|
|
162
|
+
* that value as name of the resolved type.
|
|
163
|
+
*
|
|
164
|
+
* Otherwise, test each possible type for the abstract type by calling
|
|
165
|
+
* isTypeOf for the object being coerced, returning the first type that matches.
|
|
166
|
+
*/
|
|
167
|
+
export const defaultTypeResolver: GraphQLTypeResolver<any, any>;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* If a resolve function is not given, then a default resolve behavior is used
|
|
171
|
+
* which takes the property of the source object of the same name as the field
|
|
172
|
+
* and returns it as the result, or if it's a function, returns the result
|
|
173
|
+
* of calling that function while passing along args and context.
|
|
174
|
+
*/
|
|
175
|
+
export const defaultFieldResolver: GraphQLFieldResolver<any, any>;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* This method looks up the field on the given type defintion.
|
|
179
|
+
* It has special casing for the two introspection fields, __schema
|
|
180
|
+
* and __typename. __typename is special because it can always be
|
|
181
|
+
* queried as a field, even in situations where no other fields
|
|
182
|
+
* are allowed, like on a Union. __schema could get automatically
|
|
183
|
+
* added to the query type, but that would require mutating type
|
|
184
|
+
* definitions, which would cause issues.
|
|
185
|
+
*/
|
|
186
|
+
export function getFieldDef(
|
|
187
|
+
schema: GraphQLSchema,
|
|
188
|
+
parentType: GraphQLObjectType,
|
|
189
|
+
fieldName: string,
|
|
190
|
+
): Maybe<GraphQLField<any, any>>;
|