graphql 14.1.1 → 14.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/error/GraphQLError.js +12 -10
- package/error/GraphQLError.js.flow +11 -6
- package/error/GraphQLError.mjs +20 -3
- package/error/formatError.js +2 -2
- package/error/formatError.js.flow +3 -3
- package/error/formatError.mjs +2 -2
- package/error/index.js +1 -1
- package/error/index.js.flow +5 -2
- package/error/index.mjs +2 -2
- package/error/locatedError.js +2 -2
- package/error/locatedError.js.flow +2 -2
- package/error/locatedError.mjs +2 -2
- package/error/printError.js +2 -2
- package/error/printError.js.flow +4 -5
- package/error/printError.mjs +2 -2
- package/error/syntaxError.js +2 -2
- package/error/syntaxError.js.flow +2 -2
- package/error/syntaxError.mjs +2 -2
- package/execution/execute.js +52 -37
- package/execution/execute.js.flow +66 -51
- package/execution/execute.mjs +50 -38
- package/execution/index.js +7 -1
- package/execution/index.js.flow +9 -4
- package/execution/index.mjs +3 -3
- package/execution/values.js +11 -11
- package/execution/values.js.flow +23 -19
- package/execution/values.mjs +11 -11
- package/graphql.js +13 -9
- package/graphql.js.flow +28 -10
- package/graphql.mjs +10 -9
- package/index.js +83 -53
- package/index.js.flow +60 -47
- package/index.mjs +26 -23
- package/jsutils/ObjMap.js +1 -1
- package/jsutils/ObjMap.js.flow +1 -1
- package/jsutils/ObjMap.mjs +1 -0
- package/jsutils/PromiseOrValue.js +1 -0
- package/jsutils/{MaybePromise.js.flow → PromiseOrValue.js.flow} +2 -2
- package/jsutils/PromiseOrValue.mjs +1 -0
- package/jsutils/dedent.js +2 -2
- package/jsutils/dedent.js.flow +1 -1
- package/jsutils/dedent.mjs +2 -2
- package/jsutils/defineToJSON.js +2 -2
- package/jsutils/defineToJSON.js.flow +1 -1
- package/jsutils/defineToJSON.mjs +2 -2
- package/jsutils/defineToStringTag.js +2 -2
- package/jsutils/defineToStringTag.js.flow +1 -1
- package/jsutils/defineToStringTag.mjs +2 -2
- package/jsutils/inspect.js +94 -19
- package/jsutils/inspect.js.flow +98 -20
- package/jsutils/inspect.mjs +94 -20
- package/jsutils/instanceOf.js +2 -2
- package/jsutils/instanceOf.js.flow +1 -1
- package/jsutils/instanceOf.mjs +2 -2
- package/jsutils/invariant.js +5 -3
- package/jsutils/invariant.js.flow +3 -2
- package/jsutils/invariant.mjs +5 -3
- package/jsutils/isInvalid.js +2 -2
- package/jsutils/isInvalid.js.flow +1 -1
- package/jsutils/isInvalid.mjs +2 -2
- package/jsutils/isNullish.js +2 -2
- package/jsutils/isNullish.js.flow +1 -1
- package/jsutils/isNullish.mjs +2 -2
- package/jsutils/isPromise.js +2 -2
- package/jsutils/isPromise.js.flow +1 -1
- package/jsutils/isPromise.mjs +2 -2
- package/jsutils/keyMap.js +4 -3
- package/jsutils/keyMap.js.flow +6 -6
- package/jsutils/keyMap.mjs +4 -3
- package/jsutils/keyValMap.js +4 -3
- package/jsutils/keyValMap.js.flow +6 -6
- package/jsutils/keyValMap.mjs +4 -3
- package/jsutils/mapValue.js +2 -2
- package/jsutils/mapValue.js.flow +2 -2
- package/jsutils/mapValue.mjs +2 -2
- package/jsutils/memoize3.js +3 -3
- package/jsutils/memoize3.js.flow +2 -2
- package/jsutils/memoize3.mjs +3 -3
- package/jsutils/nodejsCustomInspectSymbol.js +2 -2
- package/jsutils/nodejsCustomInspectSymbol.js.flow +1 -1
- package/jsutils/nodejsCustomInspectSymbol.mjs +2 -2
- package/jsutils/orList.js +2 -2
- package/jsutils/orList.js.flow +1 -1
- package/jsutils/orList.mjs +2 -2
- package/jsutils/promiseForObject.js +2 -2
- package/jsutils/promiseForObject.js.flow +2 -2
- package/jsutils/promiseForObject.mjs +2 -2
- package/jsutils/promiseReduce.js +2 -2
- package/jsutils/promiseReduce.js.flow +5 -5
- package/jsutils/promiseReduce.mjs +2 -2
- package/jsutils/quotedOrList.js +2 -2
- package/jsutils/quotedOrList.js.flow +1 -1
- package/jsutils/quotedOrList.mjs +2 -2
- package/jsutils/suggestionList.js +2 -2
- package/jsutils/suggestionList.js.flow +1 -1
- package/jsutils/suggestionList.mjs +2 -2
- package/language/ast.js +1 -1
- package/language/ast.js.flow +3 -3
- package/language/ast.mjs +1 -0
- package/language/blockString.js +114 -0
- package/language/blockString.js.flow +102 -0
- package/language/blockString.mjs +104 -0
- package/language/directiveLocation.js +2 -2
- package/language/directiveLocation.js.flow +1 -1
- package/language/directiveLocation.mjs +2 -2
- package/language/index.js +9 -9
- package/language/index.js.flow +10 -5
- package/language/index.mjs +3 -3
- package/language/kinds.js +2 -2
- package/language/kinds.js.flow +1 -1
- package/language/kinds.mjs +2 -2
- package/language/lexer.js +52 -44
- package/language/lexer.js.flow +65 -54
- package/language/lexer.mjs +49 -43
- package/language/location.js +2 -2
- package/language/location.js.flow +2 -2
- package/language/location.mjs +2 -2
- package/language/parser.js +75 -67
- package/language/parser.js.flow +138 -127
- package/language/parser.mjs +76 -68
- package/language/predicates.js +2 -2
- package/language/predicates.js.flow +2 -2
- package/language/predicates.mjs +2 -2
- package/language/printer.js +6 -14
- package/language/printer.js.flow +8 -17
- package/language/printer.mjs +5 -14
- package/language/source.js +2 -2
- package/language/source.js.flow +1 -1
- package/language/source.mjs +2 -2
- package/language/visitor.js +4 -6
- package/language/visitor.js.flow +3 -3
- package/language/visitor.mjs +4 -6
- package/package.json +1 -1
- package/polyfills/find.js +2 -2
- package/polyfills/find.js.flow +1 -1
- package/polyfills/find.mjs +2 -2
- package/polyfills/flatMap.js +38 -0
- package/polyfills/flatMap.js.flow +34 -0
- package/polyfills/flatMap.mjs +30 -0
- package/polyfills/isFinite.js +2 -2
- package/polyfills/isFinite.js.flow +1 -1
- package/polyfills/isFinite.mjs +2 -2
- package/polyfills/isInteger.js +2 -2
- package/polyfills/isInteger.js.flow +1 -1
- package/polyfills/isInteger.mjs +2 -2
- package/polyfills/objectEntries.js +2 -2
- package/polyfills/objectEntries.js.flow +2 -2
- package/polyfills/objectEntries.mjs +2 -2
- package/polyfills/objectValues.js +2 -2
- package/polyfills/objectValues.js.flow +2 -2
- package/polyfills/objectValues.mjs +2 -2
- package/subscription/asyncIteratorReject.js +1 -1
- package/subscription/asyncIteratorReject.js.flow +1 -1
- package/subscription/asyncIteratorReject.mjs +2 -2
- package/subscription/index.js +1 -1
- package/subscription/index.js.flow +1 -1
- package/subscription/index.mjs +2 -2
- package/subscription/mapAsyncIterator.js +1 -1
- package/subscription/mapAsyncIterator.js.flow +5 -5
- package/subscription/mapAsyncIterator.mjs +2 -2
- package/subscription/subscribe.js +2 -2
- package/subscription/subscribe.js.flow +6 -6
- package/subscription/subscribe.mjs +2 -2
- package/type/definition.js +138 -22
- package/type/definition.js.flow +184 -36
- package/type/definition.mjs +136 -23
- package/type/directives.js +14 -3
- package/type/directives.js.flow +24 -11
- package/type/directives.mjs +16 -5
- package/type/index.js +7 -7
- package/type/index.js.flow +8 -4
- package/type/index.mjs +10 -6
- package/type/introspection.js +14 -9
- package/type/introspection.js.flow +12 -18
- package/type/introspection.mjs +14 -9
- package/type/scalars.js +5 -4
- package/type/scalars.js.flow +4 -10
- package/type/scalars.mjs +7 -6
- package/type/schema.js +55 -3
- package/type/schema.js.flow +73 -17
- package/type/schema.mjs +56 -4
- package/type/validate.js +19 -47
- package/type/validate.js.flow +17 -29
- package/type/validate.mjs +18 -47
- package/utilities/TypeInfo.js +93 -73
- package/utilities/TypeInfo.js.flow +30 -23
- package/utilities/TypeInfo.mjs +93 -73
- package/utilities/assertValidName.js +2 -2
- package/utilities/assertValidName.js.flow +2 -2
- package/utilities/assertValidName.mjs +2 -2
- package/utilities/astFromValue.js +5 -4
- package/utilities/astFromValue.js.flow +8 -7
- package/utilities/astFromValue.mjs +7 -6
- package/utilities/buildASTSchema.js +63 -62
- package/utilities/buildASTSchema.js.flow +92 -108
- package/utilities/buildASTSchema.mjs +61 -62
- package/utilities/buildClientSchema.js +38 -45
- package/utilities/buildClientSchema.js.flow +66 -79
- package/utilities/buildClientSchema.mjs +37 -44
- package/utilities/coerceValue.js +6 -7
- package/utilities/coerceValue.js.flow +5 -4
- package/utilities/coerceValue.mjs +7 -8
- package/utilities/concatAST.js +9 -13
- package/utilities/concatAST.js.flow +4 -10
- package/utilities/concatAST.mjs +6 -13
- package/utilities/extendSchema.js +219 -511
- package/utilities/extendSchema.js.flow +195 -304
- package/utilities/extendSchema.mjs +218 -512
- package/utilities/findBreakingChanges.js +54 -95
- package/utilities/findBreakingChanges.js.flow +49 -47
- package/utilities/findBreakingChanges.mjs +80 -95
- package/utilities/findDeprecatedUsages.js +4 -4
- package/utilities/findDeprecatedUsages.js.flow +5 -5
- package/utilities/findDeprecatedUsages.mjs +4 -4
- package/utilities/getOperationAST.js +2 -2
- package/utilities/getOperationAST.js.flow +5 -2
- package/utilities/getOperationAST.mjs +2 -2
- package/utilities/getOperationRootType.js +24 -24
- package/utilities/getOperationRootType.js.flow +40 -35
- package/utilities/getOperationRootType.mjs +24 -24
- package/utilities/index.js +9 -1
- package/utilities/index.js.flow +13 -6
- package/utilities/index.mjs +13 -8
- package/utilities/introspectionFromSchema.js +6 -4
- package/utilities/introspectionFromSchema.js.flow +8 -7
- package/utilities/introspectionFromSchema.mjs +6 -5
- package/utilities/introspectionQuery.js +2 -2
- package/utilities/introspectionQuery.js.flow +2 -2
- package/utilities/introspectionQuery.mjs +2 -2
- package/utilities/isValidJSValue.js +4 -2
- package/utilities/isValidJSValue.js.flow +3 -2
- package/utilities/isValidJSValue.mjs +4 -2
- package/utilities/isValidLiteralValue.js +2 -2
- package/utilities/isValidLiteralValue.js.flow +4 -4
- package/utilities/isValidLiteralValue.mjs +2 -2
- package/utilities/lexicographicSortSchema.js +84 -123
- package/utilities/lexicographicSortSchema.js.flow +68 -96
- package/utilities/lexicographicSortSchema.mjs +84 -123
- package/utilities/schemaPrinter.js +47 -73
- package/utilities/schemaPrinter.js.flow +69 -120
- package/utilities/schemaPrinter.mjs +45 -72
- package/utilities/separateOperations.js +8 -12
- package/utilities/separateOperations.js.flow +6 -3
- package/utilities/separateOperations.mjs +8 -12
- package/utilities/stripIgnoredCharacters.js +140 -0
- package/utilities/stripIgnoredCharacters.js.flow +129 -0
- package/utilities/stripIgnoredCharacters.mjs +127 -0
- package/utilities/typeComparators.js +2 -2
- package/utilities/typeComparators.js.flow +4 -3
- package/utilities/typeComparators.mjs +2 -2
- package/utilities/typeFromAST.js +9 -4
- package/utilities/typeFromAST.js.flow +15 -9
- package/utilities/typeFromAST.mjs +6 -4
- package/utilities/valueFromAST.js +7 -4
- package/utilities/valueFromAST.js.flow +7 -5
- package/utilities/valueFromAST.mjs +6 -4
- package/utilities/valueFromASTUntyped.js +11 -6
- package/utilities/valueFromASTUntyped.js.flow +9 -5
- package/utilities/valueFromASTUntyped.mjs +10 -6
- package/validation/ValidationContext.js +1 -1
- package/validation/ValidationContext.js.flow +19 -20
- package/validation/ValidationContext.mjs +2 -2
- package/validation/index.js +1 -1
- package/validation/index.js.flow +2 -1
- package/validation/index.mjs +3 -2
- package/validation/rules/ExecutableDefinitions.js +3 -3
- package/validation/rules/ExecutableDefinitions.js.flow +4 -4
- package/validation/rules/ExecutableDefinitions.mjs +3 -3
- package/validation/rules/FieldsOnCorrectType.js +3 -3
- package/validation/rules/FieldsOnCorrectType.js.flow +7 -7
- package/validation/rules/FieldsOnCorrectType.mjs +3 -3
- package/validation/rules/FragmentsOnCompositeTypes.js +4 -4
- package/validation/rules/FragmentsOnCompositeTypes.js.flow +5 -5
- package/validation/rules/FragmentsOnCompositeTypes.mjs +4 -4
- package/validation/rules/KnownArgumentNames.js +1 -1
- package/validation/rules/KnownArgumentNames.js.flow +5 -5
- package/validation/rules/KnownArgumentNames.mjs +2 -2
- package/validation/rules/KnownDirectives.js +8 -6
- package/validation/rules/KnownDirectives.js.flow +11 -9
- package/validation/rules/KnownDirectives.mjs +8 -6
- package/validation/rules/KnownFragmentNames.js +3 -3
- package/validation/rules/KnownFragmentNames.js.flow +4 -4
- package/validation/rules/KnownFragmentNames.mjs +3 -3
- package/validation/rules/KnownTypeNames.js +2 -2
- package/validation/rules/KnownTypeNames.js.flow +6 -6
- package/validation/rules/KnownTypeNames.mjs +2 -2
- package/validation/rules/LoneAnonymousOperation.js +3 -3
- package/validation/rules/LoneAnonymousOperation.js.flow +4 -4
- package/validation/rules/LoneAnonymousOperation.mjs +3 -3
- package/validation/rules/LoneSchemaDefinition.js +2 -2
- package/validation/rules/LoneSchemaDefinition.js.flow +3 -3
- package/validation/rules/LoneSchemaDefinition.mjs +2 -2
- package/validation/rules/NoFragmentCycles.js +2 -2
- package/validation/rules/NoFragmentCycles.js.flow +4 -4
- package/validation/rules/NoFragmentCycles.mjs +2 -2
- package/validation/rules/NoUndefinedVariables.js +2 -2
- package/validation/rules/NoUndefinedVariables.js.flow +3 -3
- package/validation/rules/NoUndefinedVariables.mjs +2 -2
- package/validation/rules/NoUnusedFragments.js +7 -7
- package/validation/rules/NoUnusedFragments.js.flow +4 -4
- package/validation/rules/NoUnusedFragments.mjs +7 -7
- package/validation/rules/NoUnusedVariables.js +5 -5
- package/validation/rules/NoUnusedVariables.js.flow +6 -5
- package/validation/rules/NoUnusedVariables.mjs +5 -5
- package/validation/rules/OverlappingFieldsCanBeMerged.js +26 -23
- package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +17 -17
- package/validation/rules/OverlappingFieldsCanBeMerged.mjs +26 -23
- package/validation/rules/PossibleFragmentSpreads.js +4 -4
- package/validation/rules/PossibleFragmentSpreads.js.flow +5 -5
- package/validation/rules/PossibleFragmentSpreads.mjs +4 -4
- package/validation/rules/PossibleTypeExtensions.js +3 -3
- package/validation/rules/PossibleTypeExtensions.js.flow +5 -5
- package/validation/rules/PossibleTypeExtensions.mjs +4 -4
- package/validation/rules/ProvidedRequiredArguments.js +6 -8
- package/validation/rules/ProvidedRequiredArguments.js.flow +8 -8
- package/validation/rules/ProvidedRequiredArguments.mjs +7 -9
- package/validation/rules/ScalarLeafs.js +4 -4
- package/validation/rules/ScalarLeafs.js.flow +6 -6
- package/validation/rules/ScalarLeafs.mjs +4 -4
- package/validation/rules/SingleFieldSubscriptions.js +2 -2
- package/validation/rules/SingleFieldSubscriptions.js.flow +4 -4
- package/validation/rules/SingleFieldSubscriptions.mjs +2 -2
- package/validation/rules/UniqueArgumentNames.js +2 -2
- package/validation/rules/UniqueArgumentNames.js.flow +3 -3
- package/validation/rules/UniqueArgumentNames.mjs +2 -2
- package/validation/rules/UniqueDirectiveNames.js +2 -2
- package/validation/rules/UniqueDirectiveNames.js.flow +3 -3
- package/validation/rules/UniqueDirectiveNames.mjs +2 -2
- package/validation/rules/UniqueDirectivesPerLocation.js +3 -2
- package/validation/rules/UniqueDirectivesPerLocation.js.flow +4 -4
- package/validation/rules/UniqueDirectivesPerLocation.mjs +3 -2
- package/validation/rules/UniqueEnumValueNames.js +4 -8
- package/validation/rules/UniqueEnumValueNames.js.flow +6 -8
- package/validation/rules/UniqueEnumValueNames.mjs +4 -8
- package/validation/rules/UniqueFieldDefinitionNames.js +4 -8
- package/validation/rules/UniqueFieldDefinitionNames.js.flow +6 -8
- package/validation/rules/UniqueFieldDefinitionNames.mjs +4 -8
- package/validation/rules/UniqueFragmentNames.js +2 -2
- package/validation/rules/UniqueFragmentNames.js.flow +3 -3
- package/validation/rules/UniqueFragmentNames.mjs +2 -2
- package/validation/rules/UniqueInputFieldNames.js +2 -4
- package/validation/rules/UniqueInputFieldNames.js.flow +3 -4
- package/validation/rules/UniqueInputFieldNames.mjs +2 -4
- package/validation/rules/UniqueOperationNames.js +2 -2
- package/validation/rules/UniqueOperationNames.js.flow +3 -3
- package/validation/rules/UniqueOperationNames.mjs +2 -2
- package/validation/rules/UniqueOperationTypes.js +2 -2
- package/validation/rules/UniqueOperationTypes.js.flow +3 -3
- package/validation/rules/UniqueOperationTypes.mjs +2 -2
- package/validation/rules/UniqueTypeNames.js +2 -2
- package/validation/rules/UniqueTypeNames.js.flow +4 -4
- package/validation/rules/UniqueTypeNames.mjs +2 -2
- package/validation/rules/UniqueVariableNames.js +2 -2
- package/validation/rules/UniqueVariableNames.js.flow +4 -4
- package/validation/rules/UniqueVariableNames.mjs +2 -2
- package/validation/rules/ValuesOfCorrectType.js +2 -2
- package/validation/rules/ValuesOfCorrectType.js.flow +5 -5
- package/validation/rules/ValuesOfCorrectType.mjs +2 -2
- package/validation/rules/VariablesAreInputTypes.js +3 -3
- package/validation/rules/VariablesAreInputTypes.js.flow +5 -5
- package/validation/rules/VariablesAreInputTypes.mjs +3 -3
- package/validation/rules/VariablesInAllowedPosition.js +3 -3
- package/validation/rules/VariablesInAllowedPosition.js.flow +7 -8
- package/validation/rules/VariablesInAllowedPosition.mjs +3 -3
- package/validation/specifiedRules.js +2 -2
- package/validation/specifiedRules.js.flow +13 -6
- package/validation/specifiedRules.mjs +7 -7
- package/validation/validate.js +2 -2
- package/validation/validate.js.flow +10 -6
- package/validation/validate.mjs +2 -2
- package/jsutils/MaybePromise.js +0 -1
- package/jsutils/MaybePromise.mjs +0 -0
- package/language/blockStringValue.js +0 -73
- package/language/blockStringValue.js.flow +0 -64
- package/language/blockStringValue.mjs +0 -66
package/type/definition.js.flow
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -14,33 +14,34 @@ import instanceOf from '../jsutils/instanceOf';
|
|
|
14
14
|
import inspect from '../jsutils/inspect';
|
|
15
15
|
import invariant from '../jsutils/invariant';
|
|
16
16
|
import keyMap from '../jsutils/keyMap';
|
|
17
|
+
import keyValMap from '../jsutils/keyValMap';
|
|
17
18
|
import mapValue from '../jsutils/mapValue';
|
|
18
|
-
import type
|
|
19
|
+
import { type ObjMap } from '../jsutils/ObjMap';
|
|
19
20
|
import { Kind } from '../language/kinds';
|
|
20
21
|
import { valueFromASTUntyped } from '../utilities/valueFromASTUntyped';
|
|
21
|
-
import
|
|
22
|
-
ScalarTypeDefinitionNode,
|
|
23
|
-
ObjectTypeDefinitionNode,
|
|
24
|
-
FieldDefinitionNode,
|
|
25
|
-
InputValueDefinitionNode,
|
|
26
|
-
InterfaceTypeDefinitionNode,
|
|
27
|
-
UnionTypeDefinitionNode,
|
|
28
|
-
EnumTypeDefinitionNode,
|
|
29
|
-
EnumValueDefinitionNode,
|
|
30
|
-
InputObjectTypeDefinitionNode,
|
|
31
|
-
ScalarTypeExtensionNode,
|
|
32
|
-
ObjectTypeExtensionNode,
|
|
33
|
-
InterfaceTypeExtensionNode,
|
|
34
|
-
UnionTypeExtensionNode,
|
|
35
|
-
EnumTypeExtensionNode,
|
|
36
|
-
InputObjectTypeExtensionNode,
|
|
37
|
-
OperationDefinitionNode,
|
|
38
|
-
FieldNode,
|
|
39
|
-
FragmentDefinitionNode,
|
|
40
|
-
ValueNode,
|
|
22
|
+
import {
|
|
23
|
+
type ScalarTypeDefinitionNode,
|
|
24
|
+
type ObjectTypeDefinitionNode,
|
|
25
|
+
type FieldDefinitionNode,
|
|
26
|
+
type InputValueDefinitionNode,
|
|
27
|
+
type InterfaceTypeDefinitionNode,
|
|
28
|
+
type UnionTypeDefinitionNode,
|
|
29
|
+
type EnumTypeDefinitionNode,
|
|
30
|
+
type EnumValueDefinitionNode,
|
|
31
|
+
type InputObjectTypeDefinitionNode,
|
|
32
|
+
type ScalarTypeExtensionNode,
|
|
33
|
+
type ObjectTypeExtensionNode,
|
|
34
|
+
type InterfaceTypeExtensionNode,
|
|
35
|
+
type UnionTypeExtensionNode,
|
|
36
|
+
type EnumTypeExtensionNode,
|
|
37
|
+
type InputObjectTypeExtensionNode,
|
|
38
|
+
type OperationDefinitionNode,
|
|
39
|
+
type FieldNode,
|
|
40
|
+
type FragmentDefinitionNode,
|
|
41
|
+
type ValueNode,
|
|
41
42
|
} from '../language/ast';
|
|
42
|
-
import type
|
|
43
|
-
import type
|
|
43
|
+
import { type GraphQLSchema } from './schema';
|
|
44
|
+
import { type PromiseOrValue } from '../jsutils/PromiseOrValue';
|
|
44
45
|
|
|
45
46
|
// Predicates & Assertions
|
|
46
47
|
|
|
@@ -360,6 +361,9 @@ export function GraphQLList(ofType) {
|
|
|
360
361
|
(GraphQLList.prototype: any).toString = function toString() {
|
|
361
362
|
return '[' + String(this.ofType) + ']';
|
|
362
363
|
};
|
|
364
|
+
|
|
365
|
+
// Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
|
|
366
|
+
defineToStringTag(GraphQLList);
|
|
363
367
|
defineToJSON(GraphQLList);
|
|
364
368
|
|
|
365
369
|
/**
|
|
@@ -401,6 +405,9 @@ export function GraphQLNonNull(ofType) {
|
|
|
401
405
|
(GraphQLNonNull.prototype: any).toString = function toString() {
|
|
402
406
|
return String(this.ofType) + '!';
|
|
403
407
|
};
|
|
408
|
+
|
|
409
|
+
// Conditionally apply `[Symbol.toStringTag]` if `Symbol`s are supported
|
|
410
|
+
defineToStringTag(GraphQLNonNull);
|
|
404
411
|
defineToJSON(GraphQLNonNull);
|
|
405
412
|
|
|
406
413
|
/**
|
|
@@ -511,6 +518,10 @@ function resolveThunk<+T>(thunk: Thunk<T>): T {
|
|
|
511
518
|
return typeof thunk === 'function' ? thunk() : thunk;
|
|
512
519
|
}
|
|
513
520
|
|
|
521
|
+
function undefineIfEmpty<T>(arr: ?$ReadOnlyArray<T>): ?$ReadOnlyArray<T> {
|
|
522
|
+
return arr && arr.length > 0 ? arr : undefined;
|
|
523
|
+
}
|
|
524
|
+
|
|
514
525
|
/**
|
|
515
526
|
* Scalar Type Definition
|
|
516
527
|
*
|
|
@@ -551,7 +562,7 @@ export class GraphQLScalarType {
|
|
|
551
562
|
this.parseValue = config.parseValue || (value => value);
|
|
552
563
|
this.parseLiteral = config.parseLiteral || valueFromASTUntyped;
|
|
553
564
|
this.astNode = config.astNode;
|
|
554
|
-
this.extensionASTNodes = config.extensionASTNodes;
|
|
565
|
+
this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
|
|
555
566
|
invariant(typeof config.name === 'string', 'Must provide name.');
|
|
556
567
|
invariant(
|
|
557
568
|
typeof config.serialize === 'function',
|
|
@@ -569,6 +580,23 @@ export class GraphQLScalarType {
|
|
|
569
580
|
}
|
|
570
581
|
}
|
|
571
582
|
|
|
583
|
+
toConfig(): {|
|
|
584
|
+
...GraphQLScalarTypeConfig<*, *>,
|
|
585
|
+
parseValue: GraphQLScalarValueParser<*>,
|
|
586
|
+
parseLiteral: GraphQLScalarLiteralParser<*>,
|
|
587
|
+
extensionASTNodes: $ReadOnlyArray<ScalarTypeExtensionNode>,
|
|
588
|
+
|} {
|
|
589
|
+
return {
|
|
590
|
+
name: this.name,
|
|
591
|
+
description: this.description,
|
|
592
|
+
serialize: this.serialize,
|
|
593
|
+
parseValue: this.parseValue,
|
|
594
|
+
parseLiteral: this.parseLiteral,
|
|
595
|
+
astNode: this.astNode,
|
|
596
|
+
extensionASTNodes: this.extensionASTNodes || [],
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
|
|
572
600
|
toString(): string {
|
|
573
601
|
return this.name;
|
|
574
602
|
}
|
|
@@ -649,7 +677,7 @@ export class GraphQLObjectType {
|
|
|
649
677
|
this.name = config.name;
|
|
650
678
|
this.description = config.description;
|
|
651
679
|
this.astNode = config.astNode;
|
|
652
|
-
this.extensionASTNodes = config.extensionASTNodes;
|
|
680
|
+
this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
|
|
653
681
|
this.isTypeOf = config.isTypeOf;
|
|
654
682
|
this._fields = defineFieldMap.bind(undefined, config);
|
|
655
683
|
this._interfaces = defineInterfaces.bind(undefined, config);
|
|
@@ -675,6 +703,23 @@ export class GraphQLObjectType {
|
|
|
675
703
|
return this._interfaces;
|
|
676
704
|
}
|
|
677
705
|
|
|
706
|
+
toConfig(): {|
|
|
707
|
+
...GraphQLObjectTypeConfig<*, *>,
|
|
708
|
+
interfaces: Array<GraphQLInterfaceType>,
|
|
709
|
+
fields: GraphQLFieldConfigMap<*, *>,
|
|
710
|
+
extensionASTNodes: $ReadOnlyArray<ObjectTypeExtensionNode>,
|
|
711
|
+
|} {
|
|
712
|
+
return {
|
|
713
|
+
name: this.name,
|
|
714
|
+
description: this.description,
|
|
715
|
+
isTypeOf: this.isTypeOf,
|
|
716
|
+
interfaces: this.getInterfaces(),
|
|
717
|
+
fields: fieldsToFieldsConfig(this.getFields()),
|
|
718
|
+
astNode: this.astNode,
|
|
719
|
+
extensionASTNodes: this.extensionASTNodes || [],
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
|
|
678
723
|
toString(): string {
|
|
679
724
|
return this.name;
|
|
680
725
|
}
|
|
@@ -714,7 +759,7 @@ function defineFieldMap<TSource, TContext>(
|
|
|
714
759
|
`${config.name}.${fieldName} field config must be an object`,
|
|
715
760
|
);
|
|
716
761
|
invariant(
|
|
717
|
-
!
|
|
762
|
+
!('isDeprecated' in fieldConfig),
|
|
718
763
|
`${config.name}.${fieldName} should provide "deprecationReason" ` +
|
|
719
764
|
'instead of "isDeprecated".',
|
|
720
765
|
);
|
|
@@ -752,6 +797,33 @@ function isPlainObj(obj) {
|
|
|
752
797
|
return obj && typeof obj === 'object' && !Array.isArray(obj);
|
|
753
798
|
}
|
|
754
799
|
|
|
800
|
+
function fieldsToFieldsConfig(fields) {
|
|
801
|
+
return mapValue(fields, field => ({
|
|
802
|
+
type: field.type,
|
|
803
|
+
args: argsToArgsConfig(field.args),
|
|
804
|
+
resolve: field.resolve,
|
|
805
|
+
subscribe: field.subscribe,
|
|
806
|
+
deprecationReason: field.deprecationReason,
|
|
807
|
+
description: field.description,
|
|
808
|
+
astNode: field.astNode,
|
|
809
|
+
}));
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
export function argsToArgsConfig(
|
|
813
|
+
args: Array<GraphQLArgument>,
|
|
814
|
+
): GraphQLFieldConfigArgumentMap {
|
|
815
|
+
return keyValMap(
|
|
816
|
+
args,
|
|
817
|
+
arg => arg.name,
|
|
818
|
+
arg => ({
|
|
819
|
+
type: arg.type,
|
|
820
|
+
defaultValue: arg.defaultValue,
|
|
821
|
+
description: arg.description,
|
|
822
|
+
astNode: arg.astNode,
|
|
823
|
+
}),
|
|
824
|
+
);
|
|
825
|
+
}
|
|
826
|
+
|
|
755
827
|
export type GraphQLObjectTypeConfig<TSource, TContext> = {|
|
|
756
828
|
name: string,
|
|
757
829
|
interfaces?: Thunk<?Array<GraphQLInterfaceType>>,
|
|
@@ -766,13 +838,14 @@ export type GraphQLTypeResolver<TSource, TContext> = (
|
|
|
766
838
|
value: TSource,
|
|
767
839
|
context: TContext,
|
|
768
840
|
info: GraphQLResolveInfo,
|
|
769
|
-
|
|
841
|
+
abstractType: GraphQLAbstractType,
|
|
842
|
+
) => PromiseOrValue<?GraphQLObjectType | string>;
|
|
770
843
|
|
|
771
844
|
export type GraphQLIsTypeOfFn<TSource, TContext> = (
|
|
772
845
|
source: TSource,
|
|
773
846
|
context: TContext,
|
|
774
847
|
info: GraphQLResolveInfo,
|
|
775
|
-
) =>
|
|
848
|
+
) => PromiseOrValue<boolean>;
|
|
776
849
|
|
|
777
850
|
export type GraphQLFieldResolver<
|
|
778
851
|
TSource,
|
|
@@ -893,7 +966,7 @@ export class GraphQLInterfaceType {
|
|
|
893
966
|
this.name = config.name;
|
|
894
967
|
this.description = config.description;
|
|
895
968
|
this.astNode = config.astNode;
|
|
896
|
-
this.extensionASTNodes = config.extensionASTNodes;
|
|
969
|
+
this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
|
|
897
970
|
this.resolveType = config.resolveType;
|
|
898
971
|
this._fields = defineFieldMap.bind(undefined, config);
|
|
899
972
|
invariant(typeof config.name === 'string', 'Must provide name.');
|
|
@@ -911,6 +984,21 @@ export class GraphQLInterfaceType {
|
|
|
911
984
|
return this._fields;
|
|
912
985
|
}
|
|
913
986
|
|
|
987
|
+
toConfig(): {|
|
|
988
|
+
...GraphQLInterfaceTypeConfig<*, *>,
|
|
989
|
+
fields: GraphQLFieldConfigMap<*, *>,
|
|
990
|
+
extensionASTNodes: $ReadOnlyArray<InterfaceTypeExtensionNode>,
|
|
991
|
+
|} {
|
|
992
|
+
return {
|
|
993
|
+
name: this.name,
|
|
994
|
+
description: this.description,
|
|
995
|
+
resolveType: this.resolveType,
|
|
996
|
+
fields: fieldsToFieldsConfig(this.getFields()),
|
|
997
|
+
astNode: this.astNode,
|
|
998
|
+
extensionASTNodes: this.extensionASTNodes || [],
|
|
999
|
+
};
|
|
1000
|
+
}
|
|
1001
|
+
|
|
914
1002
|
toString(): string {
|
|
915
1003
|
return this.name;
|
|
916
1004
|
}
|
|
@@ -970,7 +1058,7 @@ export class GraphQLUnionType {
|
|
|
970
1058
|
this.name = config.name;
|
|
971
1059
|
this.description = config.description;
|
|
972
1060
|
this.astNode = config.astNode;
|
|
973
|
-
this.extensionASTNodes = config.extensionASTNodes;
|
|
1061
|
+
this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
|
|
974
1062
|
this.resolveType = config.resolveType;
|
|
975
1063
|
this._types = defineTypes.bind(undefined, config);
|
|
976
1064
|
invariant(typeof config.name === 'string', 'Must provide name.');
|
|
@@ -988,6 +1076,21 @@ export class GraphQLUnionType {
|
|
|
988
1076
|
return this._types;
|
|
989
1077
|
}
|
|
990
1078
|
|
|
1079
|
+
toConfig(): {|
|
|
1080
|
+
...GraphQLUnionTypeConfig<*, *>,
|
|
1081
|
+
types: Array<GraphQLObjectType>,
|
|
1082
|
+
extensionASTNodes: $ReadOnlyArray<UnionTypeExtensionNode>,
|
|
1083
|
+
|} {
|
|
1084
|
+
return {
|
|
1085
|
+
name: this.name,
|
|
1086
|
+
description: this.description,
|
|
1087
|
+
resolveType: this.resolveType,
|
|
1088
|
+
types: this.getTypes(),
|
|
1089
|
+
astNode: this.astNode,
|
|
1090
|
+
extensionASTNodes: this.extensionASTNodes || [],
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
|
|
991
1094
|
toString(): string {
|
|
992
1095
|
return this.name;
|
|
993
1096
|
}
|
|
@@ -1058,7 +1161,7 @@ export class GraphQLEnumType /* <T> */ {
|
|
|
1058
1161
|
this.name = config.name;
|
|
1059
1162
|
this.description = config.description;
|
|
1060
1163
|
this.astNode = config.astNode;
|
|
1061
|
-
this.extensionASTNodes = config.extensionASTNodes;
|
|
1164
|
+
this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
|
|
1062
1165
|
this._values = defineEnumValues(this, config.values);
|
|
1063
1166
|
this._valueLookup = new Map(
|
|
1064
1167
|
this._values.map(enumValue => [enumValue.value, enumValue]),
|
|
@@ -1102,6 +1205,30 @@ export class GraphQLEnumType /* <T> */ {
|
|
|
1102
1205
|
}
|
|
1103
1206
|
}
|
|
1104
1207
|
|
|
1208
|
+
toConfig(): {|
|
|
1209
|
+
...GraphQLEnumTypeConfig,
|
|
1210
|
+
extensionASTNodes: $ReadOnlyArray<EnumTypeExtensionNode>,
|
|
1211
|
+
|} {
|
|
1212
|
+
const values = keyValMap(
|
|
1213
|
+
this.getValues(),
|
|
1214
|
+
value => value.name,
|
|
1215
|
+
value => ({
|
|
1216
|
+
description: value.description,
|
|
1217
|
+
value: value.value,
|
|
1218
|
+
deprecationReason: value.deprecationReason,
|
|
1219
|
+
astNode: value.astNode,
|
|
1220
|
+
}),
|
|
1221
|
+
);
|
|
1222
|
+
|
|
1223
|
+
return {
|
|
1224
|
+
name: this.name,
|
|
1225
|
+
description: this.description,
|
|
1226
|
+
values,
|
|
1227
|
+
astNode: this.astNode,
|
|
1228
|
+
extensionASTNodes: this.extensionASTNodes || [],
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1105
1232
|
toString(): string {
|
|
1106
1233
|
return this.name;
|
|
1107
1234
|
}
|
|
@@ -1126,7 +1253,7 @@ function defineEnumValues(
|
|
|
1126
1253
|
`representing an internal value but got: ${inspect(value)}.`,
|
|
1127
1254
|
);
|
|
1128
1255
|
invariant(
|
|
1129
|
-
!
|
|
1256
|
+
!('isDeprecated' in value),
|
|
1130
1257
|
`${type.name}.${valueName} should provide "deprecationReason" instead ` +
|
|
1131
1258
|
'of "isDeprecated".',
|
|
1132
1259
|
);
|
|
@@ -1136,7 +1263,7 @@ function defineEnumValues(
|
|
|
1136
1263
|
isDeprecated: Boolean(value.deprecationReason),
|
|
1137
1264
|
deprecationReason: value.deprecationReason,
|
|
1138
1265
|
astNode: value.astNode,
|
|
1139
|
-
value:
|
|
1266
|
+
value: 'value' in value ? value.value : valueName,
|
|
1140
1267
|
};
|
|
1141
1268
|
});
|
|
1142
1269
|
}
|
|
@@ -1199,7 +1326,7 @@ export class GraphQLInputObjectType {
|
|
|
1199
1326
|
this.name = config.name;
|
|
1200
1327
|
this.description = config.description;
|
|
1201
1328
|
this.astNode = config.astNode;
|
|
1202
|
-
this.extensionASTNodes = config.extensionASTNodes;
|
|
1329
|
+
this.extensionASTNodes = undefineIfEmpty(config.extensionASTNodes);
|
|
1203
1330
|
this._fields = defineInputFieldMap.bind(undefined, config);
|
|
1204
1331
|
invariant(typeof config.name === 'string', 'Must provide name.');
|
|
1205
1332
|
}
|
|
@@ -1211,6 +1338,27 @@ export class GraphQLInputObjectType {
|
|
|
1211
1338
|
return this._fields;
|
|
1212
1339
|
}
|
|
1213
1340
|
|
|
1341
|
+
toConfig(): {|
|
|
1342
|
+
...GraphQLInputObjectTypeConfig,
|
|
1343
|
+
fields: GraphQLInputFieldConfigMap,
|
|
1344
|
+
extensionASTNodes: $ReadOnlyArray<InputObjectTypeExtensionNode>,
|
|
1345
|
+
|} {
|
|
1346
|
+
const fields = mapValue(this.getFields(), field => ({
|
|
1347
|
+
description: field.description,
|
|
1348
|
+
type: field.type,
|
|
1349
|
+
defaultValue: field.defaultValue,
|
|
1350
|
+
astNode: field.astNode,
|
|
1351
|
+
}));
|
|
1352
|
+
|
|
1353
|
+
return {
|
|
1354
|
+
name: this.name,
|
|
1355
|
+
description: this.description,
|
|
1356
|
+
fields,
|
|
1357
|
+
astNode: this.astNode,
|
|
1358
|
+
extensionASTNodes: this.extensionASTNodes || [],
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1214
1362
|
toString(): string {
|
|
1215
1363
|
return this.name;
|
|
1216
1364
|
}
|
|
@@ -1231,7 +1379,7 @@ function defineInputFieldMap(
|
|
|
1231
1379
|
);
|
|
1232
1380
|
return mapValue(fieldMap, (fieldConfig, fieldName) => {
|
|
1233
1381
|
invariant(
|
|
1234
|
-
!
|
|
1382
|
+
!('resolve' in fieldConfig),
|
|
1235
1383
|
`${config.name}.${fieldName} field has a resolve property, but ` +
|
|
1236
1384
|
'Input Types cannot define resolvers.',
|
|
1237
1385
|
);
|