graphql 14.0.2 → 14.1.0
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.mjs +1 -1
- package/execution/index.mjs +1 -1
- package/execution/values.js +3 -3
- package/execution/values.js.flow +1 -1
- package/execution/values.mjs +2 -2
- package/graphql.js +1 -1
- package/graphql.mjs +1 -1
- package/index.js +12 -0
- package/index.js.flow +2 -0
- package/index.mjs +2 -2
- package/jsutils/dedent.js +1 -1
- package/jsutils/dedent.mjs +1 -1
- 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 +22 -11
- package/jsutils/inspect.js.flow +22 -2
- package/jsutils/inspect.mjs +21 -4
- 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 +1 -1
- package/language/blockStringValue.mjs +1 -1
- 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 +28 -12
- package/language/lexer.js.flow +33 -19
- package/language/lexer.mjs +27 -12
- 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 +6 -5
- package/language/visitor.js.flow +2 -4
- package/language/visitor.mjs +6 -5
- package/package.json +5 -2
- package/polyfills/find.js +31 -0
- package/polyfills/find.js.flow +29 -0
- package/polyfills/find.mjs +23 -0
- package/{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.mjs +1 -1
- 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 +53 -53
- package/utilities/buildASTSchema.js.flow +14 -30
- package/utilities/buildASTSchema.mjs +45 -55
- package/utilities/buildClientSchema.js +3 -3
- package/utilities/buildClientSchema.js.flow +6 -2
- package/utilities/buildClientSchema.mjs +3 -3
- 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.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 +56 -32
- package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +3 -3
- package/validation/rules/OverlappingFieldsCanBeMerged.mjs +47 -32
- 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
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import objectValues from '../polyfills/objectValues';
|
|
10
11
|
import invariant from '../jsutils/invariant';
|
|
11
12
|
import keyMap from '../jsutils/keyMap';
|
|
12
13
|
import keyValMap from '../jsutils/keyValMap';
|
|
@@ -128,21 +129,14 @@ export function buildASTSchema(
|
|
|
128
129
|
}
|
|
129
130
|
|
|
130
131
|
let schemaDef: ?SchemaDefinitionNode;
|
|
131
|
-
|
|
132
|
-
const typeDefs: Array<TypeDefinitionNode> = [];
|
|
133
132
|
const nodeMap: ObjMap<TypeDefinitionNode> = Object.create(null);
|
|
134
133
|
const directiveDefs: Array<DirectiveDefinitionNode> = [];
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
|
|
135
|
+
for (const def of documentAST.definitions) {
|
|
137
136
|
if (def.kind === Kind.SCHEMA_DEFINITION) {
|
|
138
137
|
schemaDef = def;
|
|
139
138
|
} else if (isTypeDefinitionNode(def)) {
|
|
140
|
-
|
|
141
|
-
if (nodeMap[typeName]) {
|
|
142
|
-
throw new Error(`Type "${typeName}" was defined more than once.`);
|
|
143
|
-
}
|
|
144
|
-
typeDefs.push(def);
|
|
145
|
-
nodeMap[typeName] = def;
|
|
139
|
+
nodeMap[def.name.value] = def;
|
|
146
140
|
} else if (def.kind === Kind.DIRECTIVE_DEFINITION) {
|
|
147
141
|
directiveDefs.push(def);
|
|
148
142
|
}
|
|
@@ -159,8 +153,8 @@ export function buildASTSchema(
|
|
|
159
153
|
const definitionBuilder = new ASTDefinitionBuilder(
|
|
160
154
|
nodeMap,
|
|
161
155
|
options,
|
|
162
|
-
|
|
163
|
-
throw new Error(`Type "${
|
|
156
|
+
typeName => {
|
|
157
|
+
throw new Error(`Type "${typeName}" not found in document.`);
|
|
164
158
|
},
|
|
165
159
|
);
|
|
166
160
|
|
|
@@ -194,7 +188,7 @@ export function buildASTSchema(
|
|
|
194
188
|
subscription: operationTypes.subscription
|
|
195
189
|
? (definitionBuilder.buildType(operationTypes.subscription): any)
|
|
196
190
|
: null,
|
|
197
|
-
types:
|
|
191
|
+
types: objectValues(nodeMap).map(node => definitionBuilder.buildType(node)),
|
|
198
192
|
directives,
|
|
199
193
|
astNode: schemaDef,
|
|
200
194
|
assumeValid: options && options.assumeValid,
|
|
@@ -204,24 +198,14 @@ export function buildASTSchema(
|
|
|
204
198
|
function getOperationTypes(schema: SchemaDefinitionNode) {
|
|
205
199
|
const opTypes = {};
|
|
206
200
|
for (const operationType of schema.operationTypes) {
|
|
207
|
-
|
|
208
|
-
const operation = operationType.operation;
|
|
209
|
-
if (opTypes[operation]) {
|
|
210
|
-
throw new Error(`Must provide only one ${operation} type in schema.`);
|
|
211
|
-
}
|
|
212
|
-
if (!nodeMap[typeName]) {
|
|
213
|
-
throw new Error(
|
|
214
|
-
`Specified ${operation} type "${typeName}" not found in document.`,
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
opTypes[operation] = operationType.type;
|
|
201
|
+
opTypes[operationType.operation] = operationType.type;
|
|
218
202
|
}
|
|
219
203
|
return opTypes;
|
|
220
204
|
}
|
|
221
205
|
}
|
|
222
206
|
|
|
223
207
|
type TypeDefinitionsMap = ObjMap<TypeDefinitionNode>;
|
|
224
|
-
type TypeResolver = (
|
|
208
|
+
type TypeResolver = (typeName: string) => GraphQLNamedType;
|
|
225
209
|
|
|
226
210
|
export class ASTDefinitionBuilder {
|
|
227
211
|
_typeDefinitionsMap: TypeDefinitionsMap;
|
|
@@ -251,7 +235,7 @@ export class ASTDefinitionBuilder {
|
|
|
251
235
|
const defNode = this._typeDefinitionsMap[typeName];
|
|
252
236
|
this._cache[typeName] = defNode
|
|
253
237
|
? this._makeSchemaDef(defNode)
|
|
254
|
-
: this._resolveType(node);
|
|
238
|
+
: this._resolveType(node.name.value);
|
|
255
239
|
} else {
|
|
256
240
|
this._cache[typeName] = this._makeSchemaDef(node);
|
|
257
241
|
}
|
|
@@ -286,7 +270,7 @@ export class ASTDefinitionBuilder {
|
|
|
286
270
|
});
|
|
287
271
|
}
|
|
288
272
|
|
|
289
|
-
buildField(field: FieldDefinitionNode): GraphQLFieldConfig
|
|
273
|
+
buildField(field: FieldDefinitionNode): GraphQLFieldConfig<mixed, mixed> {
|
|
290
274
|
return {
|
|
291
275
|
// Note: While this could make assertions to get the correctly typed
|
|
292
276
|
// value, that would throw immediately while type system validation
|
|
@@ -360,7 +344,7 @@ export class ASTDefinitionBuilder {
|
|
|
360
344
|
def: ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode,
|
|
361
345
|
) {
|
|
362
346
|
return def.fields
|
|
363
|
-
? keyValMap(
|
|
347
|
+
? keyValMap<_, GraphQLFieldConfig<mixed, mixed>>(
|
|
364
348
|
def.fields,
|
|
365
349
|
field => field.name.value,
|
|
366
350
|
field => this.buildField(field),
|
|
@@ -369,7 +353,7 @@ export class ASTDefinitionBuilder {
|
|
|
369
353
|
}
|
|
370
354
|
|
|
371
355
|
_makeInputValues(values: $ReadOnlyArray<InputValueDefinitionNode>) {
|
|
372
|
-
return keyValMap(
|
|
356
|
+
return keyValMap<_, GraphQLInputField>(
|
|
373
357
|
values,
|
|
374
358
|
value => value.name.value,
|
|
375
359
|
value => this.buildInputField(value),
|
|
@@ -396,7 +380,7 @@ export class ASTDefinitionBuilder {
|
|
|
396
380
|
|
|
397
381
|
_makeValueDefMap(def: EnumTypeDefinitionNode) {
|
|
398
382
|
return def.values
|
|
399
|
-
? keyValMap(
|
|
383
|
+
? keyValMap<_, GraphQLEnumValueConfig>(
|
|
400
384
|
def.values,
|
|
401
385
|
enumValue => enumValue.name.value,
|
|
402
386
|
enumValue => this.buildEnumValue(enumValue),
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
5
3
|
*
|
|
6
4
|
* This source code is licensed under the MIT license found in the
|
|
7
5
|
* LICENSE file in the root directory of this source tree.
|
|
8
6
|
*
|
|
9
|
-
*
|
|
7
|
+
*
|
|
10
8
|
*/
|
|
9
|
+
import objectValues from '../polyfills/objectValues';
|
|
11
10
|
import invariant from '../jsutils/invariant';
|
|
12
11
|
import keyMap from '../jsutils/keyMap';
|
|
13
12
|
import keyValMap from '../jsutils/keyValMap';
|
|
@@ -49,26 +48,36 @@ export function buildASTSchema(documentAST, options) {
|
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
var schemaDef;
|
|
52
|
-
var typeDefs = [];
|
|
53
51
|
var nodeMap = Object.create(null);
|
|
54
52
|
var directiveDefs = [];
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
var _iteratorNormalCompletion = true;
|
|
54
|
+
var _didIteratorError = false;
|
|
55
|
+
var _iteratorError = undefined;
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
for (var _iterator = documentAST.definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
59
|
+
var def = _step.value;
|
|
60
|
+
|
|
61
|
+
if (def.kind === Kind.SCHEMA_DEFINITION) {
|
|
62
|
+
schemaDef = def;
|
|
63
|
+
} else if (isTypeDefinitionNode(def)) {
|
|
64
|
+
nodeMap[def.name.value] = def;
|
|
65
|
+
} else if (def.kind === Kind.DIRECTIVE_DEFINITION) {
|
|
66
|
+
directiveDefs.push(def);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
} catch (err) {
|
|
70
|
+
_didIteratorError = true;
|
|
71
|
+
_iteratorError = err;
|
|
72
|
+
} finally {
|
|
73
|
+
try {
|
|
74
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
75
|
+
_iterator.return();
|
|
76
|
+
}
|
|
77
|
+
} finally {
|
|
78
|
+
if (_didIteratorError) {
|
|
79
|
+
throw _iteratorError;
|
|
66
80
|
}
|
|
67
|
-
|
|
68
|
-
typeDefs.push(def);
|
|
69
|
-
nodeMap[typeName] = def;
|
|
70
|
-
} else if (def.kind === Kind.DIRECTIVE_DEFINITION) {
|
|
71
|
-
directiveDefs.push(def);
|
|
72
81
|
}
|
|
73
82
|
}
|
|
74
83
|
|
|
@@ -77,8 +86,8 @@ export function buildASTSchema(documentAST, options) {
|
|
|
77
86
|
mutation: nodeMap.Mutation,
|
|
78
87
|
subscription: nodeMap.Subscription
|
|
79
88
|
};
|
|
80
|
-
var definitionBuilder = new ASTDefinitionBuilder(nodeMap, options, function (
|
|
81
|
-
throw new Error("Type \"".concat(
|
|
89
|
+
var definitionBuilder = new ASTDefinitionBuilder(nodeMap, options, function (typeName) {
|
|
90
|
+
throw new Error("Type \"".concat(typeName, "\" not found in document."));
|
|
82
91
|
});
|
|
83
92
|
var directives = directiveDefs.map(function (def) {
|
|
84
93
|
return definitionBuilder.buildDirective(def);
|
|
@@ -109,7 +118,7 @@ export function buildASTSchema(documentAST, options) {
|
|
|
109
118
|
query: operationTypes.query ? definitionBuilder.buildType(operationTypes.query) : null,
|
|
110
119
|
mutation: operationTypes.mutation ? definitionBuilder.buildType(operationTypes.mutation) : null,
|
|
111
120
|
subscription: operationTypes.subscription ? definitionBuilder.buildType(operationTypes.subscription) : null,
|
|
112
|
-
types:
|
|
121
|
+
types: objectValues(nodeMap).map(function (node) {
|
|
113
122
|
return definitionBuilder.buildType(node);
|
|
114
123
|
}),
|
|
115
124
|
directives: directives,
|
|
@@ -120,37 +129,26 @@ export function buildASTSchema(documentAST, options) {
|
|
|
120
129
|
|
|
121
130
|
function getOperationTypes(schema) {
|
|
122
131
|
var opTypes = {};
|
|
123
|
-
var
|
|
124
|
-
var
|
|
125
|
-
var
|
|
132
|
+
var _iteratorNormalCompletion2 = true;
|
|
133
|
+
var _didIteratorError2 = false;
|
|
134
|
+
var _iteratorError2 = undefined;
|
|
126
135
|
|
|
127
136
|
try {
|
|
128
|
-
for (var
|
|
129
|
-
var operationType =
|
|
130
|
-
|
|
131
|
-
var operation = operationType.operation;
|
|
132
|
-
|
|
133
|
-
if (opTypes[operation]) {
|
|
134
|
-
throw new Error("Must provide only one ".concat(operation, " type in schema."));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (!nodeMap[_typeName]) {
|
|
138
|
-
throw new Error("Specified ".concat(operation, " type \"").concat(_typeName, "\" not found in document."));
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
opTypes[operation] = operationType.type;
|
|
137
|
+
for (var _iterator2 = schema.operationTypes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
138
|
+
var operationType = _step2.value;
|
|
139
|
+
opTypes[operationType.operation] = operationType.type;
|
|
142
140
|
}
|
|
143
141
|
} catch (err) {
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
_didIteratorError2 = true;
|
|
143
|
+
_iteratorError2 = err;
|
|
146
144
|
} finally {
|
|
147
145
|
try {
|
|
148
|
-
if (!
|
|
149
|
-
|
|
146
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
147
|
+
_iterator2.return();
|
|
150
148
|
}
|
|
151
149
|
} finally {
|
|
152
|
-
if (
|
|
153
|
-
throw
|
|
150
|
+
if (_didIteratorError2) {
|
|
151
|
+
throw _iteratorError2;
|
|
154
152
|
}
|
|
155
153
|
}
|
|
156
154
|
}
|
|
@@ -162,14 +160,6 @@ export var ASTDefinitionBuilder =
|
|
|
162
160
|
/*#__PURE__*/
|
|
163
161
|
function () {
|
|
164
162
|
function ASTDefinitionBuilder(typeDefinitionsMap, options, resolveType) {
|
|
165
|
-
_defineProperty(this, "_typeDefinitionsMap", void 0);
|
|
166
|
-
|
|
167
|
-
_defineProperty(this, "_options", void 0);
|
|
168
|
-
|
|
169
|
-
_defineProperty(this, "_resolveType", void 0);
|
|
170
|
-
|
|
171
|
-
_defineProperty(this, "_cache", void 0);
|
|
172
|
-
|
|
173
163
|
this._typeDefinitionsMap = typeDefinitionsMap;
|
|
174
164
|
this._options = options;
|
|
175
165
|
this._resolveType = resolveType; // Initialize to the GraphQL built in scalars and introspection types.
|
|
@@ -187,7 +177,7 @@ function () {
|
|
|
187
177
|
if (!this._cache[typeName]) {
|
|
188
178
|
if (node.kind === Kind.NAMED_TYPE) {
|
|
189
179
|
var defNode = this._typeDefinitionsMap[typeName];
|
|
190
|
-
this._cache[typeName] = defNode ? this._makeSchemaDef(defNode) : this._resolveType(node);
|
|
180
|
+
this._cache[typeName] = defNode ? this._makeSchemaDef(defNode) : this._resolveType(node.name.value);
|
|
191
181
|
} else {
|
|
192
182
|
this._cache[typeName] = this._makeSchemaDef(node);
|
|
193
183
|
}
|
|
@@ -35,7 +35,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
35
35
|
* This source code is licensed under the MIT license found in the
|
|
36
36
|
* LICENSE file in the root directory of this source tree.
|
|
37
37
|
*
|
|
38
|
-
*
|
|
38
|
+
*
|
|
39
39
|
*/
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -112,13 +112,13 @@ function buildClientSchema(introspection, options) {
|
|
|
112
112
|
|
|
113
113
|
function getInputType(typeRef) {
|
|
114
114
|
var type = getType(typeRef);
|
|
115
|
-
!(0, _definition.isInputType)(type) ? (0, _invariant.default)(0, 'Introspection must provide input type for arguments.') : void 0;
|
|
115
|
+
!(0, _definition.isInputType)(type) ? (0, _invariant.default)(0, 'Introspection must provide input type for arguments, but received: ' + (0, _inspect.default)(type) + '.') : void 0;
|
|
116
116
|
return type;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
function getOutputType(typeRef) {
|
|
120
120
|
var type = getType(typeRef);
|
|
121
|
-
!(0, _definition.isOutputType)(type) ? (0, _invariant.default)(0, 'Introspection must provide output type for fields.') : void 0;
|
|
121
|
+
!(0, _definition.isOutputType)(type) ? (0, _invariant.default)(0, 'Introspection must provide output type for fields, but received: ' + (0, _inspect.default)(type) + '.') : void 0;
|
|
122
122
|
return type;
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -143,7 +143,9 @@ export function buildClientSchema(
|
|
|
143
143
|
const type = getType(typeRef);
|
|
144
144
|
invariant(
|
|
145
145
|
isInputType(type),
|
|
146
|
-
'Introspection must provide input type for arguments
|
|
146
|
+
'Introspection must provide input type for arguments, but received: ' +
|
|
147
|
+
inspect(type) +
|
|
148
|
+
'.',
|
|
147
149
|
);
|
|
148
150
|
return type;
|
|
149
151
|
}
|
|
@@ -154,7 +156,9 @@ export function buildClientSchema(
|
|
|
154
156
|
const type = getType(typeRef);
|
|
155
157
|
invariant(
|
|
156
158
|
isOutputType(type),
|
|
157
|
-
'Introspection must provide output type for fields
|
|
159
|
+
'Introspection must provide output type for fields, but received: ' +
|
|
160
|
+
inspect(type) +
|
|
161
|
+
'.',
|
|
158
162
|
);
|
|
159
163
|
return type;
|
|
160
164
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
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.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
*
|
|
8
8
|
*/
|
|
9
9
|
import inspect from '../jsutils/inspect';
|
|
10
10
|
import invariant from '../jsutils/invariant';
|
|
@@ -92,13 +92,13 @@ export function buildClientSchema(introspection, options) {
|
|
|
92
92
|
|
|
93
93
|
function getInputType(typeRef) {
|
|
94
94
|
var type = getType(typeRef);
|
|
95
|
-
!isInputType(type) ? invariant(0, 'Introspection must provide input type for arguments.') : void 0;
|
|
95
|
+
!isInputType(type) ? invariant(0, 'Introspection must provide input type for arguments, but received: ' + inspect(type) + '.') : void 0;
|
|
96
96
|
return type;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
function getOutputType(typeRef) {
|
|
100
100
|
var type = getType(typeRef);
|
|
101
|
-
!isOutputType(type) ? invariant(0, 'Introspection must provide output type for fields.') : void 0;
|
|
101
|
+
!isOutputType(type) ? invariant(0, 'Introspection must provide output type for fields, but received: ' + inspect(type) + '.') : void 0;
|
|
102
102
|
return type;
|
|
103
103
|
}
|
|
104
104
|
|
package/utilities/coerceValue.js
CHANGED
|
@@ -7,6 +7,8 @@ exports.coerceValue = coerceValue;
|
|
|
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 _isInvalid = _interopRequireDefault(require("../jsutils/isInvalid"));
|
|
@@ -111,39 +113,58 @@ function coerceValue(value, type, blameNode, path) {
|
|
|
111
113
|
var _coercedValue = {};
|
|
112
114
|
var fields = type.getFields(); // Ensure every defined field is valid.
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
var _iteratorNormalCompletion = true;
|
|
117
|
+
var _didIteratorError = false;
|
|
118
|
+
var _iteratorError = undefined;
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
for (var _iterator = (0, _objectValues.default)(fields)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
122
|
+
var field = _step.value;
|
|
123
|
+
var fieldValue = value[field.name];
|
|
118
124
|
|
|
119
125
|
if ((0, _isInvalid.default)(fieldValue)) {
|
|
120
126
|
if (!(0, _isInvalid.default)(field.defaultValue)) {
|
|
121
|
-
_coercedValue[
|
|
127
|
+
_coercedValue[field.name] = field.defaultValue;
|
|
122
128
|
} else if ((0, _definition.isNonNullType)(field.type)) {
|
|
123
|
-
_errors = add(_errors, coercionError("Field ".concat(printPath(atPath(path,
|
|
129
|
+
_errors = add(_errors, coercionError("Field ".concat(printPath(atPath(path, field.name)), " of required ") + "type ".concat((0, _inspect.default)(field.type), " was not provided"), blameNode));
|
|
124
130
|
}
|
|
125
131
|
} else {
|
|
126
|
-
var coercedField = coerceValue(fieldValue, field.type, blameNode, atPath(path,
|
|
132
|
+
var coercedField = coerceValue(fieldValue, field.type, blameNode, atPath(path, field.name));
|
|
127
133
|
|
|
128
134
|
if (coercedField.errors) {
|
|
129
135
|
_errors = add(_errors, coercedField.errors);
|
|
130
136
|
} else if (!_errors) {
|
|
131
|
-
_coercedValue[
|
|
137
|
+
_coercedValue[field.name] = coercedField.value;
|
|
132
138
|
}
|
|
133
139
|
}
|
|
140
|
+
} // Ensure every provided field is defined.
|
|
141
|
+
|
|
142
|
+
} catch (err) {
|
|
143
|
+
_didIteratorError = true;
|
|
144
|
+
_iteratorError = err;
|
|
145
|
+
} finally {
|
|
146
|
+
try {
|
|
147
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
148
|
+
_iterator.return();
|
|
149
|
+
}
|
|
150
|
+
} finally {
|
|
151
|
+
if (_didIteratorError) {
|
|
152
|
+
throw _iteratorError;
|
|
153
|
+
}
|
|
134
154
|
}
|
|
135
|
-
}
|
|
155
|
+
}
|
|
136
156
|
|
|
157
|
+
var _arr = Object.keys(value);
|
|
137
158
|
|
|
138
|
-
for (var
|
|
139
|
-
|
|
140
|
-
if (!fields[_fieldName]) {
|
|
141
|
-
var _suggestions = (0, _suggestionList.default)(_fieldName, Object.keys(fields));
|
|
159
|
+
for (var _i = 0; _i < _arr.length; _i++) {
|
|
160
|
+
var fieldName = _arr[_i];
|
|
142
161
|
|
|
143
|
-
|
|
162
|
+
if (!fields[fieldName]) {
|
|
163
|
+
var _suggestions = (0, _suggestionList.default)(fieldName, Object.keys(fields));
|
|
144
164
|
|
|
145
|
-
|
|
146
|
-
|
|
165
|
+
var _didYouMean = _suggestions.length !== 0 ? "did you mean ".concat((0, _orList.default)(_suggestions), "?") : undefined;
|
|
166
|
+
|
|
167
|
+
_errors = add(_errors, coercionError("Field \"".concat(fieldName, "\" is not defined by type ").concat(type.name), blameNode, path, _didYouMean));
|
|
147
168
|
}
|
|
148
169
|
}
|
|
149
170
|
|
|
@@ -197,6 +218,4 @@ function printPath(path) {
|
|
|
197
218
|
}
|
|
198
219
|
|
|
199
220
|
return pathStr ? 'value' + pathStr : '';
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
221
|
+
}
|