graphql 15.1.0 → 15.4.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/LICENSE +1 -1
- package/README.md +10 -12
- package/error/GraphQLError.js +5 -5
- package/error/GraphQLError.js.flow +5 -5
- package/error/GraphQLError.mjs +1 -1
- package/error/formatError.js +1 -1
- package/error/formatError.js.flow +2 -3
- package/error/index.js +4 -4
- package/error/index.js.flow +0 -1
- package/error/locatedError.d.ts +2 -2
- package/error/locatedError.js +10 -5
- package/error/locatedError.js.flow +11 -5
- package/error/locatedError.mjs +6 -4
- package/error/syntaxError.js +1 -1
- package/error/syntaxError.js.flow +1 -2
- package/execution/execute.d.ts +24 -16
- package/execution/execute.js +123 -105
- package/execution/execute.js.flow +169 -153
- package/execution/execute.mjs +101 -82
- package/execution/index.d.ts +2 -0
- package/execution/index.js +9 -3
- package/execution/index.js.flow +12 -3
- package/execution/index.mjs +1 -1
- package/execution/values.js +11 -11
- package/execution/values.js.flow +10 -14
- package/graphql.js +5 -5
- package/graphql.js.flow +9 -9
- package/index.d.ts +19 -1
- package/index.js +27 -9
- package/index.js.flow +10 -3
- package/index.mjs +4 -3
- package/jsutils/ObjMap.js.flow +0 -1
- package/jsutils/Path.d.ts +6 -1
- package/jsutils/Path.js +3 -2
- package/jsutils/Path.js.flow +3 -2
- package/jsutils/Path.mjs +3 -2
- package/jsutils/PromiseOrValue.js.flow +0 -1
- package/jsutils/defineInspect.js +2 -2
- package/jsutils/defineInspect.js.flow +0 -1
- package/jsutils/devAssert.js.flow +0 -1
- package/jsutils/didYouMean.js.flow +0 -1
- package/jsutils/identityFunc.js.flow +0 -1
- package/jsutils/inspect.js +1 -2
- package/jsutils/inspect.js.flow +10 -8
- package/jsutils/inspect.mjs +1 -1
- package/jsutils/instanceOf.js.flow +2 -3
- package/jsutils/invariant.js.flow +0 -1
- package/jsutils/isAsyncIterable.js +19 -0
- package/jsutils/isAsyncIterable.js.flow +18 -0
- package/jsutils/isAsyncIterable.mjs +16 -0
- package/jsutils/isCollection.js +1 -1
- package/jsutils/isCollection.js.flow +0 -1
- package/jsutils/isObjectLike.js.flow +0 -1
- package/jsutils/isPromise.js.flow +0 -1
- package/jsutils/keyMap.js.flow +1 -2
- package/jsutils/keyValMap.js.flow +1 -2
- package/jsutils/mapValue.js +1 -1
- package/jsutils/mapValue.js.flow +1 -2
- package/jsutils/memoize3.js +2 -5
- package/jsutils/memoize3.js.flow +2 -5
- package/jsutils/memoize3.mjs +2 -5
- package/jsutils/nodejsCustomInspectSymbol.js.flow +0 -1
- package/jsutils/printPathArray.js.flow +0 -1
- package/jsutils/promiseForObject.js.flow +1 -2
- package/jsutils/promiseReduce.js +1 -1
- package/jsutils/promiseReduce.js.flow +1 -1
- package/jsutils/promiseReduce.mjs +1 -1
- package/jsutils/suggestionList.js.flow +1 -2
- package/jsutils/toObjMap.js +1 -1
- package/jsutils/toObjMap.js.flow +5 -6
- package/language/ast.js +1 -1
- package/language/ast.js.flow +2 -3
- package/language/blockString.d.ts +1 -1
- package/language/blockString.js +53 -32
- package/language/blockString.js.flow +49 -34
- package/language/blockString.mjs +54 -33
- package/language/directiveLocation.js.flow +0 -1
- package/language/experimentalOnlineParser/grammar.d.ts +1006 -0
- package/language/experimentalOnlineParser/grammar.js +987 -0
- package/language/experimentalOnlineParser/grammar.js.flow +1000 -0
- package/language/experimentalOnlineParser/grammar.mjs +980 -0
- package/language/experimentalOnlineParser/index.d.ts +6 -0
- package/language/experimentalOnlineParser/index.js +31 -0
- package/language/experimentalOnlineParser/index.js.flow +7 -0
- package/language/experimentalOnlineParser/index.mjs +1 -0
- package/language/experimentalOnlineParser/onlineParser.d.ts +125 -0
- package/language/experimentalOnlineParser/onlineParser.js +604 -0
- package/language/experimentalOnlineParser/onlineParser.js.flow +723 -0
- package/language/experimentalOnlineParser/onlineParser.mjs +587 -0
- package/language/index.js +12 -12
- package/language/index.js.flow +0 -1
- package/language/kinds.js.flow +0 -1
- package/language/lexer.js +242 -183
- package/language/lexer.js.flow +191 -186
- package/language/lexer.mjs +239 -180
- package/language/location.js.flow +1 -2
- package/language/parser.js +73 -68
- package/language/parser.js.flow +112 -106
- package/language/parser.mjs +66 -62
- package/language/predicates.js +1 -1
- package/language/predicates.js.flow +1 -2
- package/language/printLocation.js +1 -1
- package/language/printLocation.js.flow +4 -4
- package/language/printer.js +20 -13
- package/language/printer.js.flow +27 -25
- package/language/printer.mjs +18 -11
- package/language/source.d.ts +12 -6
- package/language/source.js +25 -9
- package/language/source.js.flow +25 -8
- package/language/source.mjs +19 -7
- package/language/tokenKind.js.flow +0 -1
- package/language/visitor.d.ts +3 -3
- package/language/visitor.js +5 -5
- package/language/visitor.js.flow +5 -5
- package/language/visitor.mjs +3 -3
- package/package.json +1 -1
- package/polyfills/arrayFrom.js +2 -2
- package/polyfills/arrayFrom.js.flow +1 -2
- package/polyfills/arrayFrom.mjs +1 -1
- package/polyfills/find.js +1 -1
- package/polyfills/find.js.flow +1 -2
- package/polyfills/find.mjs +1 -1
- package/polyfills/isFinite.js +1 -1
- package/polyfills/isFinite.js.flow +1 -2
- package/polyfills/isFinite.mjs +1 -1
- package/polyfills/isInteger.js +1 -1
- package/polyfills/isInteger.js.flow +1 -2
- package/polyfills/isInteger.mjs +1 -1
- package/polyfills/objectEntries.js +1 -1
- package/polyfills/objectEntries.js.flow +2 -3
- package/polyfills/objectEntries.mjs +1 -1
- package/polyfills/objectValues.js +1 -1
- package/polyfills/objectValues.js.flow +2 -3
- package/polyfills/objectValues.mjs +1 -1
- package/polyfills/symbols.js +3 -5
- package/polyfills/symbols.js.flow +9 -6
- package/polyfills/symbols.mjs +3 -5
- package/subscription/index.js +1 -1
- package/subscription/index.js.flow +0 -1
- package/subscription/mapAsyncIterator.js +2 -2
- package/subscription/mapAsyncIterator.js.flow +9 -10
- package/subscription/mapAsyncIterator.mjs +1 -1
- package/subscription/subscribe.js +61 -73
- package/subscription/subscribe.js.flow +74 -88
- package/subscription/subscribe.mjs +53 -65
- package/type/definition.d.ts +181 -31
- package/type/definition.js +37 -32
- package/type/definition.js.flow +66 -51
- package/type/definition.mjs +20 -18
- package/type/directives.d.ts +17 -3
- package/type/directives.js +17 -16
- package/type/directives.js.flow +20 -21
- package/type/directives.mjs +6 -5
- package/type/index.d.ts +12 -0
- package/type/index.js +6 -6
- package/type/index.js.flow +0 -1
- package/type/introspection.js +86 -68
- package/type/introspection.js.flow +85 -54
- package/type/introspection.mjs +79 -61
- package/type/scalars.js +9 -9
- package/type/scalars.js.flow +3 -3
- package/type/scalars.mjs +1 -1
- package/type/schema.d.ts +17 -4
- package/type/schema.js +13 -13
- package/type/schema.js.flow +18 -16
- package/type/schema.mjs +1 -1
- package/type/validate.js +52 -19
- package/type/validate.js.flow +67 -18
- package/type/validate.mjs +44 -10
- package/utilities/TypeInfo.js +7 -7
- package/utilities/TypeInfo.js.flow +16 -18
- package/utilities/TypeInfo.mjs +1 -1
- package/utilities/assertValidName.js +2 -2
- package/utilities/assertValidName.js.flow +0 -1
- package/utilities/astFromValue.js +10 -10
- package/utilities/astFromValue.js.flow +2 -3
- package/utilities/buildASTSchema.js +17 -27
- package/utilities/buildASTSchema.js.flow +11 -28
- package/utilities/buildASTSchema.mjs +11 -21
- package/utilities/buildClientSchema.js +14 -14
- package/utilities/buildClientSchema.js.flow +41 -29
- package/utilities/buildClientSchema.mjs +5 -5
- package/utilities/coerceInputValue.js +14 -14
- package/utilities/coerceInputValue.js.flow +7 -6
- package/utilities/coerceInputValue.mjs +2 -2
- package/utilities/concatAST.js +9 -8
- package/utilities/concatAST.js.flow +9 -9
- package/utilities/concatAST.mjs +9 -6
- package/utilities/extendSchema.js +26 -19
- package/utilities/extendSchema.js.flow +58 -45
- package/utilities/extendSchema.mjs +9 -2
- package/utilities/findBreakingChanges.js +9 -9
- package/utilities/findBreakingChanges.js.flow +12 -11
- package/utilities/findDeprecatedUsages.d.ts +9 -1
- package/utilities/findDeprecatedUsages.js +11 -27
- package/utilities/findDeprecatedUsages.js.flow +15 -44
- package/utilities/findDeprecatedUsages.mjs +11 -25
- package/utilities/getIntrospectionQuery.js.flow +2 -3
- package/utilities/getOperationAST.js +1 -1
- package/utilities/getOperationAST.js.flow +1 -5
- package/utilities/getOperationAST.mjs +1 -1
- package/utilities/getOperationRootType.js +1 -1
- package/utilities/getOperationRootType.js.flow +5 -6
- package/utilities/index.d.ts +4 -1
- package/utilities/index.js +22 -22
- package/utilities/index.js.flow +1 -2
- package/utilities/index.mjs +1 -1
- package/utilities/introspectionFromSchema.js +6 -8
- package/utilities/introspectionFromSchema.js.flow +10 -10
- package/utilities/introspectionFromSchema.mjs +3 -4
- package/utilities/lexicographicSortSchema.js +10 -8
- package/utilities/lexicographicSortSchema.js.flow +19 -12
- package/utilities/lexicographicSortSchema.mjs +3 -1
- package/utilities/printSchema.js +15 -16
- package/utilities/printSchema.js.flow +34 -25
- package/utilities/printSchema.mjs +6 -7
- package/utilities/separateOperations.js +2 -2
- package/utilities/separateOperations.js.flow +2 -6
- package/utilities/separateOperations.mjs +1 -1
- package/utilities/stripIgnoredCharacters.js +6 -16
- package/utilities/stripIgnoredCharacters.js.flow +4 -13
- package/utilities/stripIgnoredCharacters.mjs +3 -10
- package/utilities/typeComparators.js +1 -1
- package/utilities/typeComparators.js.flow +2 -4
- package/utilities/typeFromAST.js +6 -6
- package/utilities/typeFromAST.js.flow +11 -14
- package/utilities/typeFromAST.mjs +2 -2
- package/utilities/typedQueryDocumentNode.d.ts +20 -0
- package/utilities/valueFromAST.js +6 -6
- package/utilities/valueFromAST.js.flow +7 -5
- package/utilities/valueFromASTUntyped.js +4 -4
- package/utilities/valueFromASTUntyped.js.flow +2 -3
- package/validation/ValidationContext.d.ts +3 -0
- package/validation/ValidationContext.js +7 -3
- package/validation/ValidationContext.js.flow +28 -22
- package/validation/ValidationContext.mjs +4 -0
- package/validation/index.d.ts +4 -0
- package/validation/index.js +52 -36
- package/validation/index.js.flow +4 -1
- package/validation/index.mjs +4 -1
- package/validation/rules/ExecutableDefinitions.js +1 -1
- package/validation/rules/ExecutableDefinitions.js.flow +0 -1
- package/validation/rules/ExecutableDefinitionsRule.js +3 -3
- package/validation/rules/ExecutableDefinitionsRule.js.flow +2 -3
- package/validation/rules/FieldsOnCorrectTypeRule.js +5 -5
- package/validation/rules/FieldsOnCorrectTypeRule.js.flow +9 -8
- package/validation/rules/FragmentsOnCompositeTypesRule.js +4 -4
- package/validation/rules/FragmentsOnCompositeTypesRule.js.flow +2 -3
- package/validation/rules/KnownArgumentNamesRule.js +5 -5
- package/validation/rules/KnownArgumentNamesRule.js.flow +5 -5
- package/validation/rules/KnownDirectivesRule.js +6 -6
- package/validation/rules/KnownDirectivesRule.js.flow +10 -11
- package/validation/rules/KnownFragmentNamesRule.js +1 -1
- package/validation/rules/KnownFragmentNamesRule.js.flow +3 -3
- package/validation/rules/KnownTypeNamesRule.js +12 -10
- package/validation/rules/KnownTypeNamesRule.js.flow +14 -11
- package/validation/rules/KnownTypeNamesRule.mjs +6 -5
- package/validation/rules/LoneAnonymousOperationRule.js +2 -2
- package/validation/rules/LoneAnonymousOperationRule.js.flow +2 -3
- package/validation/rules/LoneSchemaDefinition.js +1 -1
- package/validation/rules/LoneSchemaDefinition.js.flow +0 -1
- package/validation/rules/LoneSchemaDefinitionRule.js +1 -1
- package/validation/rules/LoneSchemaDefinitionRule.js.flow +2 -3
- package/validation/rules/NoFragmentCyclesRule.js +1 -1
- package/validation/rules/NoFragmentCyclesRule.js.flow +4 -5
- package/validation/rules/NoUndefinedVariablesRule.js +1 -1
- package/validation/rules/NoUndefinedVariablesRule.js.flow +3 -3
- package/validation/rules/NoUnusedFragmentsRule.js +1 -1
- package/validation/rules/NoUnusedFragmentsRule.js.flow +3 -3
- package/validation/rules/NoUnusedVariablesRule.js +1 -1
- package/validation/rules/NoUnusedVariablesRule.js.flow +3 -3
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +20 -20
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js.flow +29 -27
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +12 -12
- package/validation/rules/PossibleFragmentSpreadsRule.js +5 -5
- package/validation/rules/PossibleFragmentSpreadsRule.js.flow +7 -4
- package/validation/rules/PossibleTypeExtensions.js +1 -1
- package/validation/rules/PossibleTypeExtensions.js.flow +0 -1
- package/validation/rules/PossibleTypeExtensionsRule.js +8 -8
- package/validation/rules/PossibleTypeExtensionsRule.js.flow +8 -6
- package/validation/rules/ProvidedRequiredArgumentsRule.js +7 -7
- package/validation/rules/ProvidedRequiredArgumentsRule.js.flow +7 -6
- package/validation/rules/ScalarLeafsRule.js +3 -3
- package/validation/rules/ScalarLeafsRule.js.flow +3 -4
- package/validation/rules/SingleFieldSubscriptionsRule.js +1 -1
- package/validation/rules/SingleFieldSubscriptionsRule.js.flow +3 -4
- package/validation/rules/UniqueArgumentNamesRule.js +1 -1
- package/validation/rules/UniqueArgumentNamesRule.js.flow +2 -3
- package/validation/rules/UniqueDirectiveNames.js +1 -1
- package/validation/rules/UniqueDirectiveNames.js.flow +0 -1
- package/validation/rules/UniqueDirectiveNamesRule.js +1 -1
- package/validation/rules/UniqueDirectiveNamesRule.js.flow +2 -3
- package/validation/rules/UniqueDirectivesPerLocationRule.js +4 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.js.flow +4 -5
- package/validation/rules/UniqueEnumValueNames.js +1 -1
- package/validation/rules/UniqueEnumValueNames.js.flow +0 -1
- package/validation/rules/UniqueEnumValueNamesRule.js +2 -2
- package/validation/rules/UniqueEnumValueNamesRule.js.flow +11 -4
- package/validation/rules/UniqueFieldDefinitionNames.js +1 -1
- package/validation/rules/UniqueFieldDefinitionNames.js.flow +0 -1
- package/validation/rules/UniqueFieldDefinitionNamesRule.js +3 -3
- package/validation/rules/UniqueFieldDefinitionNamesRule.js.flow +17 -6
- package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +1 -1
- package/validation/rules/UniqueFragmentNamesRule.js +1 -1
- package/validation/rules/UniqueFragmentNamesRule.js.flow +3 -3
- package/validation/rules/UniqueInputFieldNamesRule.js +1 -1
- package/validation/rules/UniqueInputFieldNamesRule.js.flow +3 -3
- package/validation/rules/UniqueOperationNamesRule.js +1 -1
- package/validation/rules/UniqueOperationNamesRule.js.flow +3 -3
- package/validation/rules/UniqueOperationTypes.js +1 -1
- package/validation/rules/UniqueOperationTypes.js.flow +0 -1
- package/validation/rules/UniqueOperationTypesRule.js +1 -1
- package/validation/rules/UniqueOperationTypesRule.js.flow +10 -4
- package/validation/rules/UniqueTypeNames.js +1 -1
- package/validation/rules/UniqueTypeNames.js.flow +0 -1
- package/validation/rules/UniqueTypeNamesRule.js +1 -1
- package/validation/rules/UniqueTypeNamesRule.js.flow +3 -4
- package/validation/rules/UniqueVariableNamesRule.js +1 -1
- package/validation/rules/UniqueVariableNamesRule.js.flow +3 -4
- package/validation/rules/ValuesOfCorrectTypeRule.js +8 -8
- package/validation/rules/ValuesOfCorrectTypeRule.js.flow +3 -4
- package/validation/rules/VariablesAreInputTypesRule.js +4 -4
- package/validation/rules/VariablesAreInputTypesRule.js.flow +3 -4
- package/validation/rules/VariablesInAllowedPositionRule.js +6 -6
- package/validation/rules/VariablesInAllowedPositionRule.js.flow +6 -6
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +14 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.js +79 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.js.flow +94 -0
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs +68 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +16 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +34 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js.flow +38 -0
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +25 -0
- package/validation/specifiedRules.js +33 -33
- package/validation/specifiedRules.js.flow +0 -1
- package/validation/validate.js +7 -7
- package/validation/validate.js.flow +4 -9
- package/version.js +2 -2
- package/version.js.flow +2 -3
- package/version.mjs +2 -2
- package/polyfills/flatMap.js +0 -30
- package/polyfills/flatMap.js.flow +0 -28
- package/polyfills/flatMap.mjs +0 -23
|
@@ -1,36 +1,48 @@
|
|
|
1
1
|
// @flow strict
|
|
2
|
-
|
|
3
2
|
import arrayFrom from '../polyfills/arrayFrom';
|
|
4
3
|
|
|
4
|
+
import type { Path } from '../jsutils/Path';
|
|
5
|
+
import type { ObjMap } from '../jsutils/ObjMap';
|
|
6
|
+
import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
|
|
5
7
|
import inspect from '../jsutils/inspect';
|
|
6
8
|
import memoize3 from '../jsutils/memoize3';
|
|
7
9
|
import invariant from '../jsutils/invariant';
|
|
8
10
|
import devAssert from '../jsutils/devAssert';
|
|
9
11
|
import isPromise from '../jsutils/isPromise';
|
|
10
|
-
import { type ObjMap } from '../jsutils/ObjMap';
|
|
11
12
|
import isObjectLike from '../jsutils/isObjectLike';
|
|
12
13
|
import isCollection from '../jsutils/isCollection';
|
|
13
14
|
import promiseReduce from '../jsutils/promiseReduce';
|
|
14
15
|
import promiseForObject from '../jsutils/promiseForObject';
|
|
15
|
-
import {
|
|
16
|
-
import { type Path, addPath, pathToArray } from '../jsutils/Path';
|
|
16
|
+
import { addPath, pathToArray } from '../jsutils/Path';
|
|
17
17
|
|
|
18
|
+
import type { GraphQLFormattedError } from '../error/formatError';
|
|
18
19
|
import { GraphQLError } from '../error/GraphQLError';
|
|
19
20
|
import { locatedError } from '../error/locatedError';
|
|
20
21
|
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
type FragmentDefinitionNode,
|
|
22
|
+
import type {
|
|
23
|
+
DocumentNode,
|
|
24
|
+
OperationDefinitionNode,
|
|
25
|
+
SelectionSetNode,
|
|
26
|
+
FieldNode,
|
|
27
|
+
FragmentSpreadNode,
|
|
28
|
+
InlineFragmentNode,
|
|
29
|
+
FragmentDefinitionNode,
|
|
30
30
|
} from '../language/ast';
|
|
31
|
+
import { Kind } from '../language/kinds';
|
|
31
32
|
|
|
33
|
+
import type { GraphQLSchema } from '../type/schema';
|
|
34
|
+
import type {
|
|
35
|
+
GraphQLObjectType,
|
|
36
|
+
GraphQLOutputType,
|
|
37
|
+
GraphQLLeafType,
|
|
38
|
+
GraphQLAbstractType,
|
|
39
|
+
GraphQLField,
|
|
40
|
+
GraphQLFieldResolver,
|
|
41
|
+
GraphQLResolveInfo,
|
|
42
|
+
GraphQLTypeResolver,
|
|
43
|
+
GraphQLList,
|
|
44
|
+
} from '../type/definition';
|
|
32
45
|
import { assertValidSchema } from '../type/validate';
|
|
33
|
-
import { type GraphQLSchema } from '../type/schema';
|
|
34
46
|
import {
|
|
35
47
|
SchemaMetaFieldDef,
|
|
36
48
|
TypeMetaFieldDef,
|
|
@@ -41,15 +53,7 @@ import {
|
|
|
41
53
|
GraphQLSkipDirective,
|
|
42
54
|
} from '../type/directives';
|
|
43
55
|
import {
|
|
44
|
-
|
|
45
|
-
type GraphQLOutputType,
|
|
46
|
-
type GraphQLLeafType,
|
|
47
|
-
type GraphQLAbstractType,
|
|
48
|
-
type GraphQLField,
|
|
49
|
-
type GraphQLFieldResolver,
|
|
50
|
-
type GraphQLResolveInfo,
|
|
51
|
-
type GraphQLTypeResolver,
|
|
52
|
-
type GraphQLList,
|
|
56
|
+
isNamedType,
|
|
53
57
|
isObjectType,
|
|
54
58
|
isAbstractType,
|
|
55
59
|
isLeafType,
|
|
@@ -109,10 +113,18 @@ export type ExecutionContext = {|
|
|
|
109
113
|
*
|
|
110
114
|
* - `errors` is included when any errors occurred as a non-empty array.
|
|
111
115
|
* - `data` is the result of a successful execution of the query.
|
|
116
|
+
* - `extensions` is reserved for adding non-standard properties.
|
|
112
117
|
*/
|
|
113
118
|
export type ExecutionResult = {|
|
|
114
119
|
errors?: $ReadOnlyArray<GraphQLError>,
|
|
115
120
|
data?: ObjMap<mixed> | null,
|
|
121
|
+
extensions?: ObjMap<mixed>,
|
|
122
|
+
|};
|
|
123
|
+
|
|
124
|
+
export type FormattedExecutionResult = {|
|
|
125
|
+
errors?: $ReadOnlyArray<GraphQLFormattedError>,
|
|
126
|
+
data?: ObjMap<mixed> | null,
|
|
127
|
+
extensions?: ObjMap<mixed>,
|
|
116
128
|
|};
|
|
117
129
|
|
|
118
130
|
export type ExecutionArgs = {|
|
|
@@ -179,6 +191,22 @@ export function execute(
|
|
|
179
191
|
});
|
|
180
192
|
}
|
|
181
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Also implements the "Evaluating requests" section of the GraphQL specification.
|
|
196
|
+
* However, it guarantees to complete synchronously (or throw an error) assuming
|
|
197
|
+
* that all field resolvers are also synchronous.
|
|
198
|
+
*/
|
|
199
|
+
export function executeSync(args: ExecutionArgs): ExecutionResult {
|
|
200
|
+
const result = executeImpl(args);
|
|
201
|
+
|
|
202
|
+
// Assert that the execution was synchronous.
|
|
203
|
+
if (isPromise(result)) {
|
|
204
|
+
throw new Error('GraphQL execution failed to complete synchronously.');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
|
|
182
210
|
function executeImpl(args: ExecutionArgs): PromiseOrValue<ExecutionResult> {
|
|
183
211
|
const {
|
|
184
212
|
schema,
|
|
@@ -360,8 +388,6 @@ function executeOperation(
|
|
|
360
388
|
// Errors from sub-fields of a NonNull type may propagate to the top level,
|
|
361
389
|
// at which point we still log the error and null the parent field, which
|
|
362
390
|
// in this case is the entire response.
|
|
363
|
-
//
|
|
364
|
-
// Similar to completeValueCatchingError.
|
|
365
391
|
try {
|
|
366
392
|
const result =
|
|
367
393
|
operation.operation === 'mutation'
|
|
@@ -395,7 +421,7 @@ function executeFieldsSerially(
|
|
|
395
421
|
Object.keys(fields),
|
|
396
422
|
(results, responseName) => {
|
|
397
423
|
const fieldNodes = fields[responseName];
|
|
398
|
-
const fieldPath = addPath(path, responseName);
|
|
424
|
+
const fieldPath = addPath(path, responseName, parentType.name);
|
|
399
425
|
const result = resolveField(
|
|
400
426
|
exeContext,
|
|
401
427
|
parentType,
|
|
@@ -435,7 +461,7 @@ function executeFields(
|
|
|
435
461
|
|
|
436
462
|
for (const responseName of Object.keys(fields)) {
|
|
437
463
|
const fieldNodes = fields[responseName];
|
|
438
|
-
const fieldPath = addPath(path, responseName);
|
|
464
|
+
const fieldPath = addPath(path, responseName, parentType.name);
|
|
439
465
|
const result = resolveField(
|
|
440
466
|
exeContext,
|
|
441
467
|
parentType,
|
|
@@ -446,7 +472,7 @@ function executeFields(
|
|
|
446
472
|
|
|
447
473
|
if (result !== undefined) {
|
|
448
474
|
results[responseName] = result;
|
|
449
|
-
if (
|
|
475
|
+
if (isPromise(result)) {
|
|
450
476
|
containsPromise = true;
|
|
451
477
|
}
|
|
452
478
|
}
|
|
@@ -617,6 +643,7 @@ function resolveField(
|
|
|
617
643
|
return;
|
|
618
644
|
}
|
|
619
645
|
|
|
646
|
+
const returnType = fieldDef.type;
|
|
620
647
|
const resolveFn = fieldDef.resolve ?? exeContext.fieldResolver;
|
|
621
648
|
|
|
622
649
|
const info = buildResolveInfo(
|
|
@@ -627,67 +654,7 @@ function resolveField(
|
|
|
627
654
|
path,
|
|
628
655
|
);
|
|
629
656
|
|
|
630
|
-
// Get the resolve function, regardless of if its result is normal
|
|
631
|
-
// or abrupt (error).
|
|
632
|
-
const result = resolveFieldValueOrError(
|
|
633
|
-
exeContext,
|
|
634
|
-
fieldDef,
|
|
635
|
-
fieldNodes,
|
|
636
|
-
resolveFn,
|
|
637
|
-
source,
|
|
638
|
-
info,
|
|
639
|
-
);
|
|
640
|
-
|
|
641
|
-
return completeValueCatchingError(
|
|
642
|
-
exeContext,
|
|
643
|
-
fieldDef.type,
|
|
644
|
-
fieldNodes,
|
|
645
|
-
info,
|
|
646
|
-
path,
|
|
647
|
-
result,
|
|
648
|
-
);
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
* @internal
|
|
653
|
-
*/
|
|
654
|
-
export function buildResolveInfo(
|
|
655
|
-
exeContext: ExecutionContext,
|
|
656
|
-
fieldDef: GraphQLField<mixed, mixed>,
|
|
657
|
-
fieldNodes: $ReadOnlyArray<FieldNode>,
|
|
658
|
-
parentType: GraphQLObjectType,
|
|
659
|
-
path: Path,
|
|
660
|
-
): GraphQLResolveInfo {
|
|
661
|
-
// The resolve function's optional fourth argument is a collection of
|
|
662
|
-
// information about the current execution state.
|
|
663
|
-
return {
|
|
664
|
-
fieldName: fieldDef.name,
|
|
665
|
-
fieldNodes,
|
|
666
|
-
returnType: fieldDef.type,
|
|
667
|
-
parentType,
|
|
668
|
-
path,
|
|
669
|
-
schema: exeContext.schema,
|
|
670
|
-
fragments: exeContext.fragments,
|
|
671
|
-
rootValue: exeContext.rootValue,
|
|
672
|
-
operation: exeContext.operation,
|
|
673
|
-
variableValues: exeContext.variableValues,
|
|
674
|
-
};
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
/**
|
|
678
|
-
* Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
|
|
679
|
-
* function. Returns the result of resolveFn or the abrupt-return Error object.
|
|
680
|
-
*
|
|
681
|
-
* @internal
|
|
682
|
-
*/
|
|
683
|
-
export function resolveFieldValueOrError(
|
|
684
|
-
exeContext: ExecutionContext,
|
|
685
|
-
fieldDef: GraphQLField<mixed, mixed>,
|
|
686
|
-
fieldNodes: $ReadOnlyArray<FieldNode>,
|
|
687
|
-
resolveFn: GraphQLFieldResolver<mixed, mixed>,
|
|
688
|
-
source: mixed,
|
|
689
|
-
info: GraphQLResolveInfo,
|
|
690
|
-
): Error | mixed {
|
|
657
|
+
// Get the resolve function, regardless of if its result is normal or abrupt (error).
|
|
691
658
|
try {
|
|
692
659
|
// Build a JS object of arguments from the field.arguments AST, using the
|
|
693
660
|
// variables scope to fulfill any variable references.
|
|
@@ -704,32 +671,7 @@ export function resolveFieldValueOrError(
|
|
|
704
671
|
const contextValue = exeContext.contextValue;
|
|
705
672
|
|
|
706
673
|
const result = resolveFn(source, args, contextValue, info);
|
|
707
|
-
return isPromise(result) ? result.then(undefined, asErrorInstance) : result;
|
|
708
|
-
} catch (error) {
|
|
709
|
-
return asErrorInstance(error);
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
674
|
|
|
713
|
-
// Sometimes a non-error is thrown, wrap it as an Error instance to ensure a
|
|
714
|
-
// consistent Error interface.
|
|
715
|
-
function asErrorInstance(error: mixed): Error {
|
|
716
|
-
if (error instanceof Error) {
|
|
717
|
-
return error;
|
|
718
|
-
}
|
|
719
|
-
return new Error('Unexpected error value: ' + inspect(error));
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
// This is a small wrapper around completeValue which detects and logs errors
|
|
723
|
-
// in the execution context.
|
|
724
|
-
function completeValueCatchingError(
|
|
725
|
-
exeContext: ExecutionContext,
|
|
726
|
-
returnType: GraphQLOutputType,
|
|
727
|
-
fieldNodes: $ReadOnlyArray<FieldNode>,
|
|
728
|
-
info: GraphQLResolveInfo,
|
|
729
|
-
path: Path,
|
|
730
|
-
result: mixed,
|
|
731
|
-
): PromiseOrValue<mixed> {
|
|
732
|
-
try {
|
|
733
675
|
let completed;
|
|
734
676
|
if (isPromise(result)) {
|
|
735
677
|
completed = result.then((resolved) =>
|
|
@@ -749,23 +691,49 @@ function completeValueCatchingError(
|
|
|
749
691
|
if (isPromise(completed)) {
|
|
750
692
|
// Note: we don't rely on a `catch` method, but we do expect "thenable"
|
|
751
693
|
// to take a second callback for the error case.
|
|
752
|
-
return completed.then(undefined, (
|
|
753
|
-
|
|
754
|
-
|
|
694
|
+
return completed.then(undefined, (rawError) => {
|
|
695
|
+
const error = locatedError(rawError, fieldNodes, pathToArray(path));
|
|
696
|
+
return handleFieldError(error, returnType, exeContext);
|
|
697
|
+
});
|
|
755
698
|
}
|
|
756
699
|
return completed;
|
|
757
|
-
} catch (
|
|
758
|
-
|
|
700
|
+
} catch (rawError) {
|
|
701
|
+
const error = locatedError(rawError, fieldNodes, pathToArray(path));
|
|
702
|
+
return handleFieldError(error, returnType, exeContext);
|
|
759
703
|
}
|
|
760
704
|
}
|
|
761
705
|
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
706
|
+
/**
|
|
707
|
+
* @internal
|
|
708
|
+
*/
|
|
709
|
+
export function buildResolveInfo(
|
|
710
|
+
exeContext: ExecutionContext,
|
|
711
|
+
fieldDef: GraphQLField<mixed, mixed>,
|
|
712
|
+
fieldNodes: $ReadOnlyArray<FieldNode>,
|
|
713
|
+
parentType: GraphQLObjectType,
|
|
714
|
+
path: Path,
|
|
715
|
+
): GraphQLResolveInfo {
|
|
716
|
+
// The resolve function's optional fourth argument is a collection of
|
|
717
|
+
// information about the current execution state.
|
|
718
|
+
return {
|
|
719
|
+
fieldName: fieldDef.name,
|
|
765
720
|
fieldNodes,
|
|
766
|
-
|
|
767
|
-
|
|
721
|
+
returnType: fieldDef.type,
|
|
722
|
+
parentType,
|
|
723
|
+
path,
|
|
724
|
+
schema: exeContext.schema,
|
|
725
|
+
fragments: exeContext.fragments,
|
|
726
|
+
rootValue: exeContext.rootValue,
|
|
727
|
+
operation: exeContext.operation,
|
|
728
|
+
variableValues: exeContext.variableValues,
|
|
729
|
+
};
|
|
730
|
+
}
|
|
768
731
|
|
|
732
|
+
function handleFieldError(
|
|
733
|
+
error: GraphQLError,
|
|
734
|
+
returnType: GraphQLOutputType,
|
|
735
|
+
exeContext: ExecutionContext,
|
|
736
|
+
): null {
|
|
769
737
|
// If the field type is non-nullable, then it is resolved without any
|
|
770
738
|
// protection from errors, however it still properly locates the error.
|
|
771
739
|
if (isNonNullType(returnType)) {
|
|
@@ -913,21 +881,49 @@ function completeListValue(
|
|
|
913
881
|
const completedResults = arrayFrom(result, (item, index) => {
|
|
914
882
|
// No need to modify the info object containing the path,
|
|
915
883
|
// since from here on it is not ever accessed by resolver functions.
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
884
|
+
const itemPath = addPath(path, index, undefined);
|
|
885
|
+
try {
|
|
886
|
+
let completedItem;
|
|
887
|
+
if (isPromise(item)) {
|
|
888
|
+
completedItem = item.then((resolved) =>
|
|
889
|
+
completeValue(
|
|
890
|
+
exeContext,
|
|
891
|
+
itemType,
|
|
892
|
+
fieldNodes,
|
|
893
|
+
info,
|
|
894
|
+
itemPath,
|
|
895
|
+
resolved,
|
|
896
|
+
),
|
|
897
|
+
);
|
|
898
|
+
} else {
|
|
899
|
+
completedItem = completeValue(
|
|
900
|
+
exeContext,
|
|
901
|
+
itemType,
|
|
902
|
+
fieldNodes,
|
|
903
|
+
info,
|
|
904
|
+
itemPath,
|
|
905
|
+
item,
|
|
906
|
+
);
|
|
907
|
+
}
|
|
925
908
|
|
|
926
|
-
|
|
927
|
-
|
|
909
|
+
if (isPromise(completedItem)) {
|
|
910
|
+
containsPromise = true;
|
|
911
|
+
// Note: we don't rely on a `catch` method, but we do expect "thenable"
|
|
912
|
+
// to take a second callback for the error case.
|
|
913
|
+
return completedItem.then(undefined, (rawError) => {
|
|
914
|
+
const error = locatedError(
|
|
915
|
+
rawError,
|
|
916
|
+
fieldNodes,
|
|
917
|
+
pathToArray(itemPath),
|
|
918
|
+
);
|
|
919
|
+
return handleFieldError(error, itemType, exeContext);
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
return completedItem;
|
|
923
|
+
} catch (rawError) {
|
|
924
|
+
const error = locatedError(rawError, fieldNodes, pathToArray(itemPath));
|
|
925
|
+
return handleFieldError(error, itemType, exeContext);
|
|
928
926
|
}
|
|
929
|
-
|
|
930
|
-
return completedItem;
|
|
931
927
|
});
|
|
932
928
|
|
|
933
929
|
return containsPromise ? Promise.all(completedResults) : completedResults;
|
|
@@ -1002,23 +998,43 @@ function completeAbstractValue(
|
|
|
1002
998
|
}
|
|
1003
999
|
|
|
1004
1000
|
function ensureValidRuntimeType(
|
|
1005
|
-
runtimeTypeOrName:
|
|
1001
|
+
runtimeTypeOrName: mixed,
|
|
1006
1002
|
exeContext: ExecutionContext,
|
|
1007
1003
|
returnType: GraphQLAbstractType,
|
|
1008
1004
|
fieldNodes: $ReadOnlyArray<FieldNode>,
|
|
1009
1005
|
info: GraphQLResolveInfo,
|
|
1010
1006
|
result: mixed,
|
|
1011
1007
|
): GraphQLObjectType {
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1008
|
+
if (runtimeTypeOrName == null) {
|
|
1009
|
+
throw new GraphQLError(
|
|
1010
|
+
`Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}". Either the "${returnType.name}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`,
|
|
1011
|
+
fieldNodes,
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1016
1014
|
|
|
1017
|
-
|
|
1015
|
+
// FIXME: temporary workaround until support for passing object types would be removed in v16.0.0
|
|
1016
|
+
const runtimeTypeName = isNamedType(runtimeTypeOrName)
|
|
1017
|
+
? runtimeTypeOrName.name
|
|
1018
|
+
: runtimeTypeOrName;
|
|
1019
|
+
|
|
1020
|
+
if (typeof runtimeTypeName !== 'string') {
|
|
1018
1021
|
throw new GraphQLError(
|
|
1019
1022
|
`Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}" with ` +
|
|
1020
|
-
`value ${inspect(result)}, received "${inspect(
|
|
1021
|
-
|
|
1023
|
+
`value ${inspect(result)}, received "${inspect(runtimeTypeOrName)}".`,
|
|
1024
|
+
);
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
const runtimeType = exeContext.schema.getType(runtimeTypeName);
|
|
1028
|
+
if (runtimeType == null) {
|
|
1029
|
+
throw new GraphQLError(
|
|
1030
|
+
`Abstract type "${returnType.name}" was resolve to a type "${runtimeTypeName}" that does not exist inside schema.`,
|
|
1031
|
+
fieldNodes,
|
|
1032
|
+
);
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
if (!isObjectType(runtimeType)) {
|
|
1036
|
+
throw new GraphQLError(
|
|
1037
|
+
`Abstract type "${returnType.name}" was resolve to a non-object type "${runtimeTypeName}".`,
|
|
1022
1038
|
fieldNodes,
|
|
1023
1039
|
);
|
|
1024
1040
|
}
|
|
@@ -1163,7 +1179,7 @@ export const defaultTypeResolver: GraphQLTypeResolver<mixed, mixed> = function (
|
|
|
1163
1179
|
if (isPromise(isTypeOfResult)) {
|
|
1164
1180
|
promisedIsTypeOfResults[i] = isTypeOfResult;
|
|
1165
1181
|
} else if (isTypeOfResult) {
|
|
1166
|
-
return type;
|
|
1182
|
+
return type.name;
|
|
1167
1183
|
}
|
|
1168
1184
|
}
|
|
1169
1185
|
}
|
|
@@ -1172,7 +1188,7 @@ export const defaultTypeResolver: GraphQLTypeResolver<mixed, mixed> = function (
|
|
|
1172
1188
|
return Promise.all(promisedIsTypeOfResults).then((isTypeOfResults) => {
|
|
1173
1189
|
for (let i = 0; i < isTypeOfResults.length; i++) {
|
|
1174
1190
|
if (isTypeOfResults[i]) {
|
|
1175
|
-
return possibleTypes[i];
|
|
1191
|
+
return possibleTypes[i].name;
|
|
1176
1192
|
}
|
|
1177
1193
|
}
|
|
1178
1194
|
});
|
|
@@ -1201,12 +1217,12 @@ export const defaultFieldResolver: GraphQLFieldResolver<
|
|
|
1201
1217
|
|
|
1202
1218
|
/**
|
|
1203
1219
|
* This method looks up the field on the given type definition.
|
|
1204
|
-
* It has special casing for the
|
|
1205
|
-
* and __typename. __typename is special because
|
|
1206
|
-
* queried as a field, even in situations where no
|
|
1207
|
-
* are allowed, like on a Union. __schema
|
|
1208
|
-
* added to the query type, but that would
|
|
1209
|
-
* definitions, which would cause issues.
|
|
1220
|
+
* It has special casing for the three introspection fields,
|
|
1221
|
+
* __schema, __type and __typename. __typename is special because
|
|
1222
|
+
* it can always be queried as a field, even in situations where no
|
|
1223
|
+
* other fields are allowed, like on a Union. __schema and __type
|
|
1224
|
+
* could get automatically added to the query type, but that would
|
|
1225
|
+
* require mutating type definitions, which would cause issues.
|
|
1210
1226
|
*
|
|
1211
1227
|
* @internal
|
|
1212
1228
|
*/
|