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
|
@@ -10,6 +10,8 @@ exports.ASTDefinitionBuilder = void 0;
|
|
|
10
10
|
|
|
11
11
|
var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
|
|
12
12
|
|
|
13
|
+
var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
|
|
14
|
+
|
|
13
15
|
var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
|
|
14
16
|
|
|
15
17
|
var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
|
|
@@ -20,7 +22,7 @@ var _valueFromAST = require("./valueFromAST");
|
|
|
20
22
|
|
|
21
23
|
var _validate = require("../validation/validate");
|
|
22
24
|
|
|
23
|
-
var
|
|
25
|
+
var _blockString = require("../language/blockString");
|
|
24
26
|
|
|
25
27
|
var _lexer = require("../language/lexer");
|
|
26
28
|
|
|
@@ -45,7 +47,7 @@ var _schema = require("../type/schema");
|
|
|
45
47
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
|
-
* Copyright (c)
|
|
50
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
49
51
|
*
|
|
50
52
|
* This source code is licensed under the MIT license found in the
|
|
51
53
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -77,7 +79,7 @@ function buildASTSchema(documentAST, options) {
|
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
var schemaDef;
|
|
80
|
-
var
|
|
82
|
+
var typeDefs = [];
|
|
81
83
|
var directiveDefs = [];
|
|
82
84
|
var _iteratorNormalCompletion = true;
|
|
83
85
|
var _didIteratorError = false;
|
|
@@ -90,7 +92,7 @@ function buildASTSchema(documentAST, options) {
|
|
|
90
92
|
if (def.kind === _kinds.Kind.SCHEMA_DEFINITION) {
|
|
91
93
|
schemaDef = def;
|
|
92
94
|
} else if ((0, _predicates.isTypeDefinitionNode)(def)) {
|
|
93
|
-
|
|
95
|
+
typeDefs.push(def);
|
|
94
96
|
} else if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
|
|
95
97
|
directiveDefs.push(def);
|
|
96
98
|
}
|
|
@@ -110,16 +112,21 @@ function buildASTSchema(documentAST, options) {
|
|
|
110
112
|
}
|
|
111
113
|
}
|
|
112
114
|
|
|
115
|
+
var astBuilder = new ASTDefinitionBuilder(options, function (typeName) {
|
|
116
|
+
var type = typeMap[typeName];
|
|
117
|
+
!type ? (0, _invariant.default)(0, "Type \"".concat(typeName, "\" not found in document.")) : void 0;
|
|
118
|
+
return type;
|
|
119
|
+
});
|
|
120
|
+
var typeMap = keyByNameNode(typeDefs, function (node) {
|
|
121
|
+
return astBuilder.buildType(node);
|
|
122
|
+
});
|
|
113
123
|
var operationTypes = schemaDef ? getOperationTypes(schemaDef) : {
|
|
114
|
-
query:
|
|
115
|
-
mutation:
|
|
116
|
-
subscription:
|
|
124
|
+
query: 'Query',
|
|
125
|
+
mutation: 'Mutation',
|
|
126
|
+
subscription: 'Subscription'
|
|
117
127
|
};
|
|
118
|
-
var definitionBuilder = new ASTDefinitionBuilder(nodeMap, options, function (typeName) {
|
|
119
|
-
throw new Error("Type \"".concat(typeName, "\" not found in document."));
|
|
120
|
-
});
|
|
121
128
|
var directives = directiveDefs.map(function (def) {
|
|
122
|
-
return
|
|
129
|
+
return astBuilder.buildDirective(def);
|
|
123
130
|
}); // If specified directives were not explicitly declared, add them.
|
|
124
131
|
|
|
125
132
|
if (!directives.some(function (directive) {
|
|
@@ -138,18 +145,16 @@ function buildASTSchema(documentAST, options) {
|
|
|
138
145
|
return directive.name === 'deprecated';
|
|
139
146
|
})) {
|
|
140
147
|
directives.push(_directives.GraphQLDeprecatedDirective);
|
|
141
|
-
}
|
|
142
|
-
// typed values below, that would throw immediately while type system
|
|
143
|
-
// validation with validateSchema() will produce more actionable results.
|
|
144
|
-
|
|
148
|
+
}
|
|
145
149
|
|
|
146
150
|
return new _schema.GraphQLSchema({
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
// Note: While this could make early assertions to get the correctly
|
|
152
|
+
// typed values below, that would throw immediately while type system
|
|
153
|
+
// validation with validateSchema() will produce more actionable results.
|
|
154
|
+
query: operationTypes.query ? typeMap[operationTypes.query] : null,
|
|
155
|
+
mutation: operationTypes.mutation ? typeMap[operationTypes.mutation] : null,
|
|
156
|
+
subscription: operationTypes.subscription ? typeMap[operationTypes.subscription] : null,
|
|
157
|
+
types: (0, _objectValues.default)(typeMap),
|
|
153
158
|
directives: directives,
|
|
154
159
|
astNode: schemaDef,
|
|
155
160
|
assumeValid: options && options.assumeValid,
|
|
@@ -165,7 +170,7 @@ function buildASTSchema(documentAST, options) {
|
|
|
165
170
|
try {
|
|
166
171
|
for (var _iterator2 = schema.operationTypes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
167
172
|
var operationType = _step2.value;
|
|
168
|
-
opTypes[operationType.operation] = operationType.type;
|
|
173
|
+
opTypes[operationType.operation] = operationType.type.name.value;
|
|
169
174
|
}
|
|
170
175
|
} catch (err) {
|
|
171
176
|
_didIteratorError2 = true;
|
|
@@ -186,47 +191,35 @@ function buildASTSchema(documentAST, options) {
|
|
|
186
191
|
}
|
|
187
192
|
}
|
|
188
193
|
|
|
194
|
+
var stdTypeMap = (0, _keyMap.default)(_scalars.specifiedScalarTypes.concat(_introspection.introspectionTypes), function (type) {
|
|
195
|
+
return type.name;
|
|
196
|
+
});
|
|
197
|
+
|
|
189
198
|
var ASTDefinitionBuilder =
|
|
190
199
|
/*#__PURE__*/
|
|
191
200
|
function () {
|
|
192
|
-
function ASTDefinitionBuilder(
|
|
193
|
-
this._typeDefinitionsMap = typeDefinitionsMap;
|
|
201
|
+
function ASTDefinitionBuilder(options, resolveType) {
|
|
194
202
|
this._options = options;
|
|
195
|
-
this._resolveType = resolveType;
|
|
196
|
-
|
|
197
|
-
this._cache = (0, _keyMap.default)(_scalars.specifiedScalarTypes.concat(_introspection.introspectionTypes), function (type) {
|
|
198
|
-
return type.name;
|
|
199
|
-
});
|
|
203
|
+
this._resolveType = resolveType;
|
|
200
204
|
}
|
|
201
205
|
|
|
202
206
|
var _proto = ASTDefinitionBuilder.prototype;
|
|
203
207
|
|
|
204
|
-
_proto.
|
|
205
|
-
var
|
|
206
|
-
|
|
207
|
-
if (!this._cache[typeName]) {
|
|
208
|
-
if (node.kind === _kinds.Kind.NAMED_TYPE) {
|
|
209
|
-
var defNode = this._typeDefinitionsMap[typeName];
|
|
210
|
-
this._cache[typeName] = defNode ? this._makeSchemaDef(defNode) : this._resolveType(node.name.value);
|
|
211
|
-
} else {
|
|
212
|
-
this._cache[typeName] = this._makeSchemaDef(node);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
return this._cache[typeName];
|
|
208
|
+
_proto.getNamedType = function getNamedType(node) {
|
|
209
|
+
var name = node.name.value;
|
|
210
|
+
return stdTypeMap[name] || this._resolveType(name);
|
|
217
211
|
};
|
|
218
212
|
|
|
219
|
-
_proto.
|
|
220
|
-
if (
|
|
221
|
-
return
|
|
213
|
+
_proto.getWrappedType = function getWrappedType(node) {
|
|
214
|
+
if (node.kind === _kinds.Kind.LIST_TYPE) {
|
|
215
|
+
return new _definition.GraphQLList(this.getWrappedType(node.type));
|
|
222
216
|
}
|
|
223
217
|
|
|
224
|
-
if (
|
|
225
|
-
return
|
|
226
|
-
this._buildWrappedType(typeNode.type));
|
|
218
|
+
if (node.kind === _kinds.Kind.NON_NULL_TYPE) {
|
|
219
|
+
return new _definition.GraphQLNonNull(this.getWrappedType(node.type));
|
|
227
220
|
}
|
|
228
221
|
|
|
229
|
-
return this.
|
|
222
|
+
return this.getNamedType(node);
|
|
230
223
|
};
|
|
231
224
|
|
|
232
225
|
_proto.buildDirective = function buildDirective(directive) {
|
|
@@ -254,7 +247,7 @@ function () {
|
|
|
254
247
|
// Note: While this could make assertions to get the correctly typed
|
|
255
248
|
// value, that would throw immediately while type system validation
|
|
256
249
|
// with validateSchema() will produce more actionable results.
|
|
257
|
-
type: this.
|
|
250
|
+
type: this.getWrappedType(field.type),
|
|
258
251
|
description: getDescription(field, this._options),
|
|
259
252
|
args: keyByNameNode(field.arguments || [], function (arg) {
|
|
260
253
|
return _this2.buildArg(arg);
|
|
@@ -267,8 +260,8 @@ function () {
|
|
|
267
260
|
_proto.buildArg = function buildArg(value) {
|
|
268
261
|
// Note: While this could make assertions to get the correctly typed
|
|
269
262
|
// value, that would throw immediately while type system validation
|
|
270
|
-
|
|
271
|
-
|
|
263
|
+
// with validateSchema() will produce more actionable results.
|
|
264
|
+
var type = this.getWrappedType(value.type);
|
|
272
265
|
return {
|
|
273
266
|
type: type,
|
|
274
267
|
description: getDescription(value, this._options),
|
|
@@ -280,8 +273,8 @@ function () {
|
|
|
280
273
|
_proto.buildInputField = function buildInputField(value) {
|
|
281
274
|
// Note: While this could make assertions to get the correctly typed
|
|
282
275
|
// value, that would throw immediately while type system validation
|
|
283
|
-
|
|
284
|
-
|
|
276
|
+
// with validateSchema() will produce more actionable results.
|
|
277
|
+
var type = this.getWrappedType(value.type);
|
|
285
278
|
return {
|
|
286
279
|
type: type,
|
|
287
280
|
description: getDescription(value, this._options),
|
|
@@ -298,7 +291,13 @@ function () {
|
|
|
298
291
|
};
|
|
299
292
|
};
|
|
300
293
|
|
|
301
|
-
_proto.
|
|
294
|
+
_proto.buildType = function buildType(astNode) {
|
|
295
|
+
var name = astNode.name.value;
|
|
296
|
+
|
|
297
|
+
if (stdTypeMap[name]) {
|
|
298
|
+
return stdTypeMap[name];
|
|
299
|
+
}
|
|
300
|
+
|
|
302
301
|
switch (astNode.kind) {
|
|
303
302
|
case _kinds.Kind.OBJECT_TYPE_DEFINITION:
|
|
304
303
|
return this._makeTypeDef(astNode);
|
|
@@ -317,10 +316,12 @@ function () {
|
|
|
317
316
|
|
|
318
317
|
case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
319
318
|
return this._makeInputObjectDef(astNode);
|
|
319
|
+
} // Not reachable. All possible type definition nodes have been considered.
|
|
320
320
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
321
|
+
/* istanbul ignore next */
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
throw new Error("Unexpected type definition node: \"".concat((0, _inspect.default)(astNode), "\"."));
|
|
324
325
|
};
|
|
325
326
|
|
|
326
327
|
_proto._makeTypeDef = function _makeTypeDef(astNode) {
|
|
@@ -333,7 +334,7 @@ function () {
|
|
|
333
334
|
|
|
334
335
|
var interfaces = interfaceNodes && interfaceNodes.length > 0 ? function () {
|
|
335
336
|
return interfaceNodes.map(function (ref) {
|
|
336
|
-
return _this3.
|
|
337
|
+
return _this3.getNamedType(ref);
|
|
337
338
|
});
|
|
338
339
|
} : [];
|
|
339
340
|
var fields = fieldNodes && fieldNodes.length > 0 ? function () {
|
|
@@ -390,7 +391,7 @@ function () {
|
|
|
390
391
|
|
|
391
392
|
var types = typeNodes && typeNodes.length > 0 ? function () {
|
|
392
393
|
return typeNodes.map(function (ref) {
|
|
393
|
-
return _this6.
|
|
394
|
+
return _this6.getNamedType(ref);
|
|
394
395
|
});
|
|
395
396
|
} : [];
|
|
396
397
|
return new _definition.GraphQLUnionType({
|
|
@@ -470,7 +471,7 @@ function getDescription(node, options) {
|
|
|
470
471
|
var rawValue = getLeadingCommentBlock(node);
|
|
471
472
|
|
|
472
473
|
if (rawValue !== undefined) {
|
|
473
|
-
return (0,
|
|
474
|
+
return (0, _blockString.dedentBlockStringValue)('\n' + rawValue);
|
|
474
475
|
}
|
|
475
476
|
}
|
|
476
477
|
}
|
|
@@ -501,4 +502,4 @@ function getLeadingCommentBlock(node) {
|
|
|
501
502
|
|
|
502
503
|
function buildSchema(source, options) {
|
|
503
504
|
return buildASTSchema((0, _parser.parse)(source, options), options);
|
|
504
|
-
}
|
|
505
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -8,54 +8,51 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import objectValues from '../polyfills/objectValues';
|
|
11
|
+
import inspect from '../jsutils/inspect';
|
|
11
12
|
import invariant from '../jsutils/invariant';
|
|
12
13
|
import keyMap from '../jsutils/keyMap';
|
|
13
14
|
import keyValMap from '../jsutils/keyValMap';
|
|
14
|
-
import type
|
|
15
|
+
import { type ObjMap } from '../jsutils/ObjMap';
|
|
15
16
|
import { valueFromAST } from './valueFromAST';
|
|
16
17
|
import { assertValidSDL } from '../validation/validate';
|
|
17
|
-
import
|
|
18
|
+
import { dedentBlockStringValue } from '../language/blockString';
|
|
18
19
|
import { TokenKind } from '../language/lexer';
|
|
19
|
-
import { parse } from '../language/parser';
|
|
20
|
-
import type
|
|
21
|
-
import type { Source } from '../language/source';
|
|
20
|
+
import { type ParseOptions, parse } from '../language/parser';
|
|
21
|
+
import { type Source } from '../language/source';
|
|
22
22
|
import { getDirectiveValues } from '../execution/values';
|
|
23
23
|
import { Kind } from '../language/kinds';
|
|
24
24
|
|
|
25
|
-
import
|
|
26
|
-
DocumentNode,
|
|
27
|
-
NameNode,
|
|
28
|
-
TypeNode,
|
|
29
|
-
NamedTypeNode,
|
|
30
|
-
SchemaDefinitionNode,
|
|
31
|
-
TypeDefinitionNode,
|
|
32
|
-
ScalarTypeDefinitionNode,
|
|
33
|
-
ObjectTypeDefinitionNode,
|
|
34
|
-
FieldDefinitionNode,
|
|
35
|
-
InputValueDefinitionNode,
|
|
36
|
-
InterfaceTypeDefinitionNode,
|
|
37
|
-
UnionTypeDefinitionNode,
|
|
38
|
-
EnumTypeDefinitionNode,
|
|
39
|
-
EnumValueDefinitionNode,
|
|
40
|
-
InputObjectTypeDefinitionNode,
|
|
41
|
-
DirectiveDefinitionNode,
|
|
42
|
-
StringValueNode,
|
|
43
|
-
Location,
|
|
25
|
+
import {
|
|
26
|
+
type DocumentNode,
|
|
27
|
+
type NameNode,
|
|
28
|
+
type TypeNode,
|
|
29
|
+
type NamedTypeNode,
|
|
30
|
+
type SchemaDefinitionNode,
|
|
31
|
+
type TypeDefinitionNode,
|
|
32
|
+
type ScalarTypeDefinitionNode,
|
|
33
|
+
type ObjectTypeDefinitionNode,
|
|
34
|
+
type FieldDefinitionNode,
|
|
35
|
+
type InputValueDefinitionNode,
|
|
36
|
+
type InterfaceTypeDefinitionNode,
|
|
37
|
+
type UnionTypeDefinitionNode,
|
|
38
|
+
type EnumTypeDefinitionNode,
|
|
39
|
+
type EnumValueDefinitionNode,
|
|
40
|
+
type InputObjectTypeDefinitionNode,
|
|
41
|
+
type DirectiveDefinitionNode,
|
|
42
|
+
type StringValueNode,
|
|
43
|
+
type Location,
|
|
44
44
|
} from '../language/ast';
|
|
45
45
|
import { isTypeDefinitionNode } from '../language/predicates';
|
|
46
46
|
|
|
47
|
-
import type
|
|
48
|
-
|
|
49
|
-
import type {
|
|
50
|
-
GraphQLType,
|
|
51
|
-
GraphQLNamedType,
|
|
52
|
-
GraphQLFieldConfig,
|
|
53
|
-
GraphQLArgumentConfig,
|
|
54
|
-
GraphQLEnumValueConfig,
|
|
55
|
-
GraphQLInputFieldConfig,
|
|
56
|
-
} from '../type/definition';
|
|
47
|
+
import { type DirectiveLocationEnum } from '../language/directiveLocation';
|
|
57
48
|
|
|
58
49
|
import {
|
|
50
|
+
type GraphQLType,
|
|
51
|
+
type GraphQLNamedType,
|
|
52
|
+
type GraphQLFieldConfig,
|
|
53
|
+
type GraphQLArgumentConfig,
|
|
54
|
+
type GraphQLEnumValueConfig,
|
|
55
|
+
type GraphQLInputFieldConfig,
|
|
59
56
|
GraphQLScalarType,
|
|
60
57
|
GraphQLObjectType,
|
|
61
58
|
GraphQLInterfaceType,
|
|
@@ -77,8 +74,10 @@ import { introspectionTypes } from '../type/introspection';
|
|
|
77
74
|
|
|
78
75
|
import { specifiedScalarTypes } from '../type/scalars';
|
|
79
76
|
|
|
80
|
-
import {
|
|
81
|
-
|
|
77
|
+
import {
|
|
78
|
+
type GraphQLSchemaValidationOptions,
|
|
79
|
+
GraphQLSchema,
|
|
80
|
+
} from '../type/schema';
|
|
82
81
|
|
|
83
82
|
export type BuildSchemaOptions = {
|
|
84
83
|
...GraphQLSchemaValidationOptions,
|
|
@@ -131,38 +130,36 @@ export function buildASTSchema(
|
|
|
131
130
|
}
|
|
132
131
|
|
|
133
132
|
let schemaDef: ?SchemaDefinitionNode;
|
|
134
|
-
const
|
|
133
|
+
const typeDefs: Array<TypeDefinitionNode> = [];
|
|
135
134
|
const directiveDefs: Array<DirectiveDefinitionNode> = [];
|
|
136
135
|
|
|
137
136
|
for (const def of documentAST.definitions) {
|
|
138
137
|
if (def.kind === Kind.SCHEMA_DEFINITION) {
|
|
139
138
|
schemaDef = def;
|
|
140
139
|
} else if (isTypeDefinitionNode(def)) {
|
|
141
|
-
|
|
140
|
+
typeDefs.push(def);
|
|
142
141
|
} else if (def.kind === Kind.DIRECTIVE_DEFINITION) {
|
|
143
142
|
directiveDefs.push(def);
|
|
144
143
|
}
|
|
145
144
|
}
|
|
146
145
|
|
|
146
|
+
const astBuilder = new ASTDefinitionBuilder(options, typeName => {
|
|
147
|
+
const type = typeMap[typeName];
|
|
148
|
+
invariant(type, `Type "${typeName}" not found in document.`);
|
|
149
|
+
return type;
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const typeMap = keyByNameNode(typeDefs, node => astBuilder.buildType(node));
|
|
153
|
+
|
|
147
154
|
const operationTypes = schemaDef
|
|
148
155
|
? getOperationTypes(schemaDef)
|
|
149
156
|
: {
|
|
150
|
-
query:
|
|
151
|
-
mutation:
|
|
152
|
-
subscription:
|
|
157
|
+
query: 'Query',
|
|
158
|
+
mutation: 'Mutation',
|
|
159
|
+
subscription: 'Subscription',
|
|
153
160
|
};
|
|
154
161
|
|
|
155
|
-
const
|
|
156
|
-
nodeMap,
|
|
157
|
-
options,
|
|
158
|
-
typeName => {
|
|
159
|
-
throw new Error(`Type "${typeName}" not found in document.`);
|
|
160
|
-
},
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
const directives = directiveDefs.map(def =>
|
|
164
|
-
definitionBuilder.buildDirective(def),
|
|
165
|
-
);
|
|
162
|
+
const directives = directiveDefs.map(def => astBuilder.buildDirective(def));
|
|
166
163
|
|
|
167
164
|
// If specified directives were not explicitly declared, add them.
|
|
168
165
|
if (!directives.some(directive => directive.name === 'skip')) {
|
|
@@ -177,20 +174,19 @@ export function buildASTSchema(
|
|
|
177
174
|
directives.push(GraphQLDeprecatedDirective);
|
|
178
175
|
}
|
|
179
176
|
|
|
180
|
-
// Note: While this could make early assertions to get the correctly
|
|
181
|
-
// typed values below, that would throw immediately while type system
|
|
182
|
-
// validation with validateSchema() will produce more actionable results.
|
|
183
177
|
return new GraphQLSchema({
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
178
|
+
// Note: While this could make early assertions to get the correctly
|
|
179
|
+
// typed values below, that would throw immediately while type system
|
|
180
|
+
// validation with validateSchema() will produce more actionable results.
|
|
181
|
+
query: operationTypes.query ? (typeMap[operationTypes.query]: any) : null,
|
|
187
182
|
mutation: operationTypes.mutation
|
|
188
|
-
? (
|
|
183
|
+
? (typeMap[operationTypes.mutation]: any)
|
|
189
184
|
: null,
|
|
190
185
|
subscription: operationTypes.subscription
|
|
191
|
-
? (
|
|
186
|
+
? (typeMap[operationTypes.subscription]: any)
|
|
192
187
|
: null,
|
|
193
|
-
|
|
188
|
+
|
|
189
|
+
types: objectValues(typeMap),
|
|
194
190
|
directives,
|
|
195
191
|
astNode: schemaDef,
|
|
196
192
|
assumeValid: options && options.assumeValid,
|
|
@@ -200,62 +196,41 @@ export function buildASTSchema(
|
|
|
200
196
|
function getOperationTypes(schema: SchemaDefinitionNode) {
|
|
201
197
|
const opTypes = {};
|
|
202
198
|
for (const operationType of schema.operationTypes) {
|
|
203
|
-
opTypes[operationType.operation] = operationType.type;
|
|
199
|
+
opTypes[operationType.operation] = operationType.type.name.value;
|
|
204
200
|
}
|
|
205
201
|
return opTypes;
|
|
206
202
|
}
|
|
207
203
|
}
|
|
208
204
|
|
|
209
|
-
type TypeDefinitionsMap = ObjMap<TypeDefinitionNode>;
|
|
210
205
|
type TypeResolver = (typeName: string) => GraphQLNamedType;
|
|
211
206
|
|
|
207
|
+
const stdTypeMap = keyMap(
|
|
208
|
+
specifiedScalarTypes.concat(introspectionTypes),
|
|
209
|
+
type => type.name,
|
|
210
|
+
);
|
|
211
|
+
|
|
212
212
|
export class ASTDefinitionBuilder {
|
|
213
|
-
_typeDefinitionsMap: TypeDefinitionsMap;
|
|
214
213
|
_options: ?BuildSchemaOptions;
|
|
215
214
|
_resolveType: TypeResolver;
|
|
216
|
-
_cache: ObjMap<GraphQLNamedType>;
|
|
217
215
|
|
|
218
|
-
constructor(
|
|
219
|
-
typeDefinitionsMap: TypeDefinitionsMap,
|
|
220
|
-
options: ?BuildSchemaOptions,
|
|
221
|
-
resolveType: TypeResolver,
|
|
222
|
-
) {
|
|
223
|
-
this._typeDefinitionsMap = typeDefinitionsMap;
|
|
216
|
+
constructor(options: ?BuildSchemaOptions, resolveType: TypeResolver) {
|
|
224
217
|
this._options = options;
|
|
225
218
|
this._resolveType = resolveType;
|
|
226
|
-
// Initialize to the GraphQL built in scalars and introspection types.
|
|
227
|
-
this._cache = keyMap(
|
|
228
|
-
specifiedScalarTypes.concat(introspectionTypes),
|
|
229
|
-
type => type.name,
|
|
230
|
-
);
|
|
231
219
|
}
|
|
232
220
|
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
if (node.kind === Kind.NAMED_TYPE) {
|
|
237
|
-
const defNode = this._typeDefinitionsMap[typeName];
|
|
238
|
-
this._cache[typeName] = defNode
|
|
239
|
-
? this._makeSchemaDef(defNode)
|
|
240
|
-
: this._resolveType(node.name.value);
|
|
241
|
-
} else {
|
|
242
|
-
this._cache[typeName] = this._makeSchemaDef(node);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
return this._cache[typeName];
|
|
221
|
+
getNamedType(node: NamedTypeNode): GraphQLNamedType {
|
|
222
|
+
const name = node.name.value;
|
|
223
|
+
return stdTypeMap[name] || this._resolveType(name);
|
|
246
224
|
}
|
|
247
225
|
|
|
248
|
-
|
|
249
|
-
if (
|
|
250
|
-
return GraphQLList(this.
|
|
226
|
+
getWrappedType(node: TypeNode): GraphQLType {
|
|
227
|
+
if (node.kind === Kind.LIST_TYPE) {
|
|
228
|
+
return new GraphQLList(this.getWrappedType(node.type));
|
|
251
229
|
}
|
|
252
|
-
if (
|
|
253
|
-
return GraphQLNonNull(
|
|
254
|
-
// Note: GraphQLNonNull constructor validates this type
|
|
255
|
-
(this._buildWrappedType(typeNode.type): any),
|
|
256
|
-
);
|
|
230
|
+
if (node.kind === Kind.NON_NULL_TYPE) {
|
|
231
|
+
return new GraphQLNonNull(this.getWrappedType(node.type));
|
|
257
232
|
}
|
|
258
|
-
return this.
|
|
233
|
+
return this.getNamedType(node);
|
|
259
234
|
}
|
|
260
235
|
|
|
261
236
|
buildDirective(directive: DirectiveDefinitionNode): GraphQLDirective {
|
|
@@ -277,7 +252,7 @@ export class ASTDefinitionBuilder {
|
|
|
277
252
|
// Note: While this could make assertions to get the correctly typed
|
|
278
253
|
// value, that would throw immediately while type system validation
|
|
279
254
|
// with validateSchema() will produce more actionable results.
|
|
280
|
-
type: (this.
|
|
255
|
+
type: (this.getWrappedType(field.type): any),
|
|
281
256
|
description: getDescription(field, this._options),
|
|
282
257
|
args: keyByNameNode(field.arguments || [], arg => this.buildArg(arg)),
|
|
283
258
|
deprecationReason: getDeprecationReason(field),
|
|
@@ -289,7 +264,7 @@ export class ASTDefinitionBuilder {
|
|
|
289
264
|
// Note: While this could make assertions to get the correctly typed
|
|
290
265
|
// value, that would throw immediately while type system validation
|
|
291
266
|
// with validateSchema() will produce more actionable results.
|
|
292
|
-
const type: any = this.
|
|
267
|
+
const type: any = this.getWrappedType(value.type);
|
|
293
268
|
return {
|
|
294
269
|
type,
|
|
295
270
|
description: getDescription(value, this._options),
|
|
@@ -302,7 +277,7 @@ export class ASTDefinitionBuilder {
|
|
|
302
277
|
// Note: While this could make assertions to get the correctly typed
|
|
303
278
|
// value, that would throw immediately while type system validation
|
|
304
279
|
// with validateSchema() will produce more actionable results.
|
|
305
|
-
const type: any = this.
|
|
280
|
+
const type: any = this.getWrappedType(value.type);
|
|
306
281
|
return {
|
|
307
282
|
type,
|
|
308
283
|
description: getDescription(value, this._options),
|
|
@@ -319,7 +294,12 @@ export class ASTDefinitionBuilder {
|
|
|
319
294
|
};
|
|
320
295
|
}
|
|
321
296
|
|
|
322
|
-
|
|
297
|
+
buildType(astNode: TypeDefinitionNode): GraphQLNamedType {
|
|
298
|
+
const name = astNode.name.value;
|
|
299
|
+
if (stdTypeMap[name]) {
|
|
300
|
+
return stdTypeMap[name];
|
|
301
|
+
}
|
|
302
|
+
|
|
323
303
|
switch (astNode.kind) {
|
|
324
304
|
case Kind.OBJECT_TYPE_DEFINITION:
|
|
325
305
|
return this._makeTypeDef(astNode);
|
|
@@ -333,9 +313,13 @@ export class ASTDefinitionBuilder {
|
|
|
333
313
|
return this._makeScalarDef(astNode);
|
|
334
314
|
case Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
335
315
|
return this._makeInputObjectDef(astNode);
|
|
336
|
-
default:
|
|
337
|
-
throw new Error(`Type kind "${astNode.kind}" not supported.`);
|
|
338
316
|
}
|
|
317
|
+
|
|
318
|
+
// Not reachable. All possible type definition nodes have been considered.
|
|
319
|
+
/* istanbul ignore next */
|
|
320
|
+
throw new Error(
|
|
321
|
+
`Unexpected type definition node: "${inspect((astNode: empty))}".`,
|
|
322
|
+
);
|
|
339
323
|
}
|
|
340
324
|
|
|
341
325
|
_makeTypeDef(astNode: ObjectTypeDefinitionNode) {
|
|
@@ -347,7 +331,7 @@ export class ASTDefinitionBuilder {
|
|
|
347
331
|
// validation with validateSchema() will produce more actionable results.
|
|
348
332
|
const interfaces =
|
|
349
333
|
interfaceNodes && interfaceNodes.length > 0
|
|
350
|
-
? () => interfaceNodes.map(ref => (this.
|
|
334
|
+
? () => interfaceNodes.map(ref => (this.getNamedType(ref): any))
|
|
351
335
|
: [];
|
|
352
336
|
|
|
353
337
|
const fields =
|
|
@@ -399,7 +383,7 @@ export class ASTDefinitionBuilder {
|
|
|
399
383
|
// validation with validateSchema() will produce more actionable results.
|
|
400
384
|
const types =
|
|
401
385
|
typeNodes && typeNodes.length > 0
|
|
402
|
-
? () => typeNodes.map(ref => (this.
|
|
386
|
+
? () => typeNodes.map(ref => (this.getNamedType(ref): any))
|
|
403
387
|
: [];
|
|
404
388
|
|
|
405
389
|
return new GraphQLUnionType({
|
|
@@ -471,7 +455,7 @@ export function getDescription(
|
|
|
471
455
|
if (options && options.commentDescriptions) {
|
|
472
456
|
const rawValue = getLeadingCommentBlock(node);
|
|
473
457
|
if (rawValue !== undefined) {
|
|
474
|
-
return
|
|
458
|
+
return dedentBlockStringValue('\n' + rawValue);
|
|
475
459
|
}
|
|
476
460
|
}
|
|
477
461
|
}
|