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
|
@@ -1,28 +1,46 @@
|
|
|
1
1
|
// @flow strict
|
|
2
2
|
|
|
3
3
|
import { forEach, isCollection } from 'iterall';
|
|
4
|
-
|
|
5
|
-
import { locatedError } from '../error/locatedError';
|
|
4
|
+
|
|
6
5
|
import inspect from '../jsutils/inspect';
|
|
6
|
+
import memoize3 from '../jsutils/memoize3';
|
|
7
7
|
import invariant from '../jsutils/invariant';
|
|
8
|
+
import devAssert from '../jsutils/devAssert';
|
|
8
9
|
import isInvalid from '../jsutils/isInvalid';
|
|
9
10
|
import isNullish from '../jsutils/isNullish';
|
|
10
11
|
import isPromise from '../jsutils/isPromise';
|
|
12
|
+
import { type ObjMap } from '../jsutils/ObjMap';
|
|
11
13
|
import isObjectLike from '../jsutils/isObjectLike';
|
|
12
|
-
import memoize3 from '../jsutils/memoize3';
|
|
13
|
-
import promiseForObject from '../jsutils/promiseForObject';
|
|
14
14
|
import promiseReduce from '../jsutils/promiseReduce';
|
|
15
|
-
import
|
|
15
|
+
import promiseForObject from '../jsutils/promiseForObject';
|
|
16
16
|
import { type PromiseOrValue } from '../jsutils/PromiseOrValue';
|
|
17
|
+
import { type Path, addPath, pathToArray } from '../jsutils/Path';
|
|
18
|
+
|
|
19
|
+
import { GraphQLError } from '../error/GraphQLError';
|
|
20
|
+
import { locatedError } from '../error/locatedError';
|
|
17
21
|
|
|
18
|
-
import { getOperationRootType } from '../utilities/getOperationRootType';
|
|
19
|
-
import { typeFromAST } from '../utilities/typeFromAST';
|
|
20
22
|
import { Kind } from '../language/kinds';
|
|
21
23
|
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
type DocumentNode,
|
|
25
|
+
type OperationDefinitionNode,
|
|
26
|
+
type SelectionSetNode,
|
|
27
|
+
type FieldNode,
|
|
28
|
+
type FragmentSpreadNode,
|
|
29
|
+
type InlineFragmentNode,
|
|
30
|
+
type FragmentDefinitionNode,
|
|
31
|
+
} from '../language/ast';
|
|
32
|
+
|
|
33
|
+
import { assertValidSchema } from '../type/validate';
|
|
34
|
+
import { type GraphQLSchema } from '../type/schema';
|
|
35
|
+
import {
|
|
36
|
+
SchemaMetaFieldDef,
|
|
37
|
+
TypeMetaFieldDef,
|
|
38
|
+
TypeNameMetaFieldDef,
|
|
39
|
+
} from '../type/introspection';
|
|
40
|
+
import {
|
|
41
|
+
GraphQLIncludeDirective,
|
|
42
|
+
GraphQLSkipDirective,
|
|
43
|
+
} from '../type/directives';
|
|
26
44
|
import {
|
|
27
45
|
type GraphQLObjectType,
|
|
28
46
|
type GraphQLOutputType,
|
|
@@ -32,7 +50,6 @@ import {
|
|
|
32
50
|
type GraphQLFieldResolver,
|
|
33
51
|
type GraphQLResolveInfo,
|
|
34
52
|
type GraphQLTypeResolver,
|
|
35
|
-
type ResponsePath,
|
|
36
53
|
type GraphQLList,
|
|
37
54
|
isObjectType,
|
|
38
55
|
isAbstractType,
|
|
@@ -40,26 +57,15 @@ import {
|
|
|
40
57
|
isListType,
|
|
41
58
|
isNonNullType,
|
|
42
59
|
} from '../type/definition';
|
|
43
|
-
|
|
44
|
-
import {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
TypeNameMetaFieldDef,
|
|
48
|
-
} from '../type/introspection';
|
|
49
|
-
import {
|
|
50
|
-
GraphQLIncludeDirective,
|
|
51
|
-
GraphQLSkipDirective,
|
|
52
|
-
} from '../type/directives';
|
|
53
|
-
import { assertValidSchema } from '../type/validate';
|
|
60
|
+
|
|
61
|
+
import { typeFromAST } from '../utilities/typeFromAST';
|
|
62
|
+
import { getOperationRootType } from '../utilities/getOperationRootType';
|
|
63
|
+
|
|
54
64
|
import {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
type FragmentSpreadNode,
|
|
60
|
-
type InlineFragmentNode,
|
|
61
|
-
type FragmentDefinitionNode,
|
|
62
|
-
} from '../language/ast';
|
|
65
|
+
getVariableValues,
|
|
66
|
+
getArgumentValues,
|
|
67
|
+
getDirectiveValues,
|
|
68
|
+
} from './values';
|
|
63
69
|
|
|
64
70
|
/**
|
|
65
71
|
* Terminology
|
|
@@ -235,30 +241,6 @@ function buildResponse(
|
|
|
235
241
|
: { errors: exeContext.errors, data };
|
|
236
242
|
}
|
|
237
243
|
|
|
238
|
-
/**
|
|
239
|
-
* Given a ResponsePath (found in the `path` entry in the information provided
|
|
240
|
-
* as the last argument to a field resolver), return an Array of the path keys.
|
|
241
|
-
*/
|
|
242
|
-
export function responsePathAsArray(
|
|
243
|
-
path: ResponsePath,
|
|
244
|
-
): $ReadOnlyArray<string | number> {
|
|
245
|
-
const flattened = [];
|
|
246
|
-
let curr = path;
|
|
247
|
-
while (curr) {
|
|
248
|
-
flattened.push(curr.key);
|
|
249
|
-
curr = curr.prev;
|
|
250
|
-
}
|
|
251
|
-
return flattened.reverse();
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Given a ResponsePath and a key, return a new ResponsePath containing the
|
|
256
|
-
* new key.
|
|
257
|
-
*/
|
|
258
|
-
export function addPath(prev: ResponsePath | void, key: string | number) {
|
|
259
|
-
return { prev, key };
|
|
260
|
-
}
|
|
261
|
-
|
|
262
244
|
/**
|
|
263
245
|
* Essential assertions before executing to provide developer feedback for
|
|
264
246
|
* improper use of the GraphQL library.
|
|
@@ -268,13 +250,13 @@ export function assertValidExecutionArguments(
|
|
|
268
250
|
document: DocumentNode,
|
|
269
251
|
rawVariableValues: ?{ +[variable: string]: mixed, ... },
|
|
270
252
|
): void {
|
|
271
|
-
|
|
253
|
+
devAssert(document, 'Must provide document');
|
|
272
254
|
|
|
273
255
|
// If the schema used for execution is invalid, throw an error.
|
|
274
256
|
assertValidSchema(schema);
|
|
275
257
|
|
|
276
258
|
// Variables, if provided, must be an object.
|
|
277
|
-
|
|
259
|
+
devAssert(
|
|
278
260
|
rawVariableValues == null || isObjectLike(rawVariableValues),
|
|
279
261
|
'Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.',
|
|
280
262
|
);
|
|
@@ -293,15 +275,13 @@ export function buildExecutionContext(
|
|
|
293
275
|
contextValue: mixed,
|
|
294
276
|
rawVariableValues: ?{ +[variable: string]: mixed, ... },
|
|
295
277
|
operationName: ?string,
|
|
296
|
-
fieldResolver: ?GraphQLFieldResolver<
|
|
297
|
-
typeResolver?: ?GraphQLTypeResolver<
|
|
278
|
+
fieldResolver: ?GraphQLFieldResolver<mixed, mixed>,
|
|
279
|
+
typeResolver?: ?GraphQLTypeResolver<mixed, mixed>,
|
|
298
280
|
): $ReadOnlyArray<GraphQLError> | ExecutionContext {
|
|
299
|
-
const errors: Array<GraphQLError> = [];
|
|
300
281
|
let operation: OperationDefinitionNode | void;
|
|
301
282
|
let hasMultipleAssumedOperations = false;
|
|
302
283
|
const fragments: ObjMap<FragmentDefinitionNode> = Object.create(null);
|
|
303
|
-
for (
|
|
304
|
-
const definition = document.definitions[i];
|
|
284
|
+
for (const definition of document.definitions) {
|
|
305
285
|
switch (definition.kind) {
|
|
306
286
|
case Kind.OPERATION_DEFINITION:
|
|
307
287
|
if (!operationName && operation) {
|
|
@@ -321,52 +301,40 @@ export function buildExecutionContext(
|
|
|
321
301
|
|
|
322
302
|
if (!operation) {
|
|
323
303
|
if (operationName) {
|
|
324
|
-
|
|
325
|
-
new GraphQLError(`Unknown operation named "${operationName}".`),
|
|
326
|
-
);
|
|
327
|
-
} else {
|
|
328
|
-
errors.push(new GraphQLError('Must provide an operation.'));
|
|
304
|
+
return [new GraphQLError(`Unknown operation named "${operationName}".`)];
|
|
329
305
|
}
|
|
330
|
-
|
|
331
|
-
|
|
306
|
+
return [new GraphQLError('Must provide an operation.')];
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (hasMultipleAssumedOperations) {
|
|
310
|
+
return [
|
|
332
311
|
new GraphQLError(
|
|
333
312
|
'Must provide operation name if query contains multiple operations.',
|
|
334
313
|
),
|
|
335
|
-
|
|
314
|
+
];
|
|
336
315
|
}
|
|
337
316
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
);
|
|
345
|
-
|
|
346
|
-
if (coercedVariableValues.errors) {
|
|
347
|
-
errors.push(...coercedVariableValues.errors);
|
|
348
|
-
} else {
|
|
349
|
-
variableValues = coercedVariableValues.coerced;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
317
|
+
const coercedVariableValues = getVariableValues(
|
|
318
|
+
schema,
|
|
319
|
+
operation.variableDefinitions || [],
|
|
320
|
+
rawVariableValues || {},
|
|
321
|
+
{ maxErrors: 50 },
|
|
322
|
+
);
|
|
352
323
|
|
|
353
|
-
if (errors
|
|
354
|
-
return errors;
|
|
324
|
+
if (coercedVariableValues.errors) {
|
|
325
|
+
return coercedVariableValues.errors;
|
|
355
326
|
}
|
|
356
327
|
|
|
357
|
-
invariant(operation, 'Has operation if no errors.');
|
|
358
|
-
invariant(variableValues, 'Has variables if no errors.');
|
|
359
|
-
|
|
360
328
|
return {
|
|
361
329
|
schema,
|
|
362
330
|
fragments,
|
|
363
331
|
rootValue,
|
|
364
332
|
contextValue,
|
|
365
333
|
operation,
|
|
366
|
-
variableValues,
|
|
334
|
+
variableValues: coercedVariableValues.coerced,
|
|
367
335
|
fieldResolver: fieldResolver || defaultFieldResolver,
|
|
368
336
|
typeResolver: typeResolver || defaultTypeResolver,
|
|
369
|
-
errors,
|
|
337
|
+
errors: [],
|
|
370
338
|
};
|
|
371
339
|
}
|
|
372
340
|
|
|
@@ -420,7 +388,7 @@ function executeFieldsSerially(
|
|
|
420
388
|
exeContext: ExecutionContext,
|
|
421
389
|
parentType: GraphQLObjectType,
|
|
422
390
|
sourceValue: mixed,
|
|
423
|
-
path:
|
|
391
|
+
path: Path | void,
|
|
424
392
|
fields: ObjMap<Array<FieldNode>>,
|
|
425
393
|
): PromiseOrValue<ObjMap<mixed>> {
|
|
426
394
|
return promiseReduce(
|
|
@@ -459,14 +427,13 @@ function executeFields(
|
|
|
459
427
|
exeContext: ExecutionContext,
|
|
460
428
|
parentType: GraphQLObjectType,
|
|
461
429
|
sourceValue: mixed,
|
|
462
|
-
path:
|
|
430
|
+
path: Path | void,
|
|
463
431
|
fields: ObjMap<Array<FieldNode>>,
|
|
464
432
|
): PromiseOrValue<ObjMap<mixed>> {
|
|
465
433
|
const results = Object.create(null);
|
|
466
434
|
let containsPromise = false;
|
|
467
435
|
|
|
468
|
-
for (
|
|
469
|
-
const responseName = keys[i];
|
|
436
|
+
for (const responseName of Object.keys(fields)) {
|
|
470
437
|
const fieldNodes = fields[responseName];
|
|
471
438
|
const fieldPath = addPath(path, responseName);
|
|
472
439
|
const result = resolveField(
|
|
@@ -511,8 +478,7 @@ export function collectFields(
|
|
|
511
478
|
fields: ObjMap<Array<FieldNode>>,
|
|
512
479
|
visitedFragmentNames: ObjMap<boolean>,
|
|
513
480
|
): ObjMap<Array<FieldNode>> {
|
|
514
|
-
for (
|
|
515
|
-
const selection = selectionSet.selections[i];
|
|
481
|
+
for (const selection of selectionSet.selections) {
|
|
516
482
|
switch (selection.kind) {
|
|
517
483
|
case Kind.FIELD: {
|
|
518
484
|
if (!shouldIncludeNode(exeContext, selection)) {
|
|
@@ -639,7 +605,7 @@ function resolveField(
|
|
|
639
605
|
parentType: GraphQLObjectType,
|
|
640
606
|
source: mixed,
|
|
641
607
|
fieldNodes: $ReadOnlyArray<FieldNode>,
|
|
642
|
-
path:
|
|
608
|
+
path: Path,
|
|
643
609
|
): PromiseOrValue<mixed> {
|
|
644
610
|
const fieldNode = fieldNodes[0];
|
|
645
611
|
const fieldName = fieldNode.name.value;
|
|
@@ -682,10 +648,10 @@ function resolveField(
|
|
|
682
648
|
|
|
683
649
|
export function buildResolveInfo(
|
|
684
650
|
exeContext: ExecutionContext,
|
|
685
|
-
fieldDef: GraphQLField
|
|
651
|
+
fieldDef: GraphQLField<mixed, mixed>,
|
|
686
652
|
fieldNodes: $ReadOnlyArray<FieldNode>,
|
|
687
653
|
parentType: GraphQLObjectType,
|
|
688
|
-
path:
|
|
654
|
+
path: Path,
|
|
689
655
|
): GraphQLResolveInfo {
|
|
690
656
|
// The resolve function's optional fourth argument is a collection of
|
|
691
657
|
// information about the current execution state.
|
|
@@ -705,12 +671,12 @@ export function buildResolveInfo(
|
|
|
705
671
|
|
|
706
672
|
// Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
|
|
707
673
|
// function. Returns the result of resolveFn or the abrupt-return Error object.
|
|
708
|
-
export function resolveFieldValueOrError
|
|
674
|
+
export function resolveFieldValueOrError(
|
|
709
675
|
exeContext: ExecutionContext,
|
|
710
|
-
fieldDef: GraphQLField<
|
|
676
|
+
fieldDef: GraphQLField<mixed, mixed>,
|
|
711
677
|
fieldNodes: $ReadOnlyArray<FieldNode>,
|
|
712
|
-
resolveFn: GraphQLFieldResolver<
|
|
713
|
-
source:
|
|
678
|
+
resolveFn: GraphQLFieldResolver<mixed, mixed>,
|
|
679
|
+
source: mixed,
|
|
714
680
|
info: GraphQLResolveInfo,
|
|
715
681
|
): Error | mixed {
|
|
716
682
|
try {
|
|
@@ -751,7 +717,7 @@ function completeValueCatchingError(
|
|
|
751
717
|
returnType: GraphQLOutputType,
|
|
752
718
|
fieldNodes: $ReadOnlyArray<FieldNode>,
|
|
753
719
|
info: GraphQLResolveInfo,
|
|
754
|
-
path:
|
|
720
|
+
path: Path,
|
|
755
721
|
result: mixed,
|
|
756
722
|
): PromiseOrValue<mixed> {
|
|
757
723
|
try {
|
|
@@ -788,7 +754,7 @@ function handleFieldError(rawError, fieldNodes, path, returnType, exeContext) {
|
|
|
788
754
|
const error = locatedError(
|
|
789
755
|
asErrorInstance(rawError),
|
|
790
756
|
fieldNodes,
|
|
791
|
-
|
|
757
|
+
pathToArray(path),
|
|
792
758
|
);
|
|
793
759
|
|
|
794
760
|
// If the field type is non-nullable, then it is resolved without any
|
|
@@ -829,7 +795,7 @@ function completeValue(
|
|
|
829
795
|
returnType: GraphQLOutputType,
|
|
830
796
|
fieldNodes: $ReadOnlyArray<FieldNode>,
|
|
831
797
|
info: GraphQLResolveInfo,
|
|
832
|
-
path:
|
|
798
|
+
path: Path,
|
|
833
799
|
result: mixed,
|
|
834
800
|
): PromiseOrValue<mixed> {
|
|
835
801
|
// If result is an Error, throw a located error.
|
|
@@ -905,11 +871,10 @@ function completeValue(
|
|
|
905
871
|
}
|
|
906
872
|
|
|
907
873
|
// Not reachable. All possible output types have been considered.
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
(returnType: empty),
|
|
912
|
-
)}".`,
|
|
874
|
+
invariant(
|
|
875
|
+
false,
|
|
876
|
+
'Cannot complete value of unexpected output type: ' +
|
|
877
|
+
inspect((returnType: empty)),
|
|
913
878
|
);
|
|
914
879
|
}
|
|
915
880
|
|
|
@@ -922,13 +887,14 @@ function completeListValue(
|
|
|
922
887
|
returnType: GraphQLList<GraphQLOutputType>,
|
|
923
888
|
fieldNodes: $ReadOnlyArray<FieldNode>,
|
|
924
889
|
info: GraphQLResolveInfo,
|
|
925
|
-
path:
|
|
890
|
+
path: Path,
|
|
926
891
|
result: mixed,
|
|
927
892
|
): PromiseOrValue<$ReadOnlyArray<mixed>> {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
893
|
+
if (!isCollection(result)) {
|
|
894
|
+
throw new GraphQLError(
|
|
895
|
+
`Expected Iterable, but did not find one for field ${info.parentType.name}.${info.fieldName}.`,
|
|
896
|
+
);
|
|
897
|
+
}
|
|
932
898
|
|
|
933
899
|
// This is specified as a simple map, however we're optimizing the path
|
|
934
900
|
// where the list contains no Promises by avoiding creating another Promise.
|
|
@@ -962,7 +928,6 @@ function completeListValue(
|
|
|
962
928
|
* null if serialization is not possible.
|
|
963
929
|
*/
|
|
964
930
|
function completeLeafValue(returnType: GraphQLLeafType, result: mixed): mixed {
|
|
965
|
-
invariant(returnType.serialize, 'Missing serialize method on type');
|
|
966
931
|
const serializedResult = returnType.serialize(result);
|
|
967
932
|
if (isInvalid(serializedResult)) {
|
|
968
933
|
throw new Error(
|
|
@@ -982,7 +947,7 @@ function completeAbstractValue(
|
|
|
982
947
|
returnType: GraphQLAbstractType,
|
|
983
948
|
fieldNodes: $ReadOnlyArray<FieldNode>,
|
|
984
949
|
info: GraphQLResolveInfo,
|
|
985
|
-
path:
|
|
950
|
+
path: Path,
|
|
986
951
|
result: mixed,
|
|
987
952
|
): PromiseOrValue<ObjMap<mixed>> {
|
|
988
953
|
const resolveTypeFn = returnType.resolveType || exeContext.typeResolver;
|
|
@@ -1066,7 +1031,7 @@ function completeObjectValue(
|
|
|
1066
1031
|
returnType: GraphQLObjectType,
|
|
1067
1032
|
fieldNodes: $ReadOnlyArray<FieldNode>,
|
|
1068
1033
|
info: GraphQLResolveInfo,
|
|
1069
|
-
path:
|
|
1034
|
+
path: Path,
|
|
1070
1035
|
result: mixed,
|
|
1071
1036
|
): PromiseOrValue<ObjMap<mixed>> {
|
|
1072
1037
|
// If there is an isTypeOf predicate function, call it with the
|
|
@@ -1119,7 +1084,7 @@ function collectAndExecuteSubfields(
|
|
|
1119
1084
|
exeContext: ExecutionContext,
|
|
1120
1085
|
returnType: GraphQLObjectType,
|
|
1121
1086
|
fieldNodes: $ReadOnlyArray<FieldNode>,
|
|
1122
|
-
path:
|
|
1087
|
+
path: Path,
|
|
1123
1088
|
result: mixed,
|
|
1124
1089
|
): PromiseOrValue<ObjMap<mixed>> {
|
|
1125
1090
|
// Collect sub-fields to execute to complete this value.
|
|
@@ -1140,13 +1105,12 @@ function _collectSubfields(
|
|
|
1140
1105
|
): ObjMap<Array<FieldNode>> {
|
|
1141
1106
|
let subFieldNodes = Object.create(null);
|
|
1142
1107
|
const visitedFragmentNames = Object.create(null);
|
|
1143
|
-
for (
|
|
1144
|
-
|
|
1145
|
-
if (selectionSet) {
|
|
1108
|
+
for (const node of fieldNodes) {
|
|
1109
|
+
if (node.selectionSet) {
|
|
1146
1110
|
subFieldNodes = collectFields(
|
|
1147
1111
|
exeContext,
|
|
1148
1112
|
returnType,
|
|
1149
|
-
selectionSet,
|
|
1113
|
+
node.selectionSet,
|
|
1150
1114
|
subFieldNodes,
|
|
1151
1115
|
visitedFragmentNames,
|
|
1152
1116
|
);
|
|
@@ -1165,7 +1129,7 @@ function _collectSubfields(
|
|
|
1165
1129
|
* Otherwise, test each possible type for the abstract type by calling
|
|
1166
1130
|
* isTypeOf for the object being coerced, returning the first type that matches.
|
|
1167
1131
|
*/
|
|
1168
|
-
export const defaultTypeResolver: GraphQLTypeResolver<
|
|
1132
|
+
export const defaultTypeResolver: GraphQLTypeResolver<mixed, mixed> = function(
|
|
1169
1133
|
value,
|
|
1170
1134
|
contextValue,
|
|
1171
1135
|
info,
|
|
@@ -1211,12 +1175,10 @@ export const defaultTypeResolver: GraphQLTypeResolver<any, *> = function(
|
|
|
1211
1175
|
* and returns it as the result, or if it's a function, returns the result
|
|
1212
1176
|
* of calling that function while passing along args and context value.
|
|
1213
1177
|
*/
|
|
1214
|
-
export const defaultFieldResolver: GraphQLFieldResolver<
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
info,
|
|
1219
|
-
) {
|
|
1178
|
+
export const defaultFieldResolver: GraphQLFieldResolver<
|
|
1179
|
+
mixed,
|
|
1180
|
+
mixed,
|
|
1181
|
+
> = function(source: any, args, contextValue, info) {
|
|
1220
1182
|
// ensure source is a value for which property access is acceptable.
|
|
1221
1183
|
if (isObjectLike(source) || typeof source === 'function') {
|
|
1222
1184
|
const property = source[info.fieldName];
|
|
@@ -1240,7 +1202,7 @@ export function getFieldDef(
|
|
|
1240
1202
|
schema: GraphQLSchema,
|
|
1241
1203
|
parentType: GraphQLObjectType,
|
|
1242
1204
|
fieldName: string,
|
|
1243
|
-
): ?GraphQLField
|
|
1205
|
+
): ?GraphQLField<mixed, mixed> {
|
|
1244
1206
|
if (
|
|
1245
1207
|
fieldName === SchemaMetaFieldDef.name &&
|
|
1246
1208
|
schema.getQueryType() === parentType
|