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
|
@@ -3,14 +3,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
3
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Copyright (c)
|
|
6
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
10
|
*
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
+
import flatMap from '../polyfills/flatMap';
|
|
13
14
|
import objectValues from '../polyfills/objectValues';
|
|
15
|
+
import inspect from '../jsutils/inspect';
|
|
14
16
|
import invariant from '../jsutils/invariant';
|
|
15
17
|
import mapValue from '../jsutils/mapValue';
|
|
16
18
|
import keyValMap from '../jsutils/keyValMap';
|
|
@@ -51,14 +53,14 @@ export function extendSchema(schema, documentAST, options) {
|
|
|
51
53
|
} // Collect the type definitions and extensions found in the document.
|
|
52
54
|
|
|
53
55
|
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
+
var typeDefs = [];
|
|
57
|
+
var typeExtsMap = Object.create(null); // New directives and types are separate because a directives and types can
|
|
56
58
|
// have the same name. For example, a type named "skip".
|
|
57
59
|
|
|
58
|
-
var
|
|
60
|
+
var directiveDefs = [];
|
|
59
61
|
var schemaDef; // Schema extensions are collected which may add additional operation types.
|
|
60
62
|
|
|
61
|
-
var
|
|
63
|
+
var schemaExts = [];
|
|
62
64
|
var _iteratorNormalCompletion = true;
|
|
63
65
|
var _didIteratorError = false;
|
|
64
66
|
var _iteratorError = undefined;
|
|
@@ -70,16 +72,15 @@ export function extendSchema(schema, documentAST, options) {
|
|
|
70
72
|
if (def.kind === Kind.SCHEMA_DEFINITION) {
|
|
71
73
|
schemaDef = def;
|
|
72
74
|
} else if (def.kind === Kind.SCHEMA_EXTENSION) {
|
|
73
|
-
|
|
75
|
+
schemaExts.push(def);
|
|
74
76
|
} else if (isTypeDefinitionNode(def)) {
|
|
75
|
-
|
|
76
|
-
typeDefinitionMap[typeName] = def;
|
|
77
|
+
typeDefs.push(def);
|
|
77
78
|
} else if (isTypeExtensionNode(def)) {
|
|
78
79
|
var extendedTypeName = def.name.value;
|
|
79
|
-
var
|
|
80
|
-
|
|
80
|
+
var existingTypeExts = typeExtsMap[extendedTypeName];
|
|
81
|
+
typeExtsMap[extendedTypeName] = existingTypeExts ? existingTypeExts.concat([def]) : [def];
|
|
81
82
|
} else if (def.kind === Kind.DIRECTIVE_DEFINITION) {
|
|
82
|
-
|
|
83
|
+
directiveDefs.push(def);
|
|
83
84
|
}
|
|
84
85
|
} // If this document contains no new types, extensions, or directives then
|
|
85
86
|
// return the same unmodified GraphQLSchema instance.
|
|
@@ -99,599 +100,304 @@ export function extendSchema(schema, documentAST, options) {
|
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
if (Object.keys(
|
|
103
|
+
if (Object.keys(typeExtsMap).length === 0 && typeDefs.length === 0 && directiveDefs.length === 0 && schemaExts.length === 0 && !schemaDef) {
|
|
103
104
|
return schema;
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
var schemaConfig = schema.toConfig();
|
|
108
|
+
var astBuilder = new ASTDefinitionBuilder(options, function (typeName) {
|
|
109
|
+
var type = typeMap[typeName];
|
|
110
|
+
!type ? invariant(0, "Unknown type: \"".concat(typeName, "\".")) : void 0;
|
|
111
|
+
return type;
|
|
110
112
|
});
|
|
111
|
-
var
|
|
113
|
+
var typeMap = keyValMap(typeDefs, function (node) {
|
|
114
|
+
return node.name.value;
|
|
115
|
+
}, function (node) {
|
|
116
|
+
return astBuilder.buildType(node);
|
|
117
|
+
});
|
|
118
|
+
var _iteratorNormalCompletion2 = true;
|
|
119
|
+
var _didIteratorError2 = false;
|
|
120
|
+
var _iteratorError2 = undefined;
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
for (var _iterator2 = schemaConfig.types[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
124
|
+
var existingType = _step2.value;
|
|
125
|
+
typeMap[existingType.name] = extendNamedType(existingType);
|
|
126
|
+
} // Get the extended root operation types.
|
|
127
|
+
|
|
128
|
+
} catch (err) {
|
|
129
|
+
_didIteratorError2 = true;
|
|
130
|
+
_iteratorError2 = err;
|
|
131
|
+
} finally {
|
|
132
|
+
try {
|
|
133
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
134
|
+
_iterator2.return();
|
|
135
|
+
}
|
|
136
|
+
} finally {
|
|
137
|
+
if (_didIteratorError2) {
|
|
138
|
+
throw _iteratorError2;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
112
142
|
|
|
113
143
|
var operationTypes = {
|
|
114
|
-
query:
|
|
115
|
-
mutation:
|
|
116
|
-
subscription:
|
|
144
|
+
query: schemaConfig.query && schemaConfig.query.name,
|
|
145
|
+
mutation: schemaConfig.mutation && schemaConfig.mutation.name,
|
|
146
|
+
subscription: schemaConfig.subscription && schemaConfig.subscription.name
|
|
117
147
|
};
|
|
118
148
|
|
|
119
149
|
if (schemaDef) {
|
|
120
|
-
var
|
|
121
|
-
var
|
|
122
|
-
var
|
|
150
|
+
var _iteratorNormalCompletion3 = true;
|
|
151
|
+
var _didIteratorError3 = false;
|
|
152
|
+
var _iteratorError3 = undefined;
|
|
123
153
|
|
|
124
154
|
try {
|
|
125
|
-
for (var
|
|
126
|
-
var _ref2 =
|
|
155
|
+
for (var _iterator3 = schemaDef.operationTypes[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
156
|
+
var _ref2 = _step3.value;
|
|
127
157
|
var operation = _ref2.operation;
|
|
128
158
|
var type = _ref2.type;
|
|
129
|
-
|
|
130
|
-
// typed values, that would throw immediately while type system
|
|
131
|
-
// validation with validateSchema() will produce more actionable results.
|
|
132
|
-
operationTypes[operation] = astBuilder.buildType(type);
|
|
159
|
+
operationTypes[operation] = type.name.value;
|
|
133
160
|
}
|
|
134
161
|
} catch (err) {
|
|
135
|
-
|
|
136
|
-
|
|
162
|
+
_didIteratorError3 = true;
|
|
163
|
+
_iteratorError3 = err;
|
|
137
164
|
} finally {
|
|
138
165
|
try {
|
|
139
|
-
if (!
|
|
140
|
-
|
|
166
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
167
|
+
_iterator3.return();
|
|
141
168
|
}
|
|
142
169
|
} finally {
|
|
143
|
-
if (
|
|
144
|
-
throw
|
|
170
|
+
if (_didIteratorError3) {
|
|
171
|
+
throw _iteratorError3;
|
|
145
172
|
}
|
|
146
173
|
}
|
|
147
174
|
}
|
|
148
175
|
} // Then, incorporate schema definition and all schema extensions.
|
|
149
176
|
|
|
150
177
|
|
|
151
|
-
for (var _i = 0; _i <
|
|
152
|
-
var
|
|
178
|
+
for (var _i = 0, _schemaExts = schemaExts; _i < _schemaExts.length; _i++) {
|
|
179
|
+
var schemaExt = _schemaExts[_i];
|
|
153
180
|
|
|
154
|
-
if (
|
|
155
|
-
var
|
|
156
|
-
var
|
|
157
|
-
var
|
|
181
|
+
if (schemaExt.operationTypes) {
|
|
182
|
+
var _iteratorNormalCompletion4 = true;
|
|
183
|
+
var _didIteratorError4 = false;
|
|
184
|
+
var _iteratorError4 = undefined;
|
|
158
185
|
|
|
159
186
|
try {
|
|
160
|
-
for (var
|
|
161
|
-
var _ref4 =
|
|
187
|
+
for (var _iterator4 = schemaExt.operationTypes[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
|
188
|
+
var _ref4 = _step4.value;
|
|
162
189
|
var _operation = _ref4.operation;
|
|
163
190
|
var _type = _ref4.type;
|
|
164
|
-
|
|
165
|
-
// typed values, that would throw immediately while type system
|
|
166
|
-
// validation with validateSchema() will produce more actionable results.
|
|
167
|
-
operationTypes[_operation] = astBuilder.buildType(_type);
|
|
191
|
+
operationTypes[_operation] = _type.name.value;
|
|
168
192
|
}
|
|
169
193
|
} catch (err) {
|
|
170
|
-
|
|
171
|
-
|
|
194
|
+
_didIteratorError4 = true;
|
|
195
|
+
_iteratorError4 = err;
|
|
172
196
|
} finally {
|
|
173
197
|
try {
|
|
174
|
-
if (!
|
|
175
|
-
|
|
198
|
+
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
|
199
|
+
_iterator4.return();
|
|
176
200
|
}
|
|
177
201
|
} finally {
|
|
178
|
-
if (
|
|
179
|
-
throw
|
|
202
|
+
if (_didIteratorError4) {
|
|
203
|
+
throw _iteratorError4;
|
|
180
204
|
}
|
|
181
205
|
}
|
|
182
206
|
}
|
|
183
207
|
}
|
|
184
|
-
}
|
|
208
|
+
} // Support both original legacy names and extended legacy names.
|
|
185
209
|
|
|
186
|
-
var schemaExtensionASTNodes = schemaExtensions ? schema.extensionASTNodes ? schema.extensionASTNodes.concat(schemaExtensions) : schemaExtensions : schema.extensionASTNodes;
|
|
187
|
-
var types = [].concat(objectValues(schema.getTypeMap()).map(function (type) {
|
|
188
|
-
return extendNamedType(type);
|
|
189
|
-
}), objectValues(typeDefinitionMap).map(function (type) {
|
|
190
|
-
return astBuilder.buildType(type);
|
|
191
|
-
})); // Support both original legacy names and extended legacy names.
|
|
192
210
|
|
|
193
|
-
var allowedLegacyNames =
|
|
211
|
+
var allowedLegacyNames = schemaConfig.allowedLegacyNames.concat(options && options.allowedLegacyNames || []); // Then produce and return a Schema with these types.
|
|
194
212
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
213
|
+
return new GraphQLSchema({
|
|
214
|
+
// Note: While this could make early assertions to get the correctly
|
|
215
|
+
// typed values, that would throw immediately while type system
|
|
216
|
+
// validation with validateSchema() will produce more actionable results.
|
|
217
|
+
query: getMaybeTypeByName(operationTypes.query),
|
|
218
|
+
mutation: getMaybeTypeByName(operationTypes.mutation),
|
|
219
|
+
subscription: getMaybeTypeByName(operationTypes.subscription),
|
|
220
|
+
types: objectValues(typeMap),
|
|
198
221
|
directives: getMergedDirectives(),
|
|
199
|
-
astNode:
|
|
200
|
-
extensionASTNodes:
|
|
222
|
+
astNode: schemaDef || schemaConfig.astNode,
|
|
223
|
+
extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExts),
|
|
201
224
|
allowedLegacyNames: allowedLegacyNames
|
|
202
|
-
})
|
|
225
|
+
}); // Below are functions used for producing this schema that have closed over
|
|
203
226
|
// this scope and have access to the schema, cache, and newly defined types.
|
|
204
227
|
|
|
228
|
+
function replaceType(type) {
|
|
229
|
+
if (isListType(type)) {
|
|
230
|
+
return new GraphQLList(replaceType(type.ofType));
|
|
231
|
+
} else if (isNonNullType(type)) {
|
|
232
|
+
return new GraphQLNonNull(replaceType(type.ofType));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return replaceNamedType(type);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function replaceNamedType(type) {
|
|
239
|
+
return typeMap[type.name];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function getMaybeTypeByName(typeName) {
|
|
243
|
+
return typeName ? typeMap[typeName] : null;
|
|
244
|
+
}
|
|
245
|
+
|
|
205
246
|
function getMergedDirectives() {
|
|
206
247
|
var existingDirectives = schema.getDirectives().map(extendDirective);
|
|
207
248
|
!existingDirectives ? invariant(0, 'schema must have default directives') : void 0;
|
|
208
|
-
return existingDirectives.concat(
|
|
249
|
+
return existingDirectives.concat(directiveDefs.map(function (node) {
|
|
209
250
|
return astBuilder.buildDirective(node);
|
|
210
251
|
}));
|
|
211
252
|
}
|
|
212
253
|
|
|
213
|
-
function extendMaybeNamedType(type) {
|
|
214
|
-
return type ? extendNamedType(type) : null;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
254
|
function extendNamedType(type) {
|
|
218
255
|
if (isIntrospectionType(type) || isSpecifiedScalarType(type)) {
|
|
219
256
|
// Builtin types are not extended.
|
|
220
257
|
return type;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
if (
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
return extendTypeCache[name];
|
|
258
|
+
} else if (isScalarType(type)) {
|
|
259
|
+
return extendScalarType(type);
|
|
260
|
+
} else if (isObjectType(type)) {
|
|
261
|
+
return extendObjectType(type);
|
|
262
|
+
} else if (isInterfaceType(type)) {
|
|
263
|
+
return extendInterfaceType(type);
|
|
264
|
+
} else if (isUnionType(type)) {
|
|
265
|
+
return extendUnionType(type);
|
|
266
|
+
} else if (isEnumType(type)) {
|
|
267
|
+
return extendEnumType(type);
|
|
268
|
+
} else if (isInputObjectType(type)) {
|
|
269
|
+
return extendInputObjectType(type);
|
|
270
|
+
} // Not reachable. All possible types have been considered.
|
|
271
|
+
|
|
272
|
+
/* istanbul ignore next */
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
throw new Error("Unexpected type: \"".concat(inspect(type), "\"."));
|
|
242
276
|
}
|
|
243
277
|
|
|
244
278
|
function extendDirective(directive) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
args: extendArgs(directive.args),
|
|
250
|
-
astNode: directive.astNode
|
|
251
|
-
});
|
|
279
|
+
var config = directive.toConfig();
|
|
280
|
+
return new GraphQLDirective(_objectSpread({}, config, {
|
|
281
|
+
args: mapValue(config.args, extendArg)
|
|
282
|
+
}));
|
|
252
283
|
}
|
|
253
284
|
|
|
254
285
|
function extendInputObjectType(type) {
|
|
255
|
-
var
|
|
256
|
-
var
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
286
|
+
var config = type.toConfig();
|
|
287
|
+
var extensions = typeExtsMap[config.name] || [];
|
|
288
|
+
var fieldNodes = flatMap(extensions, function (node) {
|
|
289
|
+
return node.fields || [];
|
|
290
|
+
});
|
|
291
|
+
return new GraphQLInputObjectType(_objectSpread({}, config, {
|
|
260
292
|
fields: function fields() {
|
|
261
|
-
return
|
|
293
|
+
return _objectSpread({}, mapValue(config.fields, function (field) {
|
|
294
|
+
return _objectSpread({}, field, {
|
|
295
|
+
type: replaceType(field.type)
|
|
296
|
+
});
|
|
297
|
+
}), keyValMap(fieldNodes, function (field) {
|
|
298
|
+
return field.name.value;
|
|
299
|
+
}, function (field) {
|
|
300
|
+
return astBuilder.buildInputField(field);
|
|
301
|
+
}));
|
|
262
302
|
},
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function extendInputFieldMap(type) {
|
|
269
|
-
var newFieldMap = mapValue(type.getFields(), function (field) {
|
|
270
|
-
return {
|
|
271
|
-
description: field.description,
|
|
272
|
-
type: extendType(field.type),
|
|
273
|
-
defaultValue: field.defaultValue,
|
|
274
|
-
astNode: field.astNode
|
|
275
|
-
};
|
|
276
|
-
}); // If there are any extensions to the fields, apply those here.
|
|
277
|
-
|
|
278
|
-
var extensions = typeExtensionsMap[type.name];
|
|
279
|
-
|
|
280
|
-
if (extensions) {
|
|
281
|
-
var _iteratorNormalCompletion3 = true;
|
|
282
|
-
var _didIteratorError3 = false;
|
|
283
|
-
var _iteratorError3 = undefined;
|
|
284
|
-
|
|
285
|
-
try {
|
|
286
|
-
for (var _iterator3 = extensions[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
287
|
-
var extension = _step3.value;
|
|
288
|
-
var _iteratorNormalCompletion4 = true;
|
|
289
|
-
var _didIteratorError4 = false;
|
|
290
|
-
var _iteratorError4 = undefined;
|
|
291
|
-
|
|
292
|
-
try {
|
|
293
|
-
for (var _iterator4 = extension.fields[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
|
294
|
-
var field = _step4.value;
|
|
295
|
-
newFieldMap[field.name.value] = astBuilder.buildInputField(field);
|
|
296
|
-
}
|
|
297
|
-
} catch (err) {
|
|
298
|
-
_didIteratorError4 = true;
|
|
299
|
-
_iteratorError4 = err;
|
|
300
|
-
} finally {
|
|
301
|
-
try {
|
|
302
|
-
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
|
303
|
-
_iterator4.return();
|
|
304
|
-
}
|
|
305
|
-
} finally {
|
|
306
|
-
if (_didIteratorError4) {
|
|
307
|
-
throw _iteratorError4;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
} catch (err) {
|
|
313
|
-
_didIteratorError3 = true;
|
|
314
|
-
_iteratorError3 = err;
|
|
315
|
-
} finally {
|
|
316
|
-
try {
|
|
317
|
-
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
318
|
-
_iterator3.return();
|
|
319
|
-
}
|
|
320
|
-
} finally {
|
|
321
|
-
if (_didIteratorError3) {
|
|
322
|
-
throw _iteratorError3;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
return newFieldMap;
|
|
303
|
+
extensionASTNodes: config.extensionASTNodes.concat(extensions)
|
|
304
|
+
}));
|
|
329
305
|
}
|
|
330
306
|
|
|
331
307
|
function extendEnumType(type) {
|
|
332
|
-
var
|
|
333
|
-
var
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
description: type.description,
|
|
337
|
-
values: extendValueMap(type),
|
|
338
|
-
astNode: type.astNode,
|
|
339
|
-
extensionASTNodes: extensionASTNodes
|
|
308
|
+
var config = type.toConfig();
|
|
309
|
+
var extensions = typeExtsMap[type.name] || [];
|
|
310
|
+
var valueNodes = flatMap(extensions, function (node) {
|
|
311
|
+
return node.values || [];
|
|
340
312
|
});
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
try {
|
|
350
|
-
for (var _iterator5 = type.getValues()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
|
351
|
-
var _value = _step5.value;
|
|
352
|
-
newValueMap[_value.name] = {
|
|
353
|
-
description: _value.description,
|
|
354
|
-
value: _value.value,
|
|
355
|
-
deprecationReason: _value.deprecationReason,
|
|
356
|
-
astNode: _value.astNode
|
|
357
|
-
};
|
|
358
|
-
} // If there are any extensions to the values, apply those here.
|
|
359
|
-
|
|
360
|
-
} catch (err) {
|
|
361
|
-
_didIteratorError5 = true;
|
|
362
|
-
_iteratorError5 = err;
|
|
363
|
-
} finally {
|
|
364
|
-
try {
|
|
365
|
-
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
|
|
366
|
-
_iterator5.return();
|
|
367
|
-
}
|
|
368
|
-
} finally {
|
|
369
|
-
if (_didIteratorError5) {
|
|
370
|
-
throw _iteratorError5;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
var extensions = typeExtensionsMap[type.name];
|
|
376
|
-
|
|
377
|
-
if (extensions) {
|
|
378
|
-
var _iteratorNormalCompletion6 = true;
|
|
379
|
-
var _didIteratorError6 = false;
|
|
380
|
-
var _iteratorError6 = undefined;
|
|
381
|
-
|
|
382
|
-
try {
|
|
383
|
-
for (var _iterator6 = extensions[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
|
|
384
|
-
var extension = _step6.value;
|
|
385
|
-
var _iteratorNormalCompletion7 = true;
|
|
386
|
-
var _didIteratorError7 = false;
|
|
387
|
-
var _iteratorError7 = undefined;
|
|
388
|
-
|
|
389
|
-
try {
|
|
390
|
-
for (var _iterator7 = extension.values[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
|
|
391
|
-
var value = _step7.value;
|
|
392
|
-
newValueMap[value.name.value] = astBuilder.buildEnumValue(value);
|
|
393
|
-
}
|
|
394
|
-
} catch (err) {
|
|
395
|
-
_didIteratorError7 = true;
|
|
396
|
-
_iteratorError7 = err;
|
|
397
|
-
} finally {
|
|
398
|
-
try {
|
|
399
|
-
if (!_iteratorNormalCompletion7 && _iterator7.return != null) {
|
|
400
|
-
_iterator7.return();
|
|
401
|
-
}
|
|
402
|
-
} finally {
|
|
403
|
-
if (_didIteratorError7) {
|
|
404
|
-
throw _iteratorError7;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
} catch (err) {
|
|
410
|
-
_didIteratorError6 = true;
|
|
411
|
-
_iteratorError6 = err;
|
|
412
|
-
} finally {
|
|
413
|
-
try {
|
|
414
|
-
if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
|
|
415
|
-
_iterator6.return();
|
|
416
|
-
}
|
|
417
|
-
} finally {
|
|
418
|
-
if (_didIteratorError6) {
|
|
419
|
-
throw _iteratorError6;
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
return newValueMap;
|
|
313
|
+
return new GraphQLEnumType(_objectSpread({}, config, {
|
|
314
|
+
values: _objectSpread({}, config.values, keyValMap(valueNodes, function (value) {
|
|
315
|
+
return value.name.value;
|
|
316
|
+
}, function (value) {
|
|
317
|
+
return astBuilder.buildEnumValue(value);
|
|
318
|
+
})),
|
|
319
|
+
extensionASTNodes: config.extensionASTNodes.concat(extensions)
|
|
320
|
+
}));
|
|
426
321
|
}
|
|
427
322
|
|
|
428
323
|
function extendScalarType(type) {
|
|
429
|
-
var
|
|
430
|
-
var
|
|
431
|
-
return new GraphQLScalarType({
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
astNode: type.astNode,
|
|
435
|
-
extensionASTNodes: extensionASTNodes,
|
|
436
|
-
serialize: type.serialize,
|
|
437
|
-
parseValue: type.parseValue,
|
|
438
|
-
parseLiteral: type.parseLiteral
|
|
439
|
-
});
|
|
324
|
+
var config = type.toConfig();
|
|
325
|
+
var extensions = typeExtsMap[config.name] || [];
|
|
326
|
+
return new GraphQLScalarType(_objectSpread({}, config, {
|
|
327
|
+
extensionASTNodes: config.extensionASTNodes.concat(extensions)
|
|
328
|
+
}));
|
|
440
329
|
}
|
|
441
330
|
|
|
442
331
|
function extendObjectType(type) {
|
|
443
|
-
var
|
|
444
|
-
var
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
332
|
+
var config = type.toConfig();
|
|
333
|
+
var extensions = typeExtsMap[config.name] || [];
|
|
334
|
+
var interfaceNodes = flatMap(extensions, function (node) {
|
|
335
|
+
return node.interfaces || [];
|
|
336
|
+
});
|
|
337
|
+
var fieldNodes = flatMap(extensions, function (node) {
|
|
338
|
+
return node.fields || [];
|
|
339
|
+
});
|
|
340
|
+
return new GraphQLObjectType(_objectSpread({}, config, {
|
|
448
341
|
interfaces: function interfaces() {
|
|
449
|
-
return
|
|
342
|
+
return [].concat(type.getInterfaces().map(replaceNamedType), interfaceNodes.map(function (node) {
|
|
343
|
+
return astBuilder.getNamedType(node);
|
|
344
|
+
}));
|
|
450
345
|
},
|
|
451
346
|
fields: function fields() {
|
|
452
|
-
return
|
|
347
|
+
return _objectSpread({}, mapValue(config.fields, extendField), keyValMap(fieldNodes, function (node) {
|
|
348
|
+
return node.name.value;
|
|
349
|
+
}, function (node) {
|
|
350
|
+
return astBuilder.buildField(node);
|
|
351
|
+
}));
|
|
453
352
|
},
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
isTypeOf: type.isTypeOf
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
function extendArgs(args) {
|
|
461
|
-
return keyValMap(args, function (arg) {
|
|
462
|
-
return arg.name;
|
|
463
|
-
}, function (arg) {
|
|
464
|
-
return {
|
|
465
|
-
type: extendType(arg.type),
|
|
466
|
-
defaultValue: arg.defaultValue,
|
|
467
|
-
description: arg.description,
|
|
468
|
-
astNode: arg.astNode
|
|
469
|
-
};
|
|
470
|
-
});
|
|
353
|
+
extensionASTNodes: config.extensionASTNodes.concat(extensions)
|
|
354
|
+
}));
|
|
471
355
|
}
|
|
472
356
|
|
|
473
357
|
function extendInterfaceType(type) {
|
|
474
|
-
var
|
|
475
|
-
var
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
358
|
+
var config = type.toConfig();
|
|
359
|
+
var extensions = typeExtsMap[config.name] || [];
|
|
360
|
+
var fieldNodes = flatMap(extensions, function (node) {
|
|
361
|
+
return node.fields || [];
|
|
362
|
+
});
|
|
363
|
+
return new GraphQLInterfaceType(_objectSpread({}, config, {
|
|
479
364
|
fields: function fields() {
|
|
480
|
-
return
|
|
365
|
+
return _objectSpread({}, mapValue(config.fields, extendField), keyValMap(fieldNodes, function (node) {
|
|
366
|
+
return node.name.value;
|
|
367
|
+
}, function (node) {
|
|
368
|
+
return astBuilder.buildField(node);
|
|
369
|
+
}));
|
|
481
370
|
},
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
resolveType: type.resolveType
|
|
485
|
-
});
|
|
371
|
+
extensionASTNodes: config.extensionASTNodes.concat(extensions)
|
|
372
|
+
}));
|
|
486
373
|
}
|
|
487
374
|
|
|
488
375
|
function extendUnionType(type) {
|
|
489
|
-
var
|
|
490
|
-
var
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
376
|
+
var config = type.toConfig();
|
|
377
|
+
var extensions = typeExtsMap[config.name] || [];
|
|
378
|
+
var typeNodes = flatMap(extensions, function (node) {
|
|
379
|
+
return node.types || [];
|
|
380
|
+
});
|
|
381
|
+
return new GraphQLUnionType(_objectSpread({}, config, {
|
|
494
382
|
types: function types() {
|
|
495
|
-
return
|
|
383
|
+
return [].concat(type.getTypes().map(replaceNamedType), typeNodes.map(function (node) {
|
|
384
|
+
return astBuilder.getNamedType(node);
|
|
385
|
+
}));
|
|
496
386
|
},
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
extensionASTNodes: extensionASTNodes
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
function extendPossibleTypes(type) {
|
|
504
|
-
var possibleTypes = type.getTypes().map(extendNamedType); // If there are any extensions to the union, apply those here.
|
|
505
|
-
|
|
506
|
-
var extensions = typeExtensionsMap[type.name];
|
|
507
|
-
|
|
508
|
-
if (extensions) {
|
|
509
|
-
var _iteratorNormalCompletion8 = true;
|
|
510
|
-
var _didIteratorError8 = false;
|
|
511
|
-
var _iteratorError8 = undefined;
|
|
512
|
-
|
|
513
|
-
try {
|
|
514
|
-
for (var _iterator8 = extensions[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
|
|
515
|
-
var extension = _step8.value;
|
|
516
|
-
var _iteratorNormalCompletion9 = true;
|
|
517
|
-
var _didIteratorError9 = false;
|
|
518
|
-
var _iteratorError9 = undefined;
|
|
519
|
-
|
|
520
|
-
try {
|
|
521
|
-
for (var _iterator9 = extension.types[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
|
|
522
|
-
var namedType = _step9.value;
|
|
523
|
-
// Note: While this could make early assertions to get the correctly
|
|
524
|
-
// typed values, that would throw immediately while type system
|
|
525
|
-
// validation with validateSchema() will produce more actionable results.
|
|
526
|
-
possibleTypes.push(astBuilder.buildType(namedType));
|
|
527
|
-
}
|
|
528
|
-
} catch (err) {
|
|
529
|
-
_didIteratorError9 = true;
|
|
530
|
-
_iteratorError9 = err;
|
|
531
|
-
} finally {
|
|
532
|
-
try {
|
|
533
|
-
if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
|
|
534
|
-
_iterator9.return();
|
|
535
|
-
}
|
|
536
|
-
} finally {
|
|
537
|
-
if (_didIteratorError9) {
|
|
538
|
-
throw _iteratorError9;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
} catch (err) {
|
|
544
|
-
_didIteratorError8 = true;
|
|
545
|
-
_iteratorError8 = err;
|
|
546
|
-
} finally {
|
|
547
|
-
try {
|
|
548
|
-
if (!_iteratorNormalCompletion8 && _iterator8.return != null) {
|
|
549
|
-
_iterator8.return();
|
|
550
|
-
}
|
|
551
|
-
} finally {
|
|
552
|
-
if (_didIteratorError8) {
|
|
553
|
-
throw _iteratorError8;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
return possibleTypes;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
function extendImplementedInterfaces(type) {
|
|
563
|
-
var interfaces = type.getInterfaces().map(extendNamedType); // If there are any extensions to the interfaces, apply those here.
|
|
564
|
-
|
|
565
|
-
var extensions = typeExtensionsMap[type.name];
|
|
566
|
-
|
|
567
|
-
if (extensions) {
|
|
568
|
-
var _iteratorNormalCompletion10 = true;
|
|
569
|
-
var _didIteratorError10 = false;
|
|
570
|
-
var _iteratorError10 = undefined;
|
|
571
|
-
|
|
572
|
-
try {
|
|
573
|
-
for (var _iterator10 = extensions[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
|
|
574
|
-
var extension = _step10.value;
|
|
575
|
-
var _iteratorNormalCompletion11 = true;
|
|
576
|
-
var _didIteratorError11 = false;
|
|
577
|
-
var _iteratorError11 = undefined;
|
|
578
|
-
|
|
579
|
-
try {
|
|
580
|
-
for (var _iterator11 = extension.interfaces[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
|
|
581
|
-
var namedType = _step11.value;
|
|
582
|
-
// Note: While this could make early assertions to get the correctly
|
|
583
|
-
// typed values, that would throw immediately while type system
|
|
584
|
-
// validation with validateSchema() will produce more actionable results.
|
|
585
|
-
interfaces.push(astBuilder.buildType(namedType));
|
|
586
|
-
}
|
|
587
|
-
} catch (err) {
|
|
588
|
-
_didIteratorError11 = true;
|
|
589
|
-
_iteratorError11 = err;
|
|
590
|
-
} finally {
|
|
591
|
-
try {
|
|
592
|
-
if (!_iteratorNormalCompletion11 && _iterator11.return != null) {
|
|
593
|
-
_iterator11.return();
|
|
594
|
-
}
|
|
595
|
-
} finally {
|
|
596
|
-
if (_didIteratorError11) {
|
|
597
|
-
throw _iteratorError11;
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
} catch (err) {
|
|
603
|
-
_didIteratorError10 = true;
|
|
604
|
-
_iteratorError10 = err;
|
|
605
|
-
} finally {
|
|
606
|
-
try {
|
|
607
|
-
if (!_iteratorNormalCompletion10 && _iterator10.return != null) {
|
|
608
|
-
_iterator10.return();
|
|
609
|
-
}
|
|
610
|
-
} finally {
|
|
611
|
-
if (_didIteratorError10) {
|
|
612
|
-
throw _iteratorError10;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
return interfaces;
|
|
387
|
+
extensionASTNodes: config.extensionASTNodes.concat(extensions)
|
|
388
|
+
}));
|
|
619
389
|
}
|
|
620
390
|
|
|
621
|
-
function
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
type: extendType(field.type),
|
|
627
|
-
args: extendArgs(field.args),
|
|
628
|
-
astNode: field.astNode,
|
|
629
|
-
resolve: field.resolve
|
|
630
|
-
};
|
|
631
|
-
}); // If there are any extensions to the fields, apply those here.
|
|
632
|
-
|
|
633
|
-
var extensions = typeExtensionsMap[type.name];
|
|
634
|
-
|
|
635
|
-
if (extensions) {
|
|
636
|
-
var _iteratorNormalCompletion12 = true;
|
|
637
|
-
var _didIteratorError12 = false;
|
|
638
|
-
var _iteratorError12 = undefined;
|
|
639
|
-
|
|
640
|
-
try {
|
|
641
|
-
for (var _iterator12 = extensions[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
|
|
642
|
-
var extension = _step12.value;
|
|
643
|
-
var _iteratorNormalCompletion13 = true;
|
|
644
|
-
var _didIteratorError13 = false;
|
|
645
|
-
var _iteratorError13 = undefined;
|
|
646
|
-
|
|
647
|
-
try {
|
|
648
|
-
for (var _iterator13 = extension.fields[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
|
|
649
|
-
var field = _step13.value;
|
|
650
|
-
newFieldMap[field.name.value] = astBuilder.buildField(field);
|
|
651
|
-
}
|
|
652
|
-
} catch (err) {
|
|
653
|
-
_didIteratorError13 = true;
|
|
654
|
-
_iteratorError13 = err;
|
|
655
|
-
} finally {
|
|
656
|
-
try {
|
|
657
|
-
if (!_iteratorNormalCompletion13 && _iterator13.return != null) {
|
|
658
|
-
_iterator13.return();
|
|
659
|
-
}
|
|
660
|
-
} finally {
|
|
661
|
-
if (_didIteratorError13) {
|
|
662
|
-
throw _iteratorError13;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
} catch (err) {
|
|
668
|
-
_didIteratorError12 = true;
|
|
669
|
-
_iteratorError12 = err;
|
|
670
|
-
} finally {
|
|
671
|
-
try {
|
|
672
|
-
if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
|
|
673
|
-
_iterator12.return();
|
|
674
|
-
}
|
|
675
|
-
} finally {
|
|
676
|
-
if (_didIteratorError12) {
|
|
677
|
-
throw _iteratorError12;
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
return newFieldMap;
|
|
391
|
+
function extendField(field) {
|
|
392
|
+
return _objectSpread({}, field, {
|
|
393
|
+
type: replaceType(field.type),
|
|
394
|
+
args: mapValue(field.args, extendArg)
|
|
395
|
+
});
|
|
684
396
|
}
|
|
685
397
|
|
|
686
|
-
function
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
if (isNonNullType(typeDef)) {
|
|
692
|
-
return GraphQLNonNull(extendType(typeDef.ofType));
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
return extendNamedType(typeDef);
|
|
398
|
+
function extendArg(arg) {
|
|
399
|
+
return _objectSpread({}, arg, {
|
|
400
|
+
type: replaceType(arg.type)
|
|
401
|
+
});
|
|
696
402
|
}
|
|
697
|
-
}
|
|
403
|
+
}
|