graphql 14.0.0 → 14.1.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/README.md +4 -4
- package/error/GraphQLError.js +1 -1
- package/error/GraphQLError.js.flow +3 -3
- package/error/GraphQLError.mjs +1 -1
- package/error/formatError.js +1 -1
- package/error/formatError.mjs +1 -1
- package/error/index.mjs +1 -1
- package/error/locatedError.js +1 -1
- package/error/locatedError.mjs +1 -1
- package/error/printError.js +1 -1
- package/error/printError.mjs +1 -1
- package/error/syntaxError.js +1 -1
- package/error/syntaxError.mjs +1 -1
- package/execution/execute.js +4 -4
- package/execution/execute.js.flow +4 -6
- package/execution/execute.mjs +5 -5
- package/execution/index.mjs +1 -1
- package/execution/values.js +4 -4
- package/execution/values.js.flow +3 -3
- package/execution/values.mjs +3 -3
- package/graphql.js +1 -1
- package/graphql.mjs +1 -1
- package/index.js +12 -0
- package/index.js.flow +4 -0
- package/index.mjs +4 -4
- package/jsutils/dedent.js +2 -2
- package/jsutils/dedent.js.flow +1 -1
- package/jsutils/dedent.mjs +2 -2
- package/jsutils/defineToJSON.js +17 -6
- package/jsutils/defineToJSON.js.flow +14 -5
- package/jsutils/defineToJSON.mjs +14 -6
- package/jsutils/defineToStringTag.js +5 -5
- package/jsutils/defineToStringTag.js.flow +3 -3
- package/jsutils/defineToStringTag.mjs +4 -4
- package/jsutils/inspect.js +46 -12
- package/jsutils/inspect.js.flow +42 -15
- package/jsutils/inspect.mjs +45 -5
- package/jsutils/instanceOf.js +1 -1
- package/jsutils/instanceOf.mjs +1 -1
- package/jsutils/invariant.js +1 -1
- package/jsutils/invariant.mjs +1 -1
- package/jsutils/isInvalid.js +1 -1
- package/jsutils/isInvalid.mjs +1 -1
- package/jsutils/isNullish.js +1 -1
- package/jsutils/isNullish.mjs +1 -1
- package/jsutils/isPromise.js +1 -1
- package/jsutils/isPromise.mjs +1 -1
- package/jsutils/keyMap.js +1 -1
- package/jsutils/keyMap.mjs +1 -1
- package/jsutils/keyValMap.js +1 -1
- package/jsutils/keyValMap.mjs +1 -1
- package/jsutils/mapValue.js +54 -0
- package/jsutils/mapValue.js.flow +27 -0
- package/jsutils/mapValue.mjs +44 -0
- package/jsutils/memoize3.js +1 -1
- package/jsutils/memoize3.mjs +1 -1
- package/jsutils/nodejsCustomInspectSymbol.js +18 -0
- package/jsutils/nodejsCustomInspectSymbol.js.flow +15 -0
- package/jsutils/nodejsCustomInspectSymbol.mjs +10 -0
- package/jsutils/orList.js +17 -4
- package/jsutils/orList.js.flow +13 -7
- package/jsutils/orList.mjs +14 -4
- package/jsutils/promiseForObject.js +1 -1
- package/jsutils/promiseForObject.mjs +1 -1
- package/jsutils/promiseReduce.js +1 -1
- package/jsutils/promiseReduce.mjs +1 -1
- package/jsutils/quotedOrList.js +1 -1
- package/jsutils/quotedOrList.mjs +1 -1
- package/jsutils/suggestionList.js +1 -1
- package/jsutils/suggestionList.mjs +1 -1
- package/language/blockStringValue.js +2 -2
- package/language/blockStringValue.js.flow +1 -1
- package/language/blockStringValue.mjs +2 -2
- package/language/directiveLocation.js +1 -1
- package/language/directiveLocation.mjs +1 -1
- package/language/index.mjs +1 -1
- package/language/kinds.js +1 -1
- package/language/kinds.mjs +1 -1
- package/language/lexer.js +29 -13
- package/language/lexer.js.flow +34 -20
- package/language/lexer.mjs +28 -13
- package/language/location.js +1 -1
- package/language/location.mjs +1 -1
- package/language/parser.js +31 -38
- package/language/parser.js.flow +32 -48
- package/language/parser.mjs +30 -38
- package/language/predicates.js +1 -1
- package/language/predicates.mjs +1 -1
- package/language/printer.js +13 -7
- package/language/printer.js.flow +19 -9
- package/language/printer.mjs +13 -7
- package/language/source.js +8 -7
- package/language/source.mjs +1 -9
- package/language/visitor.js +11 -20
- package/language/visitor.js.flow +4 -5
- package/language/visitor.mjs +8 -20
- package/package.json +10 -3
- package/polyfills/find.js +31 -0
- package/polyfills/find.js.flow +29 -0
- package/polyfills/find.mjs +23 -0
- package/{jsutils → polyfills}/isFinite.js +1 -1
- package/{jsutils → polyfills}/isFinite.js.flow +0 -0
- package/{jsutils → polyfills}/isFinite.mjs +1 -1
- package/{jsutils → polyfills}/isInteger.js +1 -1
- package/{jsutils → polyfills}/isInteger.js.flow +0 -0
- package/{jsutils → polyfills}/isInteger.mjs +1 -1
- package/polyfills/objectEntries.js +26 -0
- package/polyfills/objectEntries.js.flow +19 -0
- package/polyfills/objectEntries.mjs +18 -0
- package/{jsutils → polyfills}/objectValues.js +1 -1
- package/{jsutils → polyfills}/objectValues.js.flow +1 -1
- package/{jsutils → polyfills}/objectValues.mjs +1 -1
- package/subscription/asyncIteratorReject.mjs +1 -1
- package/subscription/index.mjs +1 -1
- package/subscription/mapAsyncIterator.mjs +1 -1
- package/subscription/subscribe.js +1 -1
- package/subscription/subscribe.js.flow +1 -1
- package/subscription/subscribe.mjs +2 -2
- package/type/definition.js +31 -130
- package/type/definition.js.flow +35 -47
- package/type/definition.mjs +30 -131
- package/type/directives.js +25 -29
- package/type/directives.js.flow +24 -20
- package/type/directives.mjs +22 -30
- package/type/index.js +12 -0
- package/type/index.js.flow +4 -0
- package/type/index.mjs +5 -3
- package/type/introspection.js +3 -3
- package/type/introspection.js.flow +1 -1
- package/type/introspection.mjs +2 -2
- package/type/scalars.js +45 -34
- package/type/scalars.js.flow +40 -26
- package/type/scalars.mjs +44 -26
- package/type/schema.js +82 -87
- package/type/schema.js.flow +17 -9
- package/type/schema.mjs +79 -86
- package/type/validate.js +168 -175
- package/type/validate.js.flow +8 -49
- package/type/validate.mjs +159 -175
- package/utilities/TypeInfo.js +10 -23
- package/utilities/TypeInfo.js.flow +1 -1
- package/utilities/TypeInfo.mjs +2 -24
- package/utilities/assertValidName.js +1 -1
- package/utilities/assertValidName.mjs +1 -1
- package/utilities/astFromValue.js +2 -2
- package/utilities/astFromValue.js.flow +1 -1
- package/utilities/astFromValue.mjs +2 -2
- package/utilities/buildASTSchema.js +169 -152
- package/utilities/buildASTSchema.js.flow +117 -113
- package/utilities/buildASTSchema.mjs +160 -152
- package/utilities/buildClientSchema.js +24 -14
- package/utilities/buildClientSchema.js.flow +24 -14
- package/utilities/buildClientSchema.mjs +23 -14
- package/utilities/coerceValue.js +38 -19
- package/utilities/coerceValue.js.flow +41 -47
- package/utilities/coerceValue.mjs +38 -20
- package/utilities/concatAST.js +1 -1
- package/utilities/concatAST.mjs +1 -1
- package/utilities/extendSchema.js +228 -312
- package/utilities/extendSchema.js.flow +27 -152
- package/utilities/extendSchema.mjs +229 -312
- package/utilities/findBreakingChanges.js +7 -5
- package/utilities/findBreakingChanges.js.flow +3 -2
- package/utilities/findBreakingChanges.mjs +6 -5
- package/utilities/findDeprecatedUsages.js +1 -1
- package/utilities/findDeprecatedUsages.mjs +1 -1
- package/utilities/getOperationAST.js +1 -1
- package/utilities/getOperationAST.mjs +1 -1
- package/utilities/getOperationRootType.js +1 -1
- package/utilities/getOperationRootType.mjs +1 -1
- package/utilities/index.mjs +1 -1
- package/utilities/introspectionFromSchema.js +1 -1
- package/utilities/introspectionFromSchema.mjs +1 -1
- package/utilities/introspectionQuery.js +1 -1
- package/utilities/introspectionQuery.mjs +1 -1
- package/utilities/isValidJSValue.js +1 -1
- package/utilities/isValidJSValue.mjs +1 -1
- package/utilities/isValidLiteralValue.js +1 -1
- package/utilities/isValidLiteralValue.mjs +1 -1
- package/utilities/lexicographicSortSchema.js +2 -2
- package/utilities/lexicographicSortSchema.js.flow +1 -1
- package/utilities/lexicographicSortSchema.mjs +2 -2
- package/utilities/schemaPrinter.js +3 -3
- package/utilities/schemaPrinter.js.flow +1 -1
- package/utilities/schemaPrinter.mjs +2 -2
- package/utilities/separateOperations.js +1 -1
- package/utilities/separateOperations.mjs +1 -1
- package/utilities/typeComparators.js +1 -1
- package/utilities/typeComparators.mjs +1 -1
- package/utilities/typeFromAST.js +1 -1
- package/utilities/typeFromAST.mjs +1 -1
- package/utilities/valueFromAST.js +3 -3
- package/utilities/valueFromAST.js.flow +1 -1
- package/utilities/valueFromAST.mjs +2 -2
- package/utilities/valueFromASTUntyped.js +1 -1
- package/utilities/valueFromASTUntyped.mjs +1 -1
- package/validation/ValidationContext.js +57 -82
- package/validation/ValidationContext.js.flow +52 -49
- package/validation/ValidationContext.mjs +52 -77
- package/validation/index.js.flow +1 -0
- package/validation/index.mjs +1 -1
- package/validation/rules/ExecutableDefinitions.js +1 -1
- package/validation/rules/ExecutableDefinitions.js.flow +1 -1
- package/validation/rules/ExecutableDefinitions.mjs +1 -1
- package/validation/rules/FieldsOnCorrectType.js +1 -1
- package/validation/rules/FieldsOnCorrectType.mjs +1 -1
- package/validation/rules/FragmentsOnCompositeTypes.js +1 -1
- package/validation/rules/FragmentsOnCompositeTypes.mjs +1 -1
- package/validation/rules/KnownArgumentNames.mjs +1 -1
- package/validation/rules/KnownDirectives.js +1 -1
- package/validation/rules/KnownDirectives.mjs +1 -1
- package/validation/rules/KnownFragmentNames.js +1 -1
- package/validation/rules/KnownFragmentNames.mjs +1 -1
- package/validation/rules/KnownTypeNames.js +59 -21
- package/validation/rules/KnownTypeNames.js.flow +54 -20
- package/validation/rules/KnownTypeNames.mjs +56 -21
- package/validation/rules/LoneAnonymousOperation.js +1 -1
- package/validation/rules/LoneAnonymousOperation.mjs +1 -1
- package/validation/rules/LoneSchemaDefinition.js +1 -1
- package/validation/rules/LoneSchemaDefinition.mjs +1 -1
- package/validation/rules/NoFragmentCycles.js +1 -1
- package/validation/rules/NoFragmentCycles.js.flow +2 -2
- package/validation/rules/NoFragmentCycles.mjs +1 -1
- package/validation/rules/NoUndefinedVariables.js +1 -1
- package/validation/rules/NoUndefinedVariables.mjs +1 -1
- package/validation/rules/NoUnusedFragments.js +1 -1
- package/validation/rules/NoUnusedFragments.js.flow +2 -2
- package/validation/rules/NoUnusedFragments.mjs +1 -1
- package/validation/rules/NoUnusedVariables.js +1 -1
- package/validation/rules/NoUnusedVariables.mjs +1 -1
- package/validation/rules/OverlappingFieldsCanBeMerged.js +57 -33
- package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +5 -6
- package/validation/rules/OverlappingFieldsCanBeMerged.mjs +48 -33
- package/validation/rules/PossibleFragmentSpreads.js +1 -1
- package/validation/rules/PossibleFragmentSpreads.mjs +1 -1
- package/validation/rules/PossibleTypeExtensions.js +158 -0
- package/validation/rules/PossibleTypeExtensions.js.flow +160 -0
- package/validation/rules/PossibleTypeExtensions.mjs +146 -0
- package/validation/rules/ProvidedRequiredArguments.mjs +1 -1
- package/validation/rules/ScalarLeafs.js +1 -1
- package/validation/rules/ScalarLeafs.mjs +1 -1
- package/validation/rules/SingleFieldSubscriptions.js +1 -1
- package/validation/rules/SingleFieldSubscriptions.mjs +1 -1
- package/validation/rules/UniqueArgumentNames.js +1 -1
- package/validation/rules/UniqueArgumentNames.mjs +1 -1
- package/validation/rules/UniqueDirectiveNames.js +55 -0
- package/validation/rules/UniqueDirectiveNames.js.flow +64 -0
- package/validation/rules/UniqueDirectiveNames.mjs +43 -0
- package/validation/rules/UniqueDirectivesPerLocation.js +1 -1
- package/validation/rules/UniqueDirectivesPerLocation.mjs +1 -1
- package/validation/rules/UniqueEnumValueNames.js +94 -0
- package/validation/rules/UniqueEnumValueNames.js.flow +87 -0
- package/validation/rules/UniqueEnumValueNames.mjs +81 -0
- package/validation/rules/UniqueFieldDefinitionNames.js +105 -0
- package/validation/rules/UniqueFieldDefinitionNames.js.flow +101 -0
- package/validation/rules/UniqueFieldDefinitionNames.mjs +92 -0
- package/validation/rules/UniqueFragmentNames.js +1 -1
- package/validation/rules/UniqueFragmentNames.mjs +1 -1
- package/validation/rules/UniqueInputFieldNames.js +1 -1
- package/validation/rules/UniqueInputFieldNames.mjs +1 -1
- package/validation/rules/UniqueOperationNames.js +1 -1
- package/validation/rules/UniqueOperationNames.mjs +1 -1
- package/validation/rules/UniqueOperationTypes.js +85 -0
- package/validation/rules/UniqueOperationTypes.js.flow +76 -0
- package/validation/rules/UniqueOperationTypes.mjs +73 -0
- package/validation/rules/UniqueTypeNames.js +62 -0
- package/validation/rules/UniqueTypeNames.js.flow +67 -0
- package/validation/rules/UniqueTypeNames.mjs +50 -0
- package/validation/rules/UniqueVariableNames.js +1 -1
- package/validation/rules/UniqueVariableNames.mjs +1 -1
- package/validation/rules/ValuesOfCorrectType.js +29 -13
- package/validation/rules/ValuesOfCorrectType.js.flow +4 -5
- package/validation/rules/ValuesOfCorrectType.mjs +28 -13
- package/validation/rules/VariablesAreInputTypes.js +1 -1
- package/validation/rules/VariablesAreInputTypes.mjs +1 -1
- package/validation/rules/VariablesInAllowedPosition.js +4 -4
- package/validation/rules/VariablesInAllowedPosition.mjs +4 -4
- package/validation/specifiedRules.js +14 -2
- package/validation/specifiedRules.js.flow +13 -0
- package/validation/specifiedRules.mjs +8 -2
- package/validation/validate.js +1 -1
- package/validation/validate.mjs +1 -1
- package/jsutils/find.js +0 -22
- package/jsutils/find.js.flow +0 -19
- package/jsutils/find.mjs +0 -15
|
@@ -7,14 +7,14 @@ exports.astFromValue = astFromValue;
|
|
|
7
7
|
|
|
8
8
|
var _iterall = require("iterall");
|
|
9
9
|
|
|
10
|
+
var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
|
|
11
|
+
|
|
10
12
|
var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
|
|
11
13
|
|
|
12
14
|
var _isNullish = _interopRequireDefault(require("../jsutils/isNullish"));
|
|
13
15
|
|
|
14
16
|
var _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
|
|
15
17
|
|
|
16
|
-
var _objectValues = _interopRequireDefault(require("../jsutils/objectValues"));
|
|
17
|
-
|
|
18
18
|
var _kinds = require("../language/kinds");
|
|
19
19
|
|
|
20
20
|
var _definition = require("../type/definition");
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
import { forEach, isCollection } from 'iterall';
|
|
11
11
|
|
|
12
|
+
import objectValues from '../polyfills/objectValues';
|
|
12
13
|
import inspect from '../jsutils/inspect';
|
|
13
14
|
import isNullish from '../jsutils/isNullish';
|
|
14
15
|
import isInvalid from '../jsutils/isInvalid';
|
|
15
|
-
import objectValues from '../jsutils/objectValues';
|
|
16
16
|
import type { ValueNode } from '../language/ast';
|
|
17
17
|
import { Kind } from '../language/kinds';
|
|
18
18
|
import type { GraphQLInputType } from '../type/definition';
|
|
@@ -6,13 +6,13 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
*
|
|
10
10
|
*/
|
|
11
11
|
import { forEach, isCollection } from 'iterall';
|
|
12
|
+
import objectValues from '../polyfills/objectValues';
|
|
12
13
|
import inspect from '../jsutils/inspect';
|
|
13
14
|
import isNullish from '../jsutils/isNullish';
|
|
14
15
|
import isInvalid from '../jsutils/isInvalid';
|
|
15
|
-
import objectValues from '../jsutils/objectValues';
|
|
16
16
|
import { Kind } from '../language/kinds';
|
|
17
17
|
import { isScalarType, isEnumType, isInputObjectType, isListType, isNonNullType } from '../type/definition';
|
|
18
18
|
import { GraphQLID } from '../type/scalars';
|
|
@@ -8,6 +8,8 @@ exports.getDescription = getDescription;
|
|
|
8
8
|
exports.buildSchema = buildSchema;
|
|
9
9
|
exports.ASTDefinitionBuilder = void 0;
|
|
10
10
|
|
|
11
|
+
var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
|
|
12
|
+
|
|
11
13
|
var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
|
|
12
14
|
|
|
13
15
|
var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
|
|
@@ -42,7 +44,14 @@ var _schema = require("../type/schema");
|
|
|
42
44
|
|
|
43
45
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
49
|
+
*
|
|
50
|
+
* This source code is licensed under the MIT license found in the
|
|
51
|
+
* LICENSE file in the root directory of this source tree.
|
|
52
|
+
*
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
46
55
|
|
|
47
56
|
/**
|
|
48
57
|
* This takes the ast of a schema document produced by the parse function in
|
|
@@ -68,26 +77,36 @@ function buildASTSchema(documentAST, options) {
|
|
|
68
77
|
}
|
|
69
78
|
|
|
70
79
|
var schemaDef;
|
|
71
|
-
var typeDefs = [];
|
|
72
80
|
var nodeMap = Object.create(null);
|
|
73
81
|
var directiveDefs = [];
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
var _iteratorNormalCompletion = true;
|
|
83
|
+
var _didIteratorError = false;
|
|
84
|
+
var _iteratorError = undefined;
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
for (var _iterator = documentAST.definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
88
|
+
var def = _step.value;
|
|
89
|
+
|
|
90
|
+
if (def.kind === _kinds.Kind.SCHEMA_DEFINITION) {
|
|
91
|
+
schemaDef = def;
|
|
92
|
+
} else if ((0, _predicates.isTypeDefinitionNode)(def)) {
|
|
93
|
+
nodeMap[def.name.value] = def;
|
|
94
|
+
} else if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
|
|
95
|
+
directiveDefs.push(def);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} catch (err) {
|
|
99
|
+
_didIteratorError = true;
|
|
100
|
+
_iteratorError = err;
|
|
101
|
+
} finally {
|
|
102
|
+
try {
|
|
103
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
104
|
+
_iterator.return();
|
|
105
|
+
}
|
|
106
|
+
} finally {
|
|
107
|
+
if (_didIteratorError) {
|
|
108
|
+
throw _iteratorError;
|
|
85
109
|
}
|
|
86
|
-
|
|
87
|
-
typeDefs.push(def);
|
|
88
|
-
nodeMap[typeName] = def;
|
|
89
|
-
} else if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
|
|
90
|
-
directiveDefs.push(def);
|
|
91
110
|
}
|
|
92
111
|
}
|
|
93
112
|
|
|
@@ -96,8 +115,8 @@ function buildASTSchema(documentAST, options) {
|
|
|
96
115
|
mutation: nodeMap.Mutation,
|
|
97
116
|
subscription: nodeMap.Subscription
|
|
98
117
|
};
|
|
99
|
-
var definitionBuilder = new ASTDefinitionBuilder(nodeMap, options, function (
|
|
100
|
-
throw new Error("Type \"".concat(
|
|
118
|
+
var definitionBuilder = new ASTDefinitionBuilder(nodeMap, options, function (typeName) {
|
|
119
|
+
throw new Error("Type \"".concat(typeName, "\" not found in document."));
|
|
101
120
|
});
|
|
102
121
|
var directives = directiveDefs.map(function (def) {
|
|
103
122
|
return definitionBuilder.buildDirective(def);
|
|
@@ -128,7 +147,7 @@ function buildASTSchema(documentAST, options) {
|
|
|
128
147
|
query: operationTypes.query ? definitionBuilder.buildType(operationTypes.query) : null,
|
|
129
148
|
mutation: operationTypes.mutation ? definitionBuilder.buildType(operationTypes.mutation) : null,
|
|
130
149
|
subscription: operationTypes.subscription ? definitionBuilder.buildType(operationTypes.subscription) : null,
|
|
131
|
-
types:
|
|
150
|
+
types: (0, _objectValues.default)(nodeMap).map(function (node) {
|
|
132
151
|
return definitionBuilder.buildType(node);
|
|
133
152
|
}),
|
|
134
153
|
directives: directives,
|
|
@@ -139,37 +158,26 @@ function buildASTSchema(documentAST, options) {
|
|
|
139
158
|
|
|
140
159
|
function getOperationTypes(schema) {
|
|
141
160
|
var opTypes = {};
|
|
142
|
-
var
|
|
143
|
-
var
|
|
144
|
-
var
|
|
161
|
+
var _iteratorNormalCompletion2 = true;
|
|
162
|
+
var _didIteratorError2 = false;
|
|
163
|
+
var _iteratorError2 = undefined;
|
|
145
164
|
|
|
146
165
|
try {
|
|
147
|
-
for (var
|
|
148
|
-
var operationType =
|
|
149
|
-
|
|
150
|
-
var operation = operationType.operation;
|
|
151
|
-
|
|
152
|
-
if (opTypes[operation]) {
|
|
153
|
-
throw new Error("Must provide only one ".concat(operation, " type in schema."));
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (!nodeMap[_typeName]) {
|
|
157
|
-
throw new Error("Specified ".concat(operation, " type \"").concat(_typeName, "\" not found in document."));
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
opTypes[operation] = operationType.type;
|
|
166
|
+
for (var _iterator2 = schema.operationTypes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
167
|
+
var operationType = _step2.value;
|
|
168
|
+
opTypes[operationType.operation] = operationType.type;
|
|
161
169
|
}
|
|
162
170
|
} catch (err) {
|
|
163
|
-
|
|
164
|
-
|
|
171
|
+
_didIteratorError2 = true;
|
|
172
|
+
_iteratorError2 = err;
|
|
165
173
|
} finally {
|
|
166
174
|
try {
|
|
167
|
-
if (!
|
|
168
|
-
|
|
175
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
176
|
+
_iterator2.return();
|
|
169
177
|
}
|
|
170
178
|
} finally {
|
|
171
|
-
if (
|
|
172
|
-
throw
|
|
179
|
+
if (_didIteratorError2) {
|
|
180
|
+
throw _iteratorError2;
|
|
173
181
|
}
|
|
174
182
|
}
|
|
175
183
|
}
|
|
@@ -182,14 +190,6 @@ var ASTDefinitionBuilder =
|
|
|
182
190
|
/*#__PURE__*/
|
|
183
191
|
function () {
|
|
184
192
|
function ASTDefinitionBuilder(typeDefinitionsMap, options, resolveType) {
|
|
185
|
-
_defineProperty(this, "_typeDefinitionsMap", void 0);
|
|
186
|
-
|
|
187
|
-
_defineProperty(this, "_options", void 0);
|
|
188
|
-
|
|
189
|
-
_defineProperty(this, "_resolveType", void 0);
|
|
190
|
-
|
|
191
|
-
_defineProperty(this, "_cache", void 0);
|
|
192
|
-
|
|
193
193
|
this._typeDefinitionsMap = typeDefinitionsMap;
|
|
194
194
|
this._options = options;
|
|
195
195
|
this._resolveType = resolveType; // Initialize to the GraphQL built in scalars and introspection types.
|
|
@@ -207,7 +207,7 @@ function () {
|
|
|
207
207
|
if (!this._cache[typeName]) {
|
|
208
208
|
if (node.kind === _kinds.Kind.NAMED_TYPE) {
|
|
209
209
|
var defNode = this._typeDefinitionsMap[typeName];
|
|
210
|
-
this._cache[typeName] = defNode ? this._makeSchemaDef(defNode) : this._resolveType(node);
|
|
210
|
+
this._cache[typeName] = defNode ? this._makeSchemaDef(defNode) : this._resolveType(node.name.value);
|
|
211
211
|
} else {
|
|
212
212
|
this._cache[typeName] = this._makeSchemaDef(node);
|
|
213
213
|
}
|
|
@@ -229,38 +229,60 @@ function () {
|
|
|
229
229
|
return this.buildType(typeNode);
|
|
230
230
|
};
|
|
231
231
|
|
|
232
|
-
_proto.buildDirective = function buildDirective(
|
|
232
|
+
_proto.buildDirective = function buildDirective(directive) {
|
|
233
|
+
var _this = this;
|
|
234
|
+
|
|
235
|
+
var locations = directive.locations.map(function (_ref) {
|
|
236
|
+
var value = _ref.value;
|
|
237
|
+
return value;
|
|
238
|
+
});
|
|
233
239
|
return new _directives.GraphQLDirective({
|
|
234
|
-
name:
|
|
235
|
-
description: getDescription(
|
|
236
|
-
locations:
|
|
237
|
-
|
|
240
|
+
name: directive.name.value,
|
|
241
|
+
description: getDescription(directive, this._options),
|
|
242
|
+
locations: locations,
|
|
243
|
+
args: keyByNameNode(directive.arguments || [], function (arg) {
|
|
244
|
+
return _this.buildArg(arg);
|
|
238
245
|
}),
|
|
239
|
-
|
|
240
|
-
astNode: directiveNode
|
|
246
|
+
astNode: directive
|
|
241
247
|
});
|
|
242
248
|
};
|
|
243
249
|
|
|
244
250
|
_proto.buildField = function buildField(field) {
|
|
251
|
+
var _this2 = this;
|
|
252
|
+
|
|
245
253
|
return {
|
|
246
254
|
// Note: While this could make assertions to get the correctly typed
|
|
247
255
|
// value, that would throw immediately while type system validation
|
|
248
256
|
// with validateSchema() will produce more actionable results.
|
|
249
257
|
type: this._buildWrappedType(field.type),
|
|
250
258
|
description: getDescription(field, this._options),
|
|
251
|
-
args: field.arguments
|
|
259
|
+
args: keyByNameNode(field.arguments || [], function (arg) {
|
|
260
|
+
return _this2.buildArg(arg);
|
|
261
|
+
}),
|
|
252
262
|
deprecationReason: getDeprecationReason(field),
|
|
253
263
|
astNode: field
|
|
254
264
|
};
|
|
255
265
|
};
|
|
256
266
|
|
|
267
|
+
_proto.buildArg = function buildArg(value) {
|
|
268
|
+
// Note: While this could make assertions to get the correctly typed
|
|
269
|
+
// value, that would throw immediately while type system validation
|
|
270
|
+
var type = this._buildWrappedType(value.type);
|
|
271
|
+
|
|
272
|
+
return {
|
|
273
|
+
type: type,
|
|
274
|
+
description: getDescription(value, this._options),
|
|
275
|
+
defaultValue: (0, _valueFromAST.valueFromAST)(value.defaultValue, type),
|
|
276
|
+
astNode: value
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
|
|
257
280
|
_proto.buildInputField = function buildInputField(value) {
|
|
258
281
|
// Note: While this could make assertions to get the correctly typed
|
|
259
282
|
// value, that would throw immediately while type system validation
|
|
260
283
|
var type = this._buildWrappedType(value.type);
|
|
261
284
|
|
|
262
285
|
return {
|
|
263
|
-
name: value.name.value,
|
|
264
286
|
type: type,
|
|
265
287
|
description: getDescription(value, this._options),
|
|
266
288
|
defaultValue: (0, _valueFromAST.valueFromAST)(value.defaultValue, type),
|
|
@@ -276,129 +298,114 @@ function () {
|
|
|
276
298
|
};
|
|
277
299
|
};
|
|
278
300
|
|
|
279
|
-
_proto._makeSchemaDef = function _makeSchemaDef(
|
|
280
|
-
switch (
|
|
301
|
+
_proto._makeSchemaDef = function _makeSchemaDef(astNode) {
|
|
302
|
+
switch (astNode.kind) {
|
|
281
303
|
case _kinds.Kind.OBJECT_TYPE_DEFINITION:
|
|
282
|
-
return this._makeTypeDef(
|
|
304
|
+
return this._makeTypeDef(astNode);
|
|
283
305
|
|
|
284
306
|
case _kinds.Kind.INTERFACE_TYPE_DEFINITION:
|
|
285
|
-
return this._makeInterfaceDef(
|
|
307
|
+
return this._makeInterfaceDef(astNode);
|
|
286
308
|
|
|
287
309
|
case _kinds.Kind.ENUM_TYPE_DEFINITION:
|
|
288
|
-
return this._makeEnumDef(
|
|
310
|
+
return this._makeEnumDef(astNode);
|
|
289
311
|
|
|
290
312
|
case _kinds.Kind.UNION_TYPE_DEFINITION:
|
|
291
|
-
return this._makeUnionDef(
|
|
313
|
+
return this._makeUnionDef(astNode);
|
|
292
314
|
|
|
293
315
|
case _kinds.Kind.SCALAR_TYPE_DEFINITION:
|
|
294
|
-
return this._makeScalarDef(
|
|
316
|
+
return this._makeScalarDef(astNode);
|
|
295
317
|
|
|
296
318
|
case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
297
|
-
return this._makeInputObjectDef(
|
|
319
|
+
return this._makeInputObjectDef(astNode);
|
|
298
320
|
|
|
299
321
|
default:
|
|
300
|
-
throw new Error("Type kind \"".concat(
|
|
322
|
+
throw new Error("Type kind \"".concat(astNode.kind, "\" not supported."));
|
|
301
323
|
}
|
|
302
324
|
};
|
|
303
325
|
|
|
304
|
-
_proto._makeTypeDef = function _makeTypeDef(
|
|
305
|
-
var _this = this;
|
|
306
|
-
|
|
307
|
-
var interfaces = def.interfaces;
|
|
308
|
-
return new _definition.GraphQLObjectType({
|
|
309
|
-
name: def.name.value,
|
|
310
|
-
description: getDescription(def, this._options),
|
|
311
|
-
fields: function fields() {
|
|
312
|
-
return _this._makeFieldDefMap(def);
|
|
313
|
-
},
|
|
314
|
-
// Note: While this could make early assertions to get the correctly
|
|
315
|
-
// typed values, that would throw immediately while type system
|
|
316
|
-
// validation with validateSchema() will produce more actionable results.
|
|
317
|
-
interfaces: interfaces ? function () {
|
|
318
|
-
return interfaces.map(function (ref) {
|
|
319
|
-
return _this.buildType(ref);
|
|
320
|
-
});
|
|
321
|
-
} : [],
|
|
322
|
-
astNode: def
|
|
323
|
-
});
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
_proto._makeFieldDefMap = function _makeFieldDefMap(def) {
|
|
327
|
-
var _this2 = this;
|
|
328
|
-
|
|
329
|
-
return def.fields ? (0, _keyValMap.default)(def.fields, function (field) {
|
|
330
|
-
return field.name.value;
|
|
331
|
-
}, function (field) {
|
|
332
|
-
return _this2.buildField(field);
|
|
333
|
-
}) : {};
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
_proto._makeInputValues = function _makeInputValues(values) {
|
|
326
|
+
_proto._makeTypeDef = function _makeTypeDef(astNode) {
|
|
337
327
|
var _this3 = this;
|
|
338
328
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
329
|
+
var interfaceNodes = astNode.interfaces;
|
|
330
|
+
var fieldNodes = astNode.fields; // Note: While this could make assertions to get the correctly typed
|
|
331
|
+
// values below, that would throw immediately while type system
|
|
332
|
+
// validation with validateSchema() will produce more actionable results.
|
|
333
|
+
|
|
334
|
+
var interfaces = interfaceNodes && interfaceNodes.length > 0 ? function () {
|
|
335
|
+
return interfaceNodes.map(function (ref) {
|
|
336
|
+
return _this3.buildType(ref);
|
|
337
|
+
});
|
|
338
|
+
} : [];
|
|
339
|
+
var fields = fieldNodes && fieldNodes.length > 0 ? function () {
|
|
340
|
+
return keyByNameNode(fieldNodes, function (field) {
|
|
341
|
+
return _this3.buildField(field);
|
|
342
|
+
});
|
|
343
|
+
} : Object.create(null);
|
|
344
|
+
return new _definition.GraphQLObjectType({
|
|
345
|
+
name: astNode.name.value,
|
|
346
|
+
description: getDescription(astNode, this._options),
|
|
347
|
+
interfaces: interfaces,
|
|
348
|
+
fields: fields,
|
|
349
|
+
astNode: astNode
|
|
343
350
|
});
|
|
344
351
|
};
|
|
345
352
|
|
|
346
|
-
_proto._makeInterfaceDef = function _makeInterfaceDef(
|
|
353
|
+
_proto._makeInterfaceDef = function _makeInterfaceDef(astNode) {
|
|
347
354
|
var _this4 = this;
|
|
348
355
|
|
|
356
|
+
var fieldNodes = astNode.fields;
|
|
357
|
+
var fields = fieldNodes && fieldNodes.length > 0 ? function () {
|
|
358
|
+
return keyByNameNode(fieldNodes, function (field) {
|
|
359
|
+
return _this4.buildField(field);
|
|
360
|
+
});
|
|
361
|
+
} : Object.create(null);
|
|
349
362
|
return new _definition.GraphQLInterfaceType({
|
|
350
|
-
name:
|
|
351
|
-
description: getDescription(
|
|
352
|
-
fields:
|
|
353
|
-
|
|
354
|
-
},
|
|
355
|
-
astNode: def
|
|
356
|
-
});
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
_proto._makeEnumDef = function _makeEnumDef(def) {
|
|
360
|
-
return new _definition.GraphQLEnumType({
|
|
361
|
-
name: def.name.value,
|
|
362
|
-
description: getDescription(def, this._options),
|
|
363
|
-
values: this._makeValueDefMap(def),
|
|
364
|
-
astNode: def
|
|
363
|
+
name: astNode.name.value,
|
|
364
|
+
description: getDescription(astNode, this._options),
|
|
365
|
+
fields: fields,
|
|
366
|
+
astNode: astNode
|
|
365
367
|
});
|
|
366
368
|
};
|
|
367
369
|
|
|
368
|
-
_proto.
|
|
370
|
+
_proto._makeEnumDef = function _makeEnumDef(astNode) {
|
|
369
371
|
var _this5 = this;
|
|
370
372
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
373
|
+
var valueNodes = astNode.values || [];
|
|
374
|
+
return new _definition.GraphQLEnumType({
|
|
375
|
+
name: astNode.name.value,
|
|
376
|
+
description: getDescription(astNode, this._options),
|
|
377
|
+
values: keyByNameNode(valueNodes, function (value) {
|
|
378
|
+
return _this5.buildEnumValue(value);
|
|
379
|
+
}),
|
|
380
|
+
astNode: astNode
|
|
381
|
+
});
|
|
376
382
|
};
|
|
377
383
|
|
|
378
|
-
_proto._makeUnionDef = function _makeUnionDef(
|
|
384
|
+
_proto._makeUnionDef = function _makeUnionDef(astNode) {
|
|
379
385
|
var _this6 = this;
|
|
380
386
|
|
|
381
|
-
var
|
|
387
|
+
var typeNodes = astNode.types; // Note: While this could make assertions to get the correctly typed
|
|
388
|
+
// values below, that would throw immediately while type system
|
|
389
|
+
// validation with validateSchema() will produce more actionable results.
|
|
390
|
+
|
|
391
|
+
var types = typeNodes && typeNodes.length > 0 ? function () {
|
|
392
|
+
return typeNodes.map(function (ref) {
|
|
393
|
+
return _this6.buildType(ref);
|
|
394
|
+
});
|
|
395
|
+
} : [];
|
|
382
396
|
return new _definition.GraphQLUnionType({
|
|
383
|
-
name:
|
|
384
|
-
description: getDescription(
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
// validation with validateSchema() will produce more actionable results.
|
|
388
|
-
types: types ? function () {
|
|
389
|
-
return types.map(function (ref) {
|
|
390
|
-
return _this6.buildType(ref);
|
|
391
|
-
});
|
|
392
|
-
} : [],
|
|
393
|
-
astNode: def
|
|
397
|
+
name: astNode.name.value,
|
|
398
|
+
description: getDescription(astNode, this._options),
|
|
399
|
+
types: types,
|
|
400
|
+
astNode: astNode
|
|
394
401
|
});
|
|
395
402
|
};
|
|
396
403
|
|
|
397
|
-
_proto._makeScalarDef = function _makeScalarDef(
|
|
404
|
+
_proto._makeScalarDef = function _makeScalarDef(astNode) {
|
|
398
405
|
return new _definition.GraphQLScalarType({
|
|
399
|
-
name:
|
|
400
|
-
description: getDescription(
|
|
401
|
-
astNode:
|
|
406
|
+
name: astNode.name.value,
|
|
407
|
+
description: getDescription(astNode, this._options),
|
|
408
|
+
astNode: astNode,
|
|
402
409
|
serialize: function serialize(value) {
|
|
403
410
|
return value;
|
|
404
411
|
}
|
|
@@ -408,26 +415,36 @@ function () {
|
|
|
408
415
|
_proto._makeInputObjectDef = function _makeInputObjectDef(def) {
|
|
409
416
|
var _this7 = this;
|
|
410
417
|
|
|
418
|
+
var fields = def.fields;
|
|
411
419
|
return new _definition.GraphQLInputObjectType({
|
|
412
420
|
name: def.name.value,
|
|
413
421
|
description: getDescription(def, this._options),
|
|
414
|
-
fields: function
|
|
415
|
-
return
|
|
416
|
-
|
|
422
|
+
fields: fields ? function () {
|
|
423
|
+
return keyByNameNode(fields, function (field) {
|
|
424
|
+
return _this7.buildInputField(field);
|
|
425
|
+
});
|
|
426
|
+
} : Object.create(null),
|
|
417
427
|
astNode: def
|
|
418
428
|
});
|
|
419
429
|
};
|
|
420
430
|
|
|
421
431
|
return ASTDefinitionBuilder;
|
|
422
432
|
}();
|
|
433
|
+
|
|
434
|
+
exports.ASTDefinitionBuilder = ASTDefinitionBuilder;
|
|
435
|
+
|
|
436
|
+
function keyByNameNode(list, valFn) {
|
|
437
|
+
return (0, _keyValMap.default)(list, function (_ref2) {
|
|
438
|
+
var name = _ref2.name;
|
|
439
|
+
return name.value;
|
|
440
|
+
}, valFn);
|
|
441
|
+
}
|
|
423
442
|
/**
|
|
424
443
|
* Given a field or enum value node, returns the string value for the
|
|
425
444
|
* deprecation reason.
|
|
426
445
|
*/
|
|
427
446
|
|
|
428
447
|
|
|
429
|
-
exports.ASTDefinitionBuilder = ASTDefinitionBuilder;
|
|
430
|
-
|
|
431
448
|
function getDeprecationReason(node) {
|
|
432
449
|
var deprecated = (0, _values.getDirectiveValues)(_directives.GraphQLDeprecatedDirective, node);
|
|
433
450
|
return deprecated && deprecated.reason;
|