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