graphql 14.0.2 → 14.2.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 +5 -5
- package/codecov.yml +14 -0
- package/error/GraphQLError.js +2 -2
- package/error/GraphQLError.js.flow +4 -4
- package/error/GraphQLError.mjs +2 -2
- package/error/formatError.js +2 -2
- package/error/formatError.js.flow +1 -1
- package/error/formatError.mjs +2 -2
- package/error/index.js.flow +1 -1
- package/error/index.mjs +2 -2
- package/error/locatedError.js +2 -2
- package/error/locatedError.js.flow +1 -1
- package/error/locatedError.mjs +2 -2
- package/error/printError.js +2 -2
- package/error/printError.js.flow +1 -1
- package/error/printError.mjs +2 -2
- package/error/syntaxError.js +2 -2
- package/error/syntaxError.js.flow +1 -1
- package/error/syntaxError.mjs +2 -2
- package/execution/execute.js +20 -11
- package/execution/execute.js.flow +41 -27
- package/execution/execute.mjs +19 -13
- package/execution/index.js +6 -0
- package/execution/index.js.flow +7 -2
- package/execution/index.mjs +3 -3
- package/execution/values.js +10 -10
- package/execution/values.js.flow +8 -8
- package/execution/values.mjs +9 -9
- package/graphql.js +8 -8
- package/graphql.js.flow +18 -4
- package/graphql.mjs +8 -8
- package/index.js +18 -0
- package/index.js.flow +4 -1
- package/index.mjs +4 -4
- package/jsutils/ObjMap.js.flow +1 -1
- package/jsutils/{MaybePromise.js → PromiseOrValue.js} +0 -0
- package/jsutils/{MaybePromise.js.flow → PromiseOrValue.js.flow} +2 -2
- package/jsutils/{MaybePromise.mjs → PromiseOrValue.mjs} +0 -0
- package/jsutils/dedent.js +2 -2
- package/jsutils/dedent.js.flow +1 -1
- package/jsutils/dedent.mjs +2 -2
- package/jsutils/defineToJSON.js +18 -7
- package/jsutils/defineToJSON.js.flow +15 -6
- package/jsutils/defineToJSON.mjs +15 -7
- package/jsutils/defineToStringTag.js +6 -6
- package/jsutils/defineToStringTag.js.flow +4 -4
- package/jsutils/defineToStringTag.mjs +5 -5
- package/jsutils/inspect.js +109 -23
- package/jsutils/inspect.js.flow +112 -14
- package/jsutils/inspect.mjs +108 -17
- package/jsutils/instanceOf.js +2 -2
- package/jsutils/instanceOf.js.flow +1 -1
- package/jsutils/instanceOf.mjs +2 -2
- package/jsutils/invariant.js +2 -2
- package/jsutils/invariant.js.flow +1 -1
- package/jsutils/invariant.mjs +2 -2
- 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 +2 -2
- package/jsutils/keyMap.js.flow +1 -1
- package/jsutils/keyMap.mjs +2 -2
- package/jsutils/keyValMap.js +2 -2
- package/jsutils/keyValMap.js.flow +1 -1
- package/jsutils/keyValMap.mjs +2 -2
- package/jsutils/mapValue.js +54 -0
- package/jsutils/mapValue.js.flow +27 -0
- package/jsutils/mapValue.mjs +44 -0
- package/jsutils/memoize3.js +2 -2
- package/jsutils/memoize3.js.flow +1 -1
- package/jsutils/memoize3.mjs +2 -2
- package/jsutils/nodejsCustomInspectSymbol.js +18 -0
- package/jsutils/nodejsCustomInspectSymbol.js.flow +15 -0
- package/jsutils/nodejsCustomInspectSymbol.mjs +10 -0
- package/jsutils/orList.js +18 -5
- package/jsutils/orList.js.flow +14 -8
- package/jsutils/orList.mjs +15 -5
- package/jsutils/promiseForObject.js +2 -2
- package/jsutils/promiseForObject.js.flow +1 -1
- 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.flow +1 -1
- package/language/{blockStringValue.mjs → blockString.js} +39 -3
- package/language/{blockStringValue.js.flow → blockString.js.flow} +31 -2
- package/language/{blockStringValue.js → blockString.mjs} +31 -10
- package/language/directiveLocation.js +2 -2
- package/language/directiveLocation.js.flow +1 -1
- package/language/directiveLocation.mjs +2 -2
- package/language/index.js.flow +1 -1
- package/language/index.mjs +2 -2
- package/language/kinds.js +2 -2
- package/language/kinds.js.flow +1 -1
- package/language/kinds.mjs +2 -2
- package/language/lexer.js +60 -46
- package/language/lexer.js.flow +71 -69
- package/language/lexer.mjs +58 -45
- package/language/location.js +2 -2
- package/language/location.js.flow +1 -1
- package/language/location.mjs +2 -2
- package/language/parser.js +84 -83
- package/language/parser.js.flow +85 -94
- package/language/parser.mjs +83 -83
- package/language/predicates.js +2 -2
- package/language/predicates.js.flow +1 -1
- package/language/predicates.mjs +2 -2
- package/language/printer.js +15 -17
- package/language/printer.js.flow +21 -20
- package/language/printer.mjs +14 -17
- package/language/source.js +8 -7
- package/language/source.js.flow +1 -1
- package/language/source.mjs +2 -10
- package/language/visitor.js +7 -6
- package/language/visitor.js.flow +3 -5
- package/language/visitor.mjs +7 -6
- package/package.json +5 -2
- package/polyfills/find.js +31 -0
- package/polyfills/find.js.flow +29 -0
- package/polyfills/find.mjs +23 -0
- package/polyfills/flatMap.js +38 -0
- package/polyfills/flatMap.js.flow +34 -0
- package/polyfills/flatMap.mjs +30 -0
- package/{jsutils → polyfills}/isFinite.js +2 -2
- package/{jsutils → polyfills}/isFinite.js.flow +1 -1
- package/{jsutils → polyfills}/isFinite.mjs +2 -2
- package/{jsutils → polyfills}/isInteger.js +2 -2
- package/{jsutils → polyfills}/isInteger.js.flow +1 -1
- package/{jsutils → polyfills}/isInteger.mjs +2 -2
- package/polyfills/objectEntries.js +26 -0
- package/polyfills/objectEntries.js.flow +19 -0
- package/polyfills/objectEntries.mjs +18 -0
- package/{jsutils → polyfills}/objectValues.js +2 -2
- package/{jsutils → polyfills}/objectValues.js.flow +2 -2
- package/{jsutils → polyfills}/objectValues.mjs +2 -2
- package/subscription/asyncIteratorReject.js.flow +1 -1
- package/subscription/asyncIteratorReject.mjs +2 -2
- package/subscription/index.js.flow +1 -1
- package/subscription/index.mjs +2 -2
- package/subscription/mapAsyncIterator.js.flow +5 -5
- package/subscription/mapAsyncIterator.mjs +2 -2
- package/subscription/subscribe.js +2 -2
- package/subscription/subscribe.js.flow +1 -1
- package/subscription/subscribe.mjs +2 -2
- package/type/definition.js +161 -138
- package/type/definition.js.flow +193 -57
- package/type/definition.mjs +158 -140
- package/type/directives.js +35 -29
- package/type/directives.js.flow +39 -21
- package/type/directives.mjs +34 -31
- package/type/index.js +12 -0
- package/type/index.js.flow +5 -1
- package/type/index.mjs +6 -4
- package/type/introspection.js +11 -7
- package/type/introspection.js.flow +11 -8
- package/type/introspection.mjs +11 -7
- package/type/scalars.js +45 -34
- package/type/scalars.js.flow +41 -27
- package/type/scalars.mjs +45 -27
- package/type/schema.js +134 -88
- package/type/schema.js.flow +77 -11
- package/type/schema.mjs +132 -88
- package/type/validate.js +152 -187
- package/type/validate.js.flow +12 -61
- package/type/validate.mjs +143 -188
- package/utilities/TypeInfo.js +10 -23
- package/utilities/TypeInfo.js.flow +2 -2
- package/utilities/TypeInfo.mjs +3 -25
- package/utilities/assertValidName.js +2 -2
- package/utilities/assertValidName.js.flow +1 -1
- package/utilities/assertValidName.mjs +2 -2
- package/utilities/astFromValue.js +7 -6
- package/utilities/astFromValue.js.flow +7 -6
- package/utilities/astFromValue.mjs +9 -8
- package/utilities/buildASTSchema.js +213 -197
- package/utilities/buildASTSchema.js.flow +163 -173
- package/utilities/buildASTSchema.mjs +203 -198
- package/utilities/buildClientSchema.js +39 -47
- package/utilities/buildClientSchema.js.flow +49 -58
- package/utilities/buildClientSchema.mjs +38 -46
- package/utilities/coerceValue.js +41 -21
- package/utilities/coerceValue.js.flow +44 -49
- package/utilities/coerceValue.mjs +42 -23
- package/utilities/concatAST.js +9 -13
- package/utilities/concatAST.js.flow +3 -9
- package/utilities/concatAST.mjs +6 -13
- package/utilities/extendSchema.js +256 -630
- package/utilities/extendSchema.js.flow +190 -426
- package/utilities/extendSchema.mjs +256 -631
- package/utilities/findBreakingChanges.js +8 -6
- package/utilities/findBreakingChanges.js.flow +4 -3
- package/utilities/findBreakingChanges.mjs +7 -6
- package/utilities/findDeprecatedUsages.js +4 -4
- package/utilities/findDeprecatedUsages.js.flow +3 -3
- package/utilities/findDeprecatedUsages.mjs +4 -4
- package/utilities/getOperationAST.js +2 -2
- package/utilities/getOperationAST.js.flow +1 -1
- package/utilities/getOperationAST.mjs +2 -2
- package/utilities/getOperationRootType.js +6 -6
- package/utilities/getOperationRootType.js.flow +9 -7
- package/utilities/getOperationRootType.mjs +6 -6
- package/utilities/index.js.flow +1 -1
- package/utilities/index.mjs +2 -2
- package/utilities/introspectionFromSchema.js +2 -2
- package/utilities/introspectionFromSchema.js.flow +1 -1
- package/utilities/introspectionFromSchema.mjs +2 -2
- package/utilities/introspectionQuery.js +2 -2
- package/utilities/introspectionQuery.js.flow +1 -1
- package/utilities/introspectionQuery.mjs +2 -2
- package/utilities/isValidJSValue.js +4 -2
- package/utilities/isValidJSValue.js.flow +2 -1
- package/utilities/isValidJSValue.mjs +4 -2
- package/utilities/isValidLiteralValue.js +2 -2
- package/utilities/isValidLiteralValue.js.flow +1 -1
- package/utilities/isValidLiteralValue.mjs +2 -2
- package/utilities/lexicographicSortSchema.js +86 -124
- package/utilities/lexicographicSortSchema.js.flow +68 -96
- package/utilities/lexicographicSortSchema.mjs +86 -124
- package/utilities/schemaPrinter.js +47 -73
- package/utilities/schemaPrinter.js.flow +62 -111
- package/utilities/schemaPrinter.mjs +46 -73
- package/utilities/separateOperations.js +11 -10
- package/utilities/separateOperations.js.flow +1 -1
- package/utilities/separateOperations.mjs +11 -10
- package/utilities/typeComparators.js +2 -2
- package/utilities/typeComparators.js.flow +1 -1
- package/utilities/typeComparators.mjs +2 -2
- package/utilities/typeFromAST.js +9 -4
- package/utilities/typeFromAST.js.flow +5 -2
- package/utilities/typeFromAST.mjs +6 -4
- package/utilities/valueFromAST.js +9 -6
- package/utilities/valueFromAST.js.flow +5 -3
- package/utilities/valueFromAST.mjs +7 -5
- package/utilities/valueFromASTUntyped.js +7 -4
- package/utilities/valueFromASTUntyped.js.flow +5 -2
- package/utilities/valueFromASTUntyped.mjs +6 -4
- package/validation/ValidationContext.js +57 -82
- package/validation/ValidationContext.js.flow +53 -50
- package/validation/ValidationContext.mjs +53 -78
- package/validation/index.js.flow +1 -1
- package/validation/index.mjs +2 -2
- package/validation/rules/ExecutableDefinitions.js +3 -3
- package/validation/rules/ExecutableDefinitions.js.flow +3 -3
- package/validation/rules/ExecutableDefinitions.mjs +3 -3
- package/validation/rules/FieldsOnCorrectType.js +3 -3
- package/validation/rules/FieldsOnCorrectType.js.flow +2 -2
- package/validation/rules/FieldsOnCorrectType.mjs +3 -3
- package/validation/rules/FragmentsOnCompositeTypes.js +4 -4
- package/validation/rules/FragmentsOnCompositeTypes.js.flow +3 -3
- package/validation/rules/FragmentsOnCompositeTypes.mjs +4 -4
- package/validation/rules/KnownArgumentNames.js.flow +1 -1
- package/validation/rules/KnownArgumentNames.mjs +2 -2
- package/validation/rules/KnownDirectives.js +4 -4
- package/validation/rules/KnownDirectives.js.flow +5 -4
- package/validation/rules/KnownDirectives.mjs +4 -4
- package/validation/rules/KnownFragmentNames.js +3 -3
- package/validation/rules/KnownFragmentNames.js.flow +2 -2
- package/validation/rules/KnownFragmentNames.mjs +3 -3
- package/validation/rules/KnownTypeNames.js +60 -22
- package/validation/rules/KnownTypeNames.js.flow +55 -21
- package/validation/rules/KnownTypeNames.mjs +57 -22
- package/validation/rules/LoneAnonymousOperation.js +3 -3
- package/validation/rules/LoneAnonymousOperation.js.flow +2 -2
- package/validation/rules/LoneAnonymousOperation.mjs +3 -3
- package/validation/rules/LoneSchemaDefinition.js +2 -2
- package/validation/rules/LoneSchemaDefinition.js.flow +1 -1
- package/validation/rules/LoneSchemaDefinition.mjs +2 -2
- package/validation/rules/NoFragmentCycles.js +2 -2
- package/validation/rules/NoFragmentCycles.js.flow +3 -3
- package/validation/rules/NoFragmentCycles.mjs +2 -2
- package/validation/rules/NoUndefinedVariables.js +2 -2
- package/validation/rules/NoUndefinedVariables.js.flow +1 -1
- package/validation/rules/NoUndefinedVariables.mjs +2 -2
- package/validation/rules/NoUnusedFragments.js +10 -7
- package/validation/rules/NoUnusedFragments.js.flow +4 -4
- package/validation/rules/NoUnusedFragments.mjs +10 -7
- package/validation/rules/NoUnusedVariables.js +7 -5
- package/validation/rules/NoUnusedVariables.js.flow +4 -3
- package/validation/rules/NoUnusedVariables.mjs +7 -5
- package/validation/rules/OverlappingFieldsCanBeMerged.js +58 -33
- package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +4 -4
- package/validation/rules/OverlappingFieldsCanBeMerged.mjs +50 -34
- package/validation/rules/PossibleFragmentSpreads.js +4 -4
- package/validation/rules/PossibleFragmentSpreads.js.flow +3 -3
- package/validation/rules/PossibleFragmentSpreads.mjs +4 -4
- package/validation/rules/PossibleTypeExtensions.js +158 -0
- package/validation/rules/PossibleTypeExtensions.js.flow +160 -0
- package/validation/rules/PossibleTypeExtensions.mjs +146 -0
- package/validation/rules/ProvidedRequiredArguments.js +3 -3
- package/validation/rules/ProvidedRequiredArguments.js.flow +4 -4
- package/validation/rules/ProvidedRequiredArguments.mjs +5 -5
- package/validation/rules/ScalarLeafs.js +4 -4
- package/validation/rules/ScalarLeafs.js.flow +3 -3
- package/validation/rules/ScalarLeafs.mjs +4 -4
- package/validation/rules/SingleFieldSubscriptions.js +2 -2
- package/validation/rules/SingleFieldSubscriptions.js.flow +1 -1
- package/validation/rules/SingleFieldSubscriptions.mjs +2 -2
- package/validation/rules/UniqueArgumentNames.js +2 -2
- package/validation/rules/UniqueArgumentNames.js.flow +1 -1
- package/validation/rules/UniqueArgumentNames.mjs +2 -2
- package/validation/rules/UniqueDirectiveNames.js +55 -0
- package/validation/rules/UniqueDirectiveNames.js.flow +64 -0
- package/validation/rules/UniqueDirectiveNames.mjs +43 -0
- package/validation/rules/UniqueDirectivesPerLocation.js +2 -2
- package/validation/rules/UniqueDirectivesPerLocation.js.flow +1 -1
- package/validation/rules/UniqueDirectivesPerLocation.mjs +2 -2
- package/validation/rules/UniqueEnumValueNames.js +90 -0
- package/validation/rules/UniqueEnumValueNames.js.flow +85 -0
- package/validation/rules/UniqueEnumValueNames.mjs +77 -0
- package/validation/rules/UniqueFieldDefinitionNames.js +101 -0
- package/validation/rules/UniqueFieldDefinitionNames.js.flow +99 -0
- package/validation/rules/UniqueFieldDefinitionNames.mjs +88 -0
- package/validation/rules/UniqueFragmentNames.js +2 -2
- package/validation/rules/UniqueFragmentNames.js.flow +1 -1
- package/validation/rules/UniqueFragmentNames.mjs +2 -2
- package/validation/rules/UniqueInputFieldNames.js +2 -4
- package/validation/rules/UniqueInputFieldNames.js.flow +1 -2
- package/validation/rules/UniqueInputFieldNames.mjs +2 -4
- package/validation/rules/UniqueOperationNames.js +2 -2
- package/validation/rules/UniqueOperationNames.js.flow +1 -1
- package/validation/rules/UniqueOperationNames.mjs +2 -2
- package/validation/rules/UniqueOperationTypes.js +85 -0
- package/validation/rules/UniqueOperationTypes.js.flow +76 -0
- package/validation/rules/UniqueOperationTypes.mjs +73 -0
- package/validation/rules/UniqueTypeNames.js +62 -0
- package/validation/rules/UniqueTypeNames.js.flow +67 -0
- package/validation/rules/UniqueTypeNames.mjs +50 -0
- package/validation/rules/UniqueVariableNames.js +2 -2
- package/validation/rules/UniqueVariableNames.js.flow +1 -1
- package/validation/rules/UniqueVariableNames.mjs +2 -2
- package/validation/rules/ValuesOfCorrectType.js +30 -14
- package/validation/rules/ValuesOfCorrectType.js.flow +5 -6
- package/validation/rules/ValuesOfCorrectType.mjs +29 -14
- package/validation/rules/VariablesAreInputTypes.js +3 -3
- package/validation/rules/VariablesAreInputTypes.js.flow +2 -2
- package/validation/rules/VariablesAreInputTypes.mjs +3 -3
- package/validation/rules/VariablesInAllowedPosition.js +5 -5
- package/validation/rules/VariablesInAllowedPosition.js.flow +1 -1
- package/validation/rules/VariablesInAllowedPosition.mjs +5 -5
- package/validation/specifiedRules.js +15 -3
- package/validation/specifiedRules.js.flow +14 -1
- package/validation/specifiedRules.mjs +9 -3
- package/validation/validate.js +2 -2
- package/validation/validate.js.flow +1 -1
- package/validation/validate.mjs +2 -2
- package/jsutils/find.js +0 -22
- package/jsutils/find.js.flow +0 -19
- package/jsutils/find.mjs +0 -15
|
@@ -5,20 +5,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.extendSchema = extendSchema;
|
|
7
7
|
|
|
8
|
+
var _flatMap = _interopRequireDefault(require("../polyfills/flatMap"));
|
|
9
|
+
|
|
10
|
+
var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
|
|
11
|
+
|
|
12
|
+
var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
|
|
13
|
+
|
|
8
14
|
var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
|
|
9
15
|
|
|
10
|
-
var
|
|
16
|
+
var _mapValue = _interopRequireDefault(require("../jsutils/mapValue"));
|
|
11
17
|
|
|
12
18
|
var _keyValMap = _interopRequireDefault(require("../jsutils/keyValMap"));
|
|
13
19
|
|
|
14
|
-
var _objectValues = _interopRequireDefault(require("../jsutils/objectValues"));
|
|
15
|
-
|
|
16
20
|
var _buildASTSchema = require("./buildASTSchema");
|
|
17
21
|
|
|
18
22
|
var _validate = require("../validation/validate");
|
|
19
23
|
|
|
20
|
-
var _GraphQLError = require("../error/GraphQLError");
|
|
21
|
-
|
|
22
24
|
var _schema = require("../type/schema");
|
|
23
25
|
|
|
24
26
|
var _introspection = require("../type/introspection");
|
|
@@ -58,7 +60,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
58
60
|
*
|
|
59
61
|
*/
|
|
60
62
|
function extendSchema(schema, documentAST, options) {
|
|
61
|
-
|
|
63
|
+
(0, _schema.assertSchema)(schema);
|
|
62
64
|
!(documentAST && documentAST.kind === _kinds.Kind.DOCUMENT) ? (0, _invariant.default)(0, 'Must provide valid Document AST') : void 0;
|
|
63
65
|
|
|
64
66
|
if (!options || !(options.assumeValid || options.assumeValidSDL)) {
|
|
@@ -66,729 +68,353 @@ function extendSchema(schema, documentAST, options) {
|
|
|
66
68
|
} // Collect the type definitions and extensions found in the document.
|
|
67
69
|
|
|
68
70
|
|
|
69
|
-
var
|
|
70
|
-
var
|
|
71
|
+
var typeDefs = [];
|
|
72
|
+
var typeExtsMap = Object.create(null); // New directives and types are separate because a directives and types can
|
|
71
73
|
// have the same name. For example, a type named "skip".
|
|
72
74
|
|
|
73
|
-
var
|
|
75
|
+
var directiveDefs = [];
|
|
74
76
|
var schemaDef; // Schema extensions are collected which may add additional operation types.
|
|
75
77
|
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
78
|
+
var schemaExts = [];
|
|
79
|
+
var _iteratorNormalCompletion = true;
|
|
80
|
+
var _didIteratorError = false;
|
|
81
|
+
var _iteratorError = undefined;
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
for (var _iterator = documentAST.definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
85
|
+
var def = _step.value;
|
|
86
|
+
|
|
87
|
+
if (def.kind === _kinds.Kind.SCHEMA_DEFINITION) {
|
|
88
|
+
schemaDef = def;
|
|
89
|
+
} else if (def.kind === _kinds.Kind.SCHEMA_EXTENSION) {
|
|
90
|
+
schemaExts.push(def);
|
|
91
|
+
} else if ((0, _predicates.isTypeDefinitionNode)(def)) {
|
|
92
|
+
typeDefs.push(def);
|
|
93
|
+
} else if ((0, _predicates.isTypeExtensionNode)(def)) {
|
|
94
|
+
var extendedTypeName = def.name.value;
|
|
95
|
+
var existingTypeExts = typeExtsMap[extendedTypeName];
|
|
96
|
+
typeExtsMap[extendedTypeName] = existingTypeExts ? existingTypeExts.concat([def]) : [def];
|
|
97
|
+
} else if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
|
|
98
|
+
directiveDefs.push(def);
|
|
92
99
|
}
|
|
100
|
+
} // If this document contains no new types, extensions, or directives then
|
|
101
|
+
// return the same unmodified GraphQLSchema instance.
|
|
93
102
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (!existingType) {
|
|
102
|
-
throw new _GraphQLError.GraphQLError("Cannot extend type \"".concat(extendedTypeName, "\" because it does not ") + 'exist in the existing schema.', [def]);
|
|
103
|
+
} catch (err) {
|
|
104
|
+
_didIteratorError = true;
|
|
105
|
+
_iteratorError = err;
|
|
106
|
+
} finally {
|
|
107
|
+
try {
|
|
108
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
109
|
+
_iterator.return();
|
|
103
110
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
typeExtensionsMap[extendedTypeName] = existingTypeExtensions ? existingTypeExtensions.concat([def]) : [def];
|
|
108
|
-
} else if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
|
|
109
|
-
var directiveName = def.name.value;
|
|
110
|
-
var existingDirective = schema.getDirective(directiveName);
|
|
111
|
-
|
|
112
|
-
if (existingDirective) {
|
|
113
|
-
throw new _GraphQLError.GraphQLError("Directive \"".concat(directiveName, "\" already exists in the schema. It ") + 'cannot be redefined.', [def]);
|
|
111
|
+
} finally {
|
|
112
|
+
if (_didIteratorError) {
|
|
113
|
+
throw _iteratorError;
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
directiveDefinitions.push(def);
|
|
117
115
|
}
|
|
118
|
-
}
|
|
119
|
-
// return the same unmodified GraphQLSchema instance.
|
|
120
|
-
|
|
116
|
+
}
|
|
121
117
|
|
|
122
|
-
if (Object.keys(
|
|
118
|
+
if (Object.keys(typeExtsMap).length === 0 && typeDefs.length === 0 && directiveDefs.length === 0 && schemaExts.length === 0 && !schemaDef) {
|
|
123
119
|
return schema;
|
|
124
120
|
}
|
|
125
121
|
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
var
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
122
|
+
var schemaConfig = schema.toConfig();
|
|
123
|
+
var astBuilder = new _buildASTSchema.ASTDefinitionBuilder(options, function (typeName) {
|
|
124
|
+
var type = typeMap[typeName];
|
|
125
|
+
!type ? (0, _invariant.default)(0, "Unknown type: \"".concat(typeName, "\".")) : void 0;
|
|
126
|
+
return type;
|
|
127
|
+
});
|
|
128
|
+
var typeMap = (0, _keyValMap.default)(typeDefs, function (node) {
|
|
129
|
+
return node.name.value;
|
|
130
|
+
}, function (node) {
|
|
131
|
+
return astBuilder.buildType(node);
|
|
135
132
|
});
|
|
136
|
-
var
|
|
133
|
+
var _iteratorNormalCompletion2 = true;
|
|
134
|
+
var _didIteratorError2 = false;
|
|
135
|
+
var _iteratorError2 = undefined;
|
|
136
|
+
|
|
137
|
+
try {
|
|
138
|
+
for (var _iterator2 = schemaConfig.types[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
139
|
+
var existingType = _step2.value;
|
|
140
|
+
typeMap[existingType.name] = extendNamedType(existingType);
|
|
141
|
+
} // Get the extended root operation types.
|
|
142
|
+
|
|
143
|
+
} catch (err) {
|
|
144
|
+
_didIteratorError2 = true;
|
|
145
|
+
_iteratorError2 = err;
|
|
146
|
+
} finally {
|
|
147
|
+
try {
|
|
148
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
149
|
+
_iterator2.return();
|
|
150
|
+
}
|
|
151
|
+
} finally {
|
|
152
|
+
if (_didIteratorError2) {
|
|
153
|
+
throw _iteratorError2;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
137
157
|
|
|
138
158
|
var operationTypes = {
|
|
139
|
-
query:
|
|
140
|
-
mutation:
|
|
141
|
-
subscription:
|
|
159
|
+
query: schemaConfig.query && schemaConfig.query.name,
|
|
160
|
+
mutation: schemaConfig.mutation && schemaConfig.mutation.name,
|
|
161
|
+
subscription: schemaConfig.subscription && schemaConfig.subscription.name
|
|
142
162
|
};
|
|
143
163
|
|
|
144
164
|
if (schemaDef) {
|
|
145
|
-
var
|
|
146
|
-
var
|
|
147
|
-
var
|
|
165
|
+
var _iteratorNormalCompletion3 = true;
|
|
166
|
+
var _didIteratorError3 = false;
|
|
167
|
+
var _iteratorError3 = undefined;
|
|
148
168
|
|
|
149
169
|
try {
|
|
150
|
-
for (var
|
|
151
|
-
var _ref2 =
|
|
152
|
-
var operation = _ref2.operation
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (operationTypes[operation]) {
|
|
156
|
-
throw new Error("Must provide only one ".concat(operation, " type in schema."));
|
|
157
|
-
} // Note: While this could make early assertions to get the correctly
|
|
158
|
-
// typed values, that would throw immediately while type system
|
|
159
|
-
// validation with validateSchema() will produce more actionable results.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
operationTypes[operation] = astBuilder.buildType(type);
|
|
170
|
+
for (var _iterator3 = schemaDef.operationTypes[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
171
|
+
var _ref2 = _step3.value;
|
|
172
|
+
var operation = _ref2.operation;
|
|
173
|
+
var type = _ref2.type;
|
|
174
|
+
operationTypes[operation] = type.name.value;
|
|
163
175
|
}
|
|
164
176
|
} catch (err) {
|
|
165
|
-
|
|
166
|
-
|
|
177
|
+
_didIteratorError3 = true;
|
|
178
|
+
_iteratorError3 = err;
|
|
167
179
|
} finally {
|
|
168
180
|
try {
|
|
169
|
-
if (!
|
|
170
|
-
|
|
181
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
182
|
+
_iterator3.return();
|
|
171
183
|
}
|
|
172
184
|
} finally {
|
|
173
|
-
if (
|
|
174
|
-
throw
|
|
185
|
+
if (_didIteratorError3) {
|
|
186
|
+
throw _iteratorError3;
|
|
175
187
|
}
|
|
176
188
|
}
|
|
177
189
|
}
|
|
178
190
|
} // Then, incorporate schema definition and all schema extensions.
|
|
179
191
|
|
|
180
192
|
|
|
181
|
-
|
|
182
|
-
var schemaExtension = schemaExtensions[_i];
|
|
193
|
+
var _arr = schemaExts;
|
|
183
194
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
var _didIteratorError12 = false;
|
|
187
|
-
var _iteratorError12 = undefined;
|
|
188
|
-
|
|
189
|
-
try {
|
|
190
|
-
for (var _iterator12 = schemaExtension.operationTypes[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
|
|
191
|
-
var _ref4 = _step12.value;
|
|
192
|
-
var operation = _ref4.operation,
|
|
193
|
-
type = _ref4.type;
|
|
194
|
-
|
|
195
|
-
if (operationTypes[operation]) {
|
|
196
|
-
throw new Error("Must provide only one ".concat(operation, " type in schema."));
|
|
197
|
-
} // Note: While this could make early assertions to get the correctly
|
|
198
|
-
// typed values, that would throw immediately while type system
|
|
199
|
-
// validation with validateSchema() will produce more actionable results.
|
|
195
|
+
for (var _i = 0; _i < _arr.length; _i++) {
|
|
196
|
+
var schemaExt = _arr[_i];
|
|
200
197
|
|
|
198
|
+
if (schemaExt.operationTypes) {
|
|
199
|
+
var _iteratorNormalCompletion4 = true;
|
|
200
|
+
var _didIteratorError4 = false;
|
|
201
|
+
var _iteratorError4 = undefined;
|
|
201
202
|
|
|
202
|
-
|
|
203
|
+
try {
|
|
204
|
+
for (var _iterator4 = schemaExt.operationTypes[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
|
205
|
+
var _ref4 = _step4.value;
|
|
206
|
+
var _operation = _ref4.operation;
|
|
207
|
+
var _type = _ref4.type;
|
|
208
|
+
operationTypes[_operation] = _type.name.value;
|
|
203
209
|
}
|
|
204
210
|
} catch (err) {
|
|
205
|
-
|
|
206
|
-
|
|
211
|
+
_didIteratorError4 = true;
|
|
212
|
+
_iteratorError4 = err;
|
|
207
213
|
} finally {
|
|
208
214
|
try {
|
|
209
|
-
if (!
|
|
210
|
-
|
|
215
|
+
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
|
216
|
+
_iterator4.return();
|
|
211
217
|
}
|
|
212
218
|
} finally {
|
|
213
|
-
if (
|
|
214
|
-
throw
|
|
219
|
+
if (_didIteratorError4) {
|
|
220
|
+
throw _iteratorError4;
|
|
215
221
|
}
|
|
216
222
|
}
|
|
217
223
|
}
|
|
218
224
|
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
var schemaExtensionASTNodes = schemaExtensions ? schema.extensionASTNodes ? schema.extensionASTNodes.concat(schemaExtensions) : schemaExtensions : schema.extensionASTNodes;
|
|
222
|
-
var types = (0, _objectValues.default)(schema.getTypeMap()).map(function (type) {
|
|
223
|
-
return extendNamedType(type);
|
|
224
|
-
}).concat((0, _objectValues.default)(typeDefinitionMap).map(function (type) {
|
|
225
|
-
return astBuilder.buildType(type);
|
|
226
|
-
})); // Support both original legacy names and extended legacy names.
|
|
225
|
+
} // Support both original legacy names and extended legacy names.
|
|
227
226
|
|
|
228
|
-
var allowedLegacyNames = schema.__allowedLegacyNames.concat(options && options.allowedLegacyNames || []); // Then produce and return a Schema with these types.
|
|
229
227
|
|
|
228
|
+
var allowedLegacyNames = schemaConfig.allowedLegacyNames.concat(options && options.allowedLegacyNames || []); // Then produce and return a Schema with these types.
|
|
230
229
|
|
|
231
|
-
return new _schema.GraphQLSchema(
|
|
232
|
-
|
|
230
|
+
return new _schema.GraphQLSchema({
|
|
231
|
+
// Note: While this could make early assertions to get the correctly
|
|
232
|
+
// typed values, that would throw immediately while type system
|
|
233
|
+
// validation with validateSchema() will produce more actionable results.
|
|
234
|
+
query: getMaybeTypeByName(operationTypes.query),
|
|
235
|
+
mutation: getMaybeTypeByName(operationTypes.mutation),
|
|
236
|
+
subscription: getMaybeTypeByName(operationTypes.subscription),
|
|
237
|
+
types: (0, _objectValues.default)(typeMap),
|
|
233
238
|
directives: getMergedDirectives(),
|
|
234
|
-
astNode:
|
|
235
|
-
extensionASTNodes:
|
|
239
|
+
astNode: schemaDef || schemaConfig.astNode,
|
|
240
|
+
extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExts),
|
|
236
241
|
allowedLegacyNames: allowedLegacyNames
|
|
237
|
-
})
|
|
242
|
+
}); // Below are functions used for producing this schema that have closed over
|
|
238
243
|
// this scope and have access to the schema, cache, and newly defined types.
|
|
239
244
|
|
|
245
|
+
function replaceType(type) {
|
|
246
|
+
if ((0, _definition.isListType)(type)) {
|
|
247
|
+
return new _definition.GraphQLList(replaceType(type.ofType));
|
|
248
|
+
} else if ((0, _definition.isNonNullType)(type)) {
|
|
249
|
+
return new _definition.GraphQLNonNull(replaceType(type.ofType));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return replaceNamedType(type);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function replaceNamedType(type) {
|
|
256
|
+
return typeMap[type.name];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function getMaybeTypeByName(typeName) {
|
|
260
|
+
return typeName ? typeMap[typeName] : null;
|
|
261
|
+
}
|
|
262
|
+
|
|
240
263
|
function getMergedDirectives() {
|
|
241
264
|
var existingDirectives = schema.getDirectives().map(extendDirective);
|
|
242
265
|
!existingDirectives ? (0, _invariant.default)(0, 'schema must have default directives') : void 0;
|
|
243
|
-
return existingDirectives.concat(
|
|
266
|
+
return existingDirectives.concat(directiveDefs.map(function (node) {
|
|
244
267
|
return astBuilder.buildDirective(node);
|
|
245
268
|
}));
|
|
246
269
|
}
|
|
247
270
|
|
|
248
|
-
function extendMaybeNamedType(type) {
|
|
249
|
-
return type ? extendNamedType(type) : null;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
271
|
function extendNamedType(type) {
|
|
253
272
|
if ((0, _introspection.isIntrospectionType)(type) || (0, _scalars.isSpecifiedScalarType)(type)) {
|
|
254
273
|
// Builtin types are not extended.
|
|
255
274
|
return type;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
if (
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return extendTypeCache[name];
|
|
275
|
+
} else if ((0, _definition.isScalarType)(type)) {
|
|
276
|
+
return extendScalarType(type);
|
|
277
|
+
} else if ((0, _definition.isObjectType)(type)) {
|
|
278
|
+
return extendObjectType(type);
|
|
279
|
+
} else if ((0, _definition.isInterfaceType)(type)) {
|
|
280
|
+
return extendInterfaceType(type);
|
|
281
|
+
} else if ((0, _definition.isUnionType)(type)) {
|
|
282
|
+
return extendUnionType(type);
|
|
283
|
+
} else if ((0, _definition.isEnumType)(type)) {
|
|
284
|
+
return extendEnumType(type);
|
|
285
|
+
} else if ((0, _definition.isInputObjectType)(type)) {
|
|
286
|
+
return extendInputObjectType(type);
|
|
287
|
+
} // Not reachable. All possible types have been considered.
|
|
288
|
+
|
|
289
|
+
/* istanbul ignore next */
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
throw new Error("Unexpected type: \"".concat((0, _inspect.default)(type), "\"."));
|
|
277
293
|
}
|
|
278
294
|
|
|
279
295
|
function extendDirective(directive) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
args: extendArgs(directive.args),
|
|
285
|
-
astNode: directive.astNode
|
|
286
|
-
});
|
|
296
|
+
var config = directive.toConfig();
|
|
297
|
+
return new _directives.GraphQLDirective(_objectSpread({}, config, {
|
|
298
|
+
args: (0, _mapValue.default)(config.args, extendArg)
|
|
299
|
+
}));
|
|
287
300
|
}
|
|
288
301
|
|
|
289
302
|
function extendInputObjectType(type) {
|
|
290
|
-
var
|
|
291
|
-
var
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
303
|
+
var config = type.toConfig();
|
|
304
|
+
var extensions = typeExtsMap[config.name] || [];
|
|
305
|
+
var fieldNodes = (0, _flatMap.default)(extensions, function (node) {
|
|
306
|
+
return node.fields || [];
|
|
307
|
+
});
|
|
308
|
+
return new _definition.GraphQLInputObjectType(_objectSpread({}, config, {
|
|
295
309
|
fields: function fields() {
|
|
296
|
-
return
|
|
310
|
+
return _objectSpread({}, (0, _mapValue.default)(config.fields, function (field) {
|
|
311
|
+
return _objectSpread({}, field, {
|
|
312
|
+
type: replaceType(field.type)
|
|
313
|
+
});
|
|
314
|
+
}), (0, _keyValMap.default)(fieldNodes, function (field) {
|
|
315
|
+
return field.name.value;
|
|
316
|
+
}, function (field) {
|
|
317
|
+
return astBuilder.buildInputField(field);
|
|
318
|
+
}));
|
|
297
319
|
},
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
function extendInputFieldMap(type) {
|
|
304
|
-
var newFieldMap = Object.create(null);
|
|
305
|
-
var oldFieldMap = type.getFields();
|
|
306
|
-
|
|
307
|
-
var _arr = Object.keys(oldFieldMap);
|
|
308
|
-
|
|
309
|
-
for (var _i2 = 0; _i2 < _arr.length; _i2++) {
|
|
310
|
-
var _fieldName = _arr[_i2];
|
|
311
|
-
var _field = oldFieldMap[_fieldName];
|
|
312
|
-
newFieldMap[_fieldName] = {
|
|
313
|
-
description: _field.description,
|
|
314
|
-
type: extendType(_field.type),
|
|
315
|
-
defaultValue: _field.defaultValue,
|
|
316
|
-
astNode: _field.astNode
|
|
317
|
-
};
|
|
318
|
-
} // If there are any extensions to the fields, apply those here.
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
var extensions = typeExtensionsMap[type.name];
|
|
322
|
-
|
|
323
|
-
if (extensions) {
|
|
324
|
-
var _iteratorNormalCompletion2 = true;
|
|
325
|
-
var _didIteratorError2 = false;
|
|
326
|
-
var _iteratorError2 = undefined;
|
|
327
|
-
|
|
328
|
-
try {
|
|
329
|
-
for (var _iterator2 = extensions[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
330
|
-
var extension = _step2.value;
|
|
331
|
-
var _iteratorNormalCompletion3 = true;
|
|
332
|
-
var _didIteratorError3 = false;
|
|
333
|
-
var _iteratorError3 = undefined;
|
|
334
|
-
|
|
335
|
-
try {
|
|
336
|
-
for (var _iterator3 = extension.fields[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
337
|
-
var field = _step3.value;
|
|
338
|
-
var fieldName = field.name.value;
|
|
339
|
-
|
|
340
|
-
if (oldFieldMap[fieldName]) {
|
|
341
|
-
throw new _GraphQLError.GraphQLError("Field \"".concat(type.name, ".").concat(fieldName, "\" already exists in the ") + 'schema. It cannot also be defined in this type extension.', [field]);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
newFieldMap[fieldName] = astBuilder.buildInputField(field);
|
|
345
|
-
}
|
|
346
|
-
} catch (err) {
|
|
347
|
-
_didIteratorError3 = true;
|
|
348
|
-
_iteratorError3 = err;
|
|
349
|
-
} finally {
|
|
350
|
-
try {
|
|
351
|
-
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
352
|
-
_iterator3.return();
|
|
353
|
-
}
|
|
354
|
-
} finally {
|
|
355
|
-
if (_didIteratorError3) {
|
|
356
|
-
throw _iteratorError3;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
} catch (err) {
|
|
362
|
-
_didIteratorError2 = true;
|
|
363
|
-
_iteratorError2 = err;
|
|
364
|
-
} finally {
|
|
365
|
-
try {
|
|
366
|
-
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
367
|
-
_iterator2.return();
|
|
368
|
-
}
|
|
369
|
-
} finally {
|
|
370
|
-
if (_didIteratorError2) {
|
|
371
|
-
throw _iteratorError2;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
return newFieldMap;
|
|
320
|
+
extensionASTNodes: config.extensionASTNodes.concat(extensions)
|
|
321
|
+
}));
|
|
378
322
|
}
|
|
379
323
|
|
|
380
324
|
function extendEnumType(type) {
|
|
381
|
-
var
|
|
382
|
-
var
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
description: type.description,
|
|
386
|
-
values: extendValueMap(type),
|
|
387
|
-
astNode: type.astNode,
|
|
388
|
-
extensionASTNodes: extensionASTNodes
|
|
325
|
+
var config = type.toConfig();
|
|
326
|
+
var extensions = typeExtsMap[type.name] || [];
|
|
327
|
+
var valueNodes = (0, _flatMap.default)(extensions, function (node) {
|
|
328
|
+
return node.values || [];
|
|
389
329
|
});
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
var _arr2 = Object.keys(oldValueMap);
|
|
399
|
-
|
|
400
|
-
for (var _i3 = 0; _i3 < _arr2.length; _i3++) {
|
|
401
|
-
var _valueName = _arr2[_i3];
|
|
402
|
-
var _value = oldValueMap[_valueName];
|
|
403
|
-
newValueMap[_valueName] = {
|
|
404
|
-
name: _value.name,
|
|
405
|
-
description: _value.description,
|
|
406
|
-
value: _value.value,
|
|
407
|
-
deprecationReason: _value.deprecationReason,
|
|
408
|
-
astNode: _value.astNode
|
|
409
|
-
};
|
|
410
|
-
} // If there are any extensions to the values, apply those here.
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
var extensions = typeExtensionsMap[type.name];
|
|
414
|
-
|
|
415
|
-
if (extensions) {
|
|
416
|
-
var _iteratorNormalCompletion4 = true;
|
|
417
|
-
var _didIteratorError4 = false;
|
|
418
|
-
var _iteratorError4 = undefined;
|
|
419
|
-
|
|
420
|
-
try {
|
|
421
|
-
for (var _iterator4 = extensions[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
|
422
|
-
var extension = _step4.value;
|
|
423
|
-
var _iteratorNormalCompletion5 = true;
|
|
424
|
-
var _didIteratorError5 = false;
|
|
425
|
-
var _iteratorError5 = undefined;
|
|
426
|
-
|
|
427
|
-
try {
|
|
428
|
-
for (var _iterator5 = extension.values[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
|
429
|
-
var value = _step5.value;
|
|
430
|
-
var valueName = value.name.value;
|
|
431
|
-
|
|
432
|
-
if (oldValueMap[valueName]) {
|
|
433
|
-
throw new _GraphQLError.GraphQLError("Enum value \"".concat(type.name, ".").concat(valueName, "\" already exists in the ") + 'schema. It cannot also be defined in this type extension.', [value]);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
newValueMap[valueName] = astBuilder.buildEnumValue(value);
|
|
437
|
-
}
|
|
438
|
-
} catch (err) {
|
|
439
|
-
_didIteratorError5 = true;
|
|
440
|
-
_iteratorError5 = err;
|
|
441
|
-
} finally {
|
|
442
|
-
try {
|
|
443
|
-
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
|
|
444
|
-
_iterator5.return();
|
|
445
|
-
}
|
|
446
|
-
} finally {
|
|
447
|
-
if (_didIteratorError5) {
|
|
448
|
-
throw _iteratorError5;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
} catch (err) {
|
|
454
|
-
_didIteratorError4 = true;
|
|
455
|
-
_iteratorError4 = err;
|
|
456
|
-
} finally {
|
|
457
|
-
try {
|
|
458
|
-
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
|
459
|
-
_iterator4.return();
|
|
460
|
-
}
|
|
461
|
-
} finally {
|
|
462
|
-
if (_didIteratorError4) {
|
|
463
|
-
throw _iteratorError4;
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
return newValueMap;
|
|
330
|
+
return new _definition.GraphQLEnumType(_objectSpread({}, config, {
|
|
331
|
+
values: _objectSpread({}, config.values, (0, _keyValMap.default)(valueNodes, function (value) {
|
|
332
|
+
return value.name.value;
|
|
333
|
+
}, function (value) {
|
|
334
|
+
return astBuilder.buildEnumValue(value);
|
|
335
|
+
})),
|
|
336
|
+
extensionASTNodes: config.extensionASTNodes.concat(extensions)
|
|
337
|
+
}));
|
|
470
338
|
}
|
|
471
339
|
|
|
472
340
|
function extendScalarType(type) {
|
|
473
|
-
var
|
|
474
|
-
var
|
|
475
|
-
return new _definition.GraphQLScalarType({
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
astNode: type.astNode,
|
|
479
|
-
extensionASTNodes: extensionASTNodes,
|
|
480
|
-
serialize: type.serialize,
|
|
481
|
-
parseValue: type.parseValue,
|
|
482
|
-
parseLiteral: type.parseLiteral
|
|
483
|
-
});
|
|
341
|
+
var config = type.toConfig();
|
|
342
|
+
var extensions = typeExtsMap[config.name] || [];
|
|
343
|
+
return new _definition.GraphQLScalarType(_objectSpread({}, config, {
|
|
344
|
+
extensionASTNodes: config.extensionASTNodes.concat(extensions)
|
|
345
|
+
}));
|
|
484
346
|
}
|
|
485
347
|
|
|
486
348
|
function extendObjectType(type) {
|
|
487
|
-
var
|
|
488
|
-
var
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
349
|
+
var config = type.toConfig();
|
|
350
|
+
var extensions = typeExtsMap[config.name] || [];
|
|
351
|
+
var interfaceNodes = (0, _flatMap.default)(extensions, function (node) {
|
|
352
|
+
return node.interfaces || [];
|
|
353
|
+
});
|
|
354
|
+
var fieldNodes = (0, _flatMap.default)(extensions, function (node) {
|
|
355
|
+
return node.fields || [];
|
|
356
|
+
});
|
|
357
|
+
return new _definition.GraphQLObjectType(_objectSpread({}, config, {
|
|
492
358
|
interfaces: function interfaces() {
|
|
493
|
-
return
|
|
359
|
+
return [].concat(type.getInterfaces().map(replaceNamedType), interfaceNodes.map(function (node) {
|
|
360
|
+
return astBuilder.getNamedType(node);
|
|
361
|
+
}));
|
|
494
362
|
},
|
|
495
363
|
fields: function fields() {
|
|
496
|
-
return
|
|
364
|
+
return _objectSpread({}, (0, _mapValue.default)(config.fields, extendField), (0, _keyValMap.default)(fieldNodes, function (node) {
|
|
365
|
+
return node.name.value;
|
|
366
|
+
}, function (node) {
|
|
367
|
+
return astBuilder.buildField(node);
|
|
368
|
+
}));
|
|
497
369
|
},
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
isTypeOf: type.isTypeOf
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
function extendArgs(args) {
|
|
505
|
-
return (0, _keyValMap.default)(args, function (arg) {
|
|
506
|
-
return arg.name;
|
|
507
|
-
}, function (arg) {
|
|
508
|
-
return {
|
|
509
|
-
type: extendType(arg.type),
|
|
510
|
-
defaultValue: arg.defaultValue,
|
|
511
|
-
description: arg.description,
|
|
512
|
-
astNode: arg.astNode
|
|
513
|
-
};
|
|
514
|
-
});
|
|
370
|
+
extensionASTNodes: config.extensionASTNodes.concat(extensions)
|
|
371
|
+
}));
|
|
515
372
|
}
|
|
516
373
|
|
|
517
374
|
function extendInterfaceType(type) {
|
|
518
|
-
var
|
|
519
|
-
var
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
375
|
+
var config = type.toConfig();
|
|
376
|
+
var extensions = typeExtsMap[config.name] || [];
|
|
377
|
+
var fieldNodes = (0, _flatMap.default)(extensions, function (node) {
|
|
378
|
+
return node.fields || [];
|
|
379
|
+
});
|
|
380
|
+
return new _definition.GraphQLInterfaceType(_objectSpread({}, config, {
|
|
523
381
|
fields: function fields() {
|
|
524
|
-
return
|
|
382
|
+
return _objectSpread({}, (0, _mapValue.default)(config.fields, extendField), (0, _keyValMap.default)(fieldNodes, function (node) {
|
|
383
|
+
return node.name.value;
|
|
384
|
+
}, function (node) {
|
|
385
|
+
return astBuilder.buildField(node);
|
|
386
|
+
}));
|
|
525
387
|
},
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
resolveType: type.resolveType
|
|
529
|
-
});
|
|
388
|
+
extensionASTNodes: config.extensionASTNodes.concat(extensions)
|
|
389
|
+
}));
|
|
530
390
|
}
|
|
531
391
|
|
|
532
392
|
function extendUnionType(type) {
|
|
533
|
-
var
|
|
534
|
-
var
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
393
|
+
var config = type.toConfig();
|
|
394
|
+
var extensions = typeExtsMap[config.name] || [];
|
|
395
|
+
var typeNodes = (0, _flatMap.default)(extensions, function (node) {
|
|
396
|
+
return node.types || [];
|
|
397
|
+
});
|
|
398
|
+
return new _definition.GraphQLUnionType(_objectSpread({}, config, {
|
|
538
399
|
types: function types() {
|
|
539
|
-
return
|
|
400
|
+
return [].concat(type.getTypes().map(replaceNamedType), typeNodes.map(function (node) {
|
|
401
|
+
return astBuilder.getNamedType(node);
|
|
402
|
+
}));
|
|
540
403
|
},
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
extensionASTNodes: extensionASTNodes
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
function extendPossibleTypes(type) {
|
|
548
|
-
var possibleTypes = type.getTypes().map(extendNamedType); // If there are any extensions to the union, apply those here.
|
|
549
|
-
|
|
550
|
-
var extensions = typeExtensionsMap[type.name];
|
|
551
|
-
|
|
552
|
-
if (extensions) {
|
|
553
|
-
var _iteratorNormalCompletion6 = true;
|
|
554
|
-
var _didIteratorError6 = false;
|
|
555
|
-
var _iteratorError6 = undefined;
|
|
556
|
-
|
|
557
|
-
try {
|
|
558
|
-
for (var _iterator6 = extensions[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
|
|
559
|
-
var extension = _step6.value;
|
|
560
|
-
var _iteratorNormalCompletion7 = true;
|
|
561
|
-
var _didIteratorError7 = false;
|
|
562
|
-
var _iteratorError7 = undefined;
|
|
563
|
-
|
|
564
|
-
try {
|
|
565
|
-
for (var _iterator7 = extension.types[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
|
|
566
|
-
var namedType = _step7.value;
|
|
567
|
-
// Note: While this could make early assertions to get the correctly
|
|
568
|
-
// typed values, that would throw immediately while type system
|
|
569
|
-
// validation with validateSchema() will produce more actionable results.
|
|
570
|
-
possibleTypes.push(astBuilder.buildType(namedType));
|
|
571
|
-
}
|
|
572
|
-
} catch (err) {
|
|
573
|
-
_didIteratorError7 = true;
|
|
574
|
-
_iteratorError7 = err;
|
|
575
|
-
} finally {
|
|
576
|
-
try {
|
|
577
|
-
if (!_iteratorNormalCompletion7 && _iterator7.return != null) {
|
|
578
|
-
_iterator7.return();
|
|
579
|
-
}
|
|
580
|
-
} finally {
|
|
581
|
-
if (_didIteratorError7) {
|
|
582
|
-
throw _iteratorError7;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
} catch (err) {
|
|
588
|
-
_didIteratorError6 = true;
|
|
589
|
-
_iteratorError6 = err;
|
|
590
|
-
} finally {
|
|
591
|
-
try {
|
|
592
|
-
if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
|
|
593
|
-
_iterator6.return();
|
|
594
|
-
}
|
|
595
|
-
} finally {
|
|
596
|
-
if (_didIteratorError6) {
|
|
597
|
-
throw _iteratorError6;
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
return possibleTypes;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
function extendImplementedInterfaces(type) {
|
|
607
|
-
var interfaces = type.getInterfaces().map(extendNamedType); // If there are any extensions to the interfaces, apply those here.
|
|
608
|
-
|
|
609
|
-
var extensions = typeExtensionsMap[type.name];
|
|
610
|
-
|
|
611
|
-
if (extensions) {
|
|
612
|
-
var _iteratorNormalCompletion8 = true;
|
|
613
|
-
var _didIteratorError8 = false;
|
|
614
|
-
var _iteratorError8 = undefined;
|
|
615
|
-
|
|
616
|
-
try {
|
|
617
|
-
for (var _iterator8 = extensions[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
|
|
618
|
-
var extension = _step8.value;
|
|
619
|
-
var _iteratorNormalCompletion9 = true;
|
|
620
|
-
var _didIteratorError9 = false;
|
|
621
|
-
var _iteratorError9 = undefined;
|
|
622
|
-
|
|
623
|
-
try {
|
|
624
|
-
for (var _iterator9 = extension.interfaces[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
|
|
625
|
-
var namedType = _step9.value;
|
|
626
|
-
// Note: While this could make early assertions to get the correctly
|
|
627
|
-
// typed values, that would throw immediately while type system
|
|
628
|
-
// validation with validateSchema() will produce more actionable results.
|
|
629
|
-
interfaces.push(astBuilder.buildType(namedType));
|
|
630
|
-
}
|
|
631
|
-
} catch (err) {
|
|
632
|
-
_didIteratorError9 = true;
|
|
633
|
-
_iteratorError9 = err;
|
|
634
|
-
} finally {
|
|
635
|
-
try {
|
|
636
|
-
if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
|
|
637
|
-
_iterator9.return();
|
|
638
|
-
}
|
|
639
|
-
} finally {
|
|
640
|
-
if (_didIteratorError9) {
|
|
641
|
-
throw _iteratorError9;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
} catch (err) {
|
|
647
|
-
_didIteratorError8 = true;
|
|
648
|
-
_iteratorError8 = err;
|
|
649
|
-
} finally {
|
|
650
|
-
try {
|
|
651
|
-
if (!_iteratorNormalCompletion8 && _iterator8.return != null) {
|
|
652
|
-
_iterator8.return();
|
|
653
|
-
}
|
|
654
|
-
} finally {
|
|
655
|
-
if (_didIteratorError8) {
|
|
656
|
-
throw _iteratorError8;
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
return interfaces;
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
function extendFieldMap(type) {
|
|
666
|
-
var newFieldMap = Object.create(null);
|
|
667
|
-
var oldFieldMap = type.getFields();
|
|
668
|
-
|
|
669
|
-
var _arr3 = Object.keys(oldFieldMap);
|
|
670
|
-
|
|
671
|
-
for (var _i4 = 0; _i4 < _arr3.length; _i4++) {
|
|
672
|
-
var _fieldName2 = _arr3[_i4];
|
|
673
|
-
var _field2 = oldFieldMap[_fieldName2];
|
|
674
|
-
newFieldMap[_fieldName2] = {
|
|
675
|
-
description: _field2.description,
|
|
676
|
-
deprecationReason: _field2.deprecationReason,
|
|
677
|
-
type: extendType(_field2.type),
|
|
678
|
-
args: extendArgs(_field2.args),
|
|
679
|
-
astNode: _field2.astNode,
|
|
680
|
-
resolve: _field2.resolve
|
|
681
|
-
};
|
|
682
|
-
} // If there are any extensions to the fields, apply those here.
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
var extensions = typeExtensionsMap[type.name];
|
|
686
|
-
|
|
687
|
-
if (extensions) {
|
|
688
|
-
var _iteratorNormalCompletion10 = true;
|
|
689
|
-
var _didIteratorError10 = false;
|
|
690
|
-
var _iteratorError10 = undefined;
|
|
691
|
-
|
|
692
|
-
try {
|
|
693
|
-
for (var _iterator10 = extensions[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
|
|
694
|
-
var extension = _step10.value;
|
|
695
|
-
var _iteratorNormalCompletion11 = true;
|
|
696
|
-
var _didIteratorError11 = false;
|
|
697
|
-
var _iteratorError11 = undefined;
|
|
698
|
-
|
|
699
|
-
try {
|
|
700
|
-
for (var _iterator11 = extension.fields[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
|
|
701
|
-
var field = _step11.value;
|
|
702
|
-
var fieldName = field.name.value;
|
|
703
|
-
|
|
704
|
-
if (oldFieldMap[fieldName]) {
|
|
705
|
-
throw new _GraphQLError.GraphQLError("Field \"".concat(type.name, ".").concat(fieldName, "\" already exists in the ") + 'schema. It cannot also be defined in this type extension.', [field]);
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
newFieldMap[fieldName] = astBuilder.buildField(field);
|
|
709
|
-
}
|
|
710
|
-
} catch (err) {
|
|
711
|
-
_didIteratorError11 = true;
|
|
712
|
-
_iteratorError11 = err;
|
|
713
|
-
} finally {
|
|
714
|
-
try {
|
|
715
|
-
if (!_iteratorNormalCompletion11 && _iterator11.return != null) {
|
|
716
|
-
_iterator11.return();
|
|
717
|
-
}
|
|
718
|
-
} finally {
|
|
719
|
-
if (_didIteratorError11) {
|
|
720
|
-
throw _iteratorError11;
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
} catch (err) {
|
|
726
|
-
_didIteratorError10 = true;
|
|
727
|
-
_iteratorError10 = err;
|
|
728
|
-
} finally {
|
|
729
|
-
try {
|
|
730
|
-
if (!_iteratorNormalCompletion10 && _iterator10.return != null) {
|
|
731
|
-
_iterator10.return();
|
|
732
|
-
}
|
|
733
|
-
} finally {
|
|
734
|
-
if (_didIteratorError10) {
|
|
735
|
-
throw _iteratorError10;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
return newFieldMap;
|
|
404
|
+
extensionASTNodes: config.extensionASTNodes.concat(extensions)
|
|
405
|
+
}));
|
|
742
406
|
}
|
|
743
407
|
|
|
744
|
-
function
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
if ((0, _definition.isNonNullType)(typeDef)) {
|
|
750
|
-
return (0, _definition.GraphQLNonNull)(extendType(typeDef.ofType));
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
return extendNamedType(typeDef);
|
|
408
|
+
function extendField(field) {
|
|
409
|
+
return _objectSpread({}, field, {
|
|
410
|
+
type: replaceType(field.type),
|
|
411
|
+
args: (0, _mapValue.default)(field.args, extendArg)
|
|
412
|
+
});
|
|
754
413
|
}
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
function checkExtensionNode(type, node) {
|
|
758
|
-
switch (node.kind) {
|
|
759
|
-
case _kinds.Kind.OBJECT_TYPE_EXTENSION:
|
|
760
|
-
if (!(0, _definition.isObjectType)(type)) {
|
|
761
|
-
throw new _GraphQLError.GraphQLError("Cannot extend non-object type \"".concat(type.name, "\"."), [node]);
|
|
762
|
-
}
|
|
763
414
|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
throw new _GraphQLError.GraphQLError("Cannot extend non-interface type \"".concat(type.name, "\"."), [node]);
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
break;
|
|
772
|
-
|
|
773
|
-
case _kinds.Kind.ENUM_TYPE_EXTENSION:
|
|
774
|
-
if (!(0, _definition.isEnumType)(type)) {
|
|
775
|
-
throw new _GraphQLError.GraphQLError("Cannot extend non-enum type \"".concat(type.name, "\"."), [node]);
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
break;
|
|
779
|
-
|
|
780
|
-
case _kinds.Kind.UNION_TYPE_EXTENSION:
|
|
781
|
-
if (!(0, _definition.isUnionType)(type)) {
|
|
782
|
-
throw new _GraphQLError.GraphQLError("Cannot extend non-union type \"".concat(type.name, "\"."), [node]);
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
break;
|
|
786
|
-
|
|
787
|
-
case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION:
|
|
788
|
-
if (!(0, _definition.isInputObjectType)(type)) {
|
|
789
|
-
throw new _GraphQLError.GraphQLError("Cannot extend non-input object type \"".concat(type.name, "\"."), [node]);
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
break;
|
|
415
|
+
function extendArg(arg) {
|
|
416
|
+
return _objectSpread({}, arg, {
|
|
417
|
+
type: replaceType(arg.type)
|
|
418
|
+
});
|
|
793
419
|
}
|
|
794
420
|
}
|