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.
Files changed (279) hide show
  1. package/README.md +4 -4
  2. package/error/GraphQLError.js +1 -1
  3. package/error/GraphQLError.js.flow +3 -3
  4. package/error/GraphQLError.mjs +1 -1
  5. package/error/formatError.js +1 -1
  6. package/error/formatError.mjs +1 -1
  7. package/error/index.mjs +1 -1
  8. package/error/locatedError.js +1 -1
  9. package/error/locatedError.mjs +1 -1
  10. package/error/printError.js +1 -1
  11. package/error/printError.mjs +1 -1
  12. package/error/syntaxError.js +1 -1
  13. package/error/syntaxError.mjs +1 -1
  14. package/execution/execute.mjs +1 -1
  15. package/execution/index.mjs +1 -1
  16. package/execution/values.js +3 -3
  17. package/execution/values.js.flow +1 -1
  18. package/execution/values.mjs +2 -2
  19. package/graphql.js +1 -1
  20. package/graphql.mjs +1 -1
  21. package/index.js +12 -0
  22. package/index.js.flow +2 -0
  23. package/index.mjs +2 -2
  24. package/jsutils/dedent.js +1 -1
  25. package/jsutils/dedent.mjs +1 -1
  26. package/jsutils/defineToJSON.js +17 -6
  27. package/jsutils/defineToJSON.js.flow +14 -5
  28. package/jsutils/defineToJSON.mjs +14 -6
  29. package/jsutils/defineToStringTag.js +5 -5
  30. package/jsutils/defineToStringTag.js.flow +3 -3
  31. package/jsutils/defineToStringTag.mjs +4 -4
  32. package/jsutils/inspect.js +22 -11
  33. package/jsutils/inspect.js.flow +22 -2
  34. package/jsutils/inspect.mjs +21 -4
  35. package/jsutils/instanceOf.js +1 -1
  36. package/jsutils/instanceOf.mjs +1 -1
  37. package/jsutils/invariant.js +1 -1
  38. package/jsutils/invariant.mjs +1 -1
  39. package/jsutils/isInvalid.js +1 -1
  40. package/jsutils/isInvalid.mjs +1 -1
  41. package/jsutils/isNullish.js +1 -1
  42. package/jsutils/isNullish.mjs +1 -1
  43. package/jsutils/isPromise.js +1 -1
  44. package/jsutils/isPromise.mjs +1 -1
  45. package/jsutils/keyMap.js +1 -1
  46. package/jsutils/keyMap.mjs +1 -1
  47. package/jsutils/keyValMap.js +1 -1
  48. package/jsutils/keyValMap.mjs +1 -1
  49. package/jsutils/mapValue.js +54 -0
  50. package/jsutils/mapValue.js.flow +27 -0
  51. package/jsutils/mapValue.mjs +44 -0
  52. package/jsutils/memoize3.js +1 -1
  53. package/jsutils/memoize3.mjs +1 -1
  54. package/jsutils/nodejsCustomInspectSymbol.js +18 -0
  55. package/jsutils/nodejsCustomInspectSymbol.js.flow +15 -0
  56. package/jsutils/nodejsCustomInspectSymbol.mjs +10 -0
  57. package/jsutils/orList.js +17 -4
  58. package/jsutils/orList.js.flow +13 -7
  59. package/jsutils/orList.mjs +14 -4
  60. package/jsutils/promiseForObject.js +1 -1
  61. package/jsutils/promiseForObject.mjs +1 -1
  62. package/jsutils/promiseReduce.js +1 -1
  63. package/jsutils/promiseReduce.mjs +1 -1
  64. package/jsutils/quotedOrList.js +1 -1
  65. package/jsutils/quotedOrList.mjs +1 -1
  66. package/jsutils/suggestionList.js +1 -1
  67. package/jsutils/suggestionList.mjs +1 -1
  68. package/language/blockStringValue.js +1 -1
  69. package/language/blockStringValue.mjs +1 -1
  70. package/language/directiveLocation.js +1 -1
  71. package/language/directiveLocation.mjs +1 -1
  72. package/language/index.mjs +1 -1
  73. package/language/kinds.js +1 -1
  74. package/language/kinds.mjs +1 -1
  75. package/language/lexer.js +28 -12
  76. package/language/lexer.js.flow +33 -19
  77. package/language/lexer.mjs +27 -12
  78. package/language/location.js +1 -1
  79. package/language/location.mjs +1 -1
  80. package/language/parser.js +31 -38
  81. package/language/parser.js.flow +32 -48
  82. package/language/parser.mjs +30 -38
  83. package/language/predicates.js +1 -1
  84. package/language/predicates.mjs +1 -1
  85. package/language/printer.js +13 -7
  86. package/language/printer.js.flow +19 -9
  87. package/language/printer.mjs +13 -7
  88. package/language/source.js +8 -7
  89. package/language/source.mjs +1 -9
  90. package/language/visitor.js +6 -5
  91. package/language/visitor.js.flow +2 -4
  92. package/language/visitor.mjs +6 -5
  93. package/package.json +5 -2
  94. package/polyfills/find.js +31 -0
  95. package/polyfills/find.js.flow +29 -0
  96. package/polyfills/find.mjs +23 -0
  97. package/{jsutils → polyfills}/isFinite.js +1 -1
  98. package/{jsutils → polyfills}/isFinite.js.flow +0 -0
  99. package/{jsutils → polyfills}/isFinite.mjs +1 -1
  100. package/{jsutils → polyfills}/isInteger.js +1 -1
  101. package/{jsutils → polyfills}/isInteger.js.flow +0 -0
  102. package/{jsutils → polyfills}/isInteger.mjs +1 -1
  103. package/polyfills/objectEntries.js +26 -0
  104. package/polyfills/objectEntries.js.flow +19 -0
  105. package/polyfills/objectEntries.mjs +18 -0
  106. package/{jsutils → polyfills}/objectValues.js +1 -1
  107. package/{jsutils → polyfills}/objectValues.js.flow +1 -1
  108. package/{jsutils → polyfills}/objectValues.mjs +1 -1
  109. package/subscription/asyncIteratorReject.mjs +1 -1
  110. package/subscription/index.mjs +1 -1
  111. package/subscription/mapAsyncIterator.mjs +1 -1
  112. package/subscription/subscribe.js +1 -1
  113. package/subscription/subscribe.mjs +1 -1
  114. package/type/definition.js +31 -130
  115. package/type/definition.js.flow +35 -47
  116. package/type/definition.mjs +30 -131
  117. package/type/directives.js +25 -29
  118. package/type/directives.js.flow +24 -20
  119. package/type/directives.mjs +22 -30
  120. package/type/index.js +12 -0
  121. package/type/index.js.flow +4 -0
  122. package/type/index.mjs +5 -3
  123. package/type/introspection.js +3 -3
  124. package/type/introspection.js.flow +1 -1
  125. package/type/introspection.mjs +2 -2
  126. package/type/scalars.js +45 -34
  127. package/type/scalars.js.flow +40 -26
  128. package/type/scalars.mjs +44 -26
  129. package/type/schema.js +82 -87
  130. package/type/schema.js.flow +17 -9
  131. package/type/schema.mjs +79 -86
  132. package/type/validate.js +168 -175
  133. package/type/validate.js.flow +8 -49
  134. package/type/validate.mjs +159 -175
  135. package/utilities/TypeInfo.js +10 -23
  136. package/utilities/TypeInfo.js.flow +1 -1
  137. package/utilities/TypeInfo.mjs +2 -24
  138. package/utilities/assertValidName.js +1 -1
  139. package/utilities/assertValidName.mjs +1 -1
  140. package/utilities/astFromValue.js +2 -2
  141. package/utilities/astFromValue.js.flow +1 -1
  142. package/utilities/astFromValue.mjs +2 -2
  143. package/utilities/buildASTSchema.js +53 -53
  144. package/utilities/buildASTSchema.js.flow +14 -30
  145. package/utilities/buildASTSchema.mjs +45 -55
  146. package/utilities/buildClientSchema.js +3 -3
  147. package/utilities/buildClientSchema.js.flow +6 -2
  148. package/utilities/buildClientSchema.mjs +3 -3
  149. package/utilities/coerceValue.js +38 -19
  150. package/utilities/coerceValue.js.flow +41 -47
  151. package/utilities/coerceValue.mjs +38 -20
  152. package/utilities/concatAST.js +1 -1
  153. package/utilities/concatAST.mjs +1 -1
  154. package/utilities/extendSchema.js +228 -312
  155. package/utilities/extendSchema.js.flow +27 -152
  156. package/utilities/extendSchema.mjs +229 -312
  157. package/utilities/findBreakingChanges.js +7 -5
  158. package/utilities/findBreakingChanges.js.flow +3 -2
  159. package/utilities/findBreakingChanges.mjs +6 -5
  160. package/utilities/findDeprecatedUsages.js +1 -1
  161. package/utilities/findDeprecatedUsages.mjs +1 -1
  162. package/utilities/getOperationAST.js +1 -1
  163. package/utilities/getOperationAST.mjs +1 -1
  164. package/utilities/getOperationRootType.js +1 -1
  165. package/utilities/getOperationRootType.mjs +1 -1
  166. package/utilities/index.mjs +1 -1
  167. package/utilities/introspectionFromSchema.js +1 -1
  168. package/utilities/introspectionFromSchema.mjs +1 -1
  169. package/utilities/introspectionQuery.js +1 -1
  170. package/utilities/introspectionQuery.mjs +1 -1
  171. package/utilities/isValidJSValue.js +1 -1
  172. package/utilities/isValidJSValue.mjs +1 -1
  173. package/utilities/isValidLiteralValue.js +1 -1
  174. package/utilities/isValidLiteralValue.mjs +1 -1
  175. package/utilities/lexicographicSortSchema.js +2 -2
  176. package/utilities/lexicographicSortSchema.js.flow +1 -1
  177. package/utilities/lexicographicSortSchema.mjs +2 -2
  178. package/utilities/schemaPrinter.js +3 -3
  179. package/utilities/schemaPrinter.js.flow +1 -1
  180. package/utilities/schemaPrinter.mjs +2 -2
  181. package/utilities/separateOperations.js +1 -1
  182. package/utilities/separateOperations.mjs +1 -1
  183. package/utilities/typeComparators.js +1 -1
  184. package/utilities/typeComparators.mjs +1 -1
  185. package/utilities/typeFromAST.js +1 -1
  186. package/utilities/typeFromAST.mjs +1 -1
  187. package/utilities/valueFromAST.js +3 -3
  188. package/utilities/valueFromAST.js.flow +1 -1
  189. package/utilities/valueFromAST.mjs +2 -2
  190. package/utilities/valueFromASTUntyped.js +1 -1
  191. package/utilities/valueFromASTUntyped.mjs +1 -1
  192. package/validation/ValidationContext.js +57 -82
  193. package/validation/ValidationContext.js.flow +52 -49
  194. package/validation/ValidationContext.mjs +52 -77
  195. package/validation/index.mjs +1 -1
  196. package/validation/rules/ExecutableDefinitions.js +1 -1
  197. package/validation/rules/ExecutableDefinitions.js.flow +1 -1
  198. package/validation/rules/ExecutableDefinitions.mjs +1 -1
  199. package/validation/rules/FieldsOnCorrectType.js +1 -1
  200. package/validation/rules/FieldsOnCorrectType.mjs +1 -1
  201. package/validation/rules/FragmentsOnCompositeTypes.js +1 -1
  202. package/validation/rules/FragmentsOnCompositeTypes.mjs +1 -1
  203. package/validation/rules/KnownArgumentNames.mjs +1 -1
  204. package/validation/rules/KnownDirectives.js +1 -1
  205. package/validation/rules/KnownDirectives.mjs +1 -1
  206. package/validation/rules/KnownFragmentNames.js +1 -1
  207. package/validation/rules/KnownFragmentNames.mjs +1 -1
  208. package/validation/rules/KnownTypeNames.js +59 -21
  209. package/validation/rules/KnownTypeNames.js.flow +54 -20
  210. package/validation/rules/KnownTypeNames.mjs +56 -21
  211. package/validation/rules/LoneAnonymousOperation.js +1 -1
  212. package/validation/rules/LoneAnonymousOperation.mjs +1 -1
  213. package/validation/rules/LoneSchemaDefinition.js +1 -1
  214. package/validation/rules/LoneSchemaDefinition.mjs +1 -1
  215. package/validation/rules/NoFragmentCycles.js +1 -1
  216. package/validation/rules/NoFragmentCycles.js.flow +2 -2
  217. package/validation/rules/NoFragmentCycles.mjs +1 -1
  218. package/validation/rules/NoUndefinedVariables.js +1 -1
  219. package/validation/rules/NoUndefinedVariables.mjs +1 -1
  220. package/validation/rules/NoUnusedFragments.js +1 -1
  221. package/validation/rules/NoUnusedFragments.js.flow +2 -2
  222. package/validation/rules/NoUnusedFragments.mjs +1 -1
  223. package/validation/rules/NoUnusedVariables.js +1 -1
  224. package/validation/rules/NoUnusedVariables.mjs +1 -1
  225. package/validation/rules/OverlappingFieldsCanBeMerged.js +56 -32
  226. package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +3 -3
  227. package/validation/rules/OverlappingFieldsCanBeMerged.mjs +47 -32
  228. package/validation/rules/PossibleFragmentSpreads.js +1 -1
  229. package/validation/rules/PossibleFragmentSpreads.mjs +1 -1
  230. package/validation/rules/PossibleTypeExtensions.js +158 -0
  231. package/validation/rules/PossibleTypeExtensions.js.flow +160 -0
  232. package/validation/rules/PossibleTypeExtensions.mjs +146 -0
  233. package/validation/rules/ProvidedRequiredArguments.mjs +1 -1
  234. package/validation/rules/ScalarLeafs.js +1 -1
  235. package/validation/rules/ScalarLeafs.mjs +1 -1
  236. package/validation/rules/SingleFieldSubscriptions.js +1 -1
  237. package/validation/rules/SingleFieldSubscriptions.mjs +1 -1
  238. package/validation/rules/UniqueArgumentNames.js +1 -1
  239. package/validation/rules/UniqueArgumentNames.mjs +1 -1
  240. package/validation/rules/UniqueDirectiveNames.js +55 -0
  241. package/validation/rules/UniqueDirectiveNames.js.flow +64 -0
  242. package/validation/rules/UniqueDirectiveNames.mjs +43 -0
  243. package/validation/rules/UniqueDirectivesPerLocation.js +1 -1
  244. package/validation/rules/UniqueDirectivesPerLocation.mjs +1 -1
  245. package/validation/rules/UniqueEnumValueNames.js +94 -0
  246. package/validation/rules/UniqueEnumValueNames.js.flow +87 -0
  247. package/validation/rules/UniqueEnumValueNames.mjs +81 -0
  248. package/validation/rules/UniqueFieldDefinitionNames.js +105 -0
  249. package/validation/rules/UniqueFieldDefinitionNames.js.flow +101 -0
  250. package/validation/rules/UniqueFieldDefinitionNames.mjs +92 -0
  251. package/validation/rules/UniqueFragmentNames.js +1 -1
  252. package/validation/rules/UniqueFragmentNames.mjs +1 -1
  253. package/validation/rules/UniqueInputFieldNames.js +1 -1
  254. package/validation/rules/UniqueInputFieldNames.mjs +1 -1
  255. package/validation/rules/UniqueOperationNames.js +1 -1
  256. package/validation/rules/UniqueOperationNames.mjs +1 -1
  257. package/validation/rules/UniqueOperationTypes.js +85 -0
  258. package/validation/rules/UniqueOperationTypes.js.flow +76 -0
  259. package/validation/rules/UniqueOperationTypes.mjs +73 -0
  260. package/validation/rules/UniqueTypeNames.js +62 -0
  261. package/validation/rules/UniqueTypeNames.js.flow +67 -0
  262. package/validation/rules/UniqueTypeNames.mjs +50 -0
  263. package/validation/rules/UniqueVariableNames.js +1 -1
  264. package/validation/rules/UniqueVariableNames.mjs +1 -1
  265. package/validation/rules/ValuesOfCorrectType.js +29 -13
  266. package/validation/rules/ValuesOfCorrectType.js.flow +4 -5
  267. package/validation/rules/ValuesOfCorrectType.mjs +28 -13
  268. package/validation/rules/VariablesAreInputTypes.js +1 -1
  269. package/validation/rules/VariablesAreInputTypes.mjs +1 -1
  270. package/validation/rules/VariablesInAllowedPosition.js +4 -4
  271. package/validation/rules/VariablesInAllowedPosition.mjs +4 -4
  272. package/validation/specifiedRules.js +14 -2
  273. package/validation/specifiedRules.js.flow +13 -0
  274. package/validation/specifiedRules.mjs +8 -2
  275. package/validation/validate.js +1 -1
  276. package/validation/validate.mjs +1 -1
  277. package/jsutils/find.js +0 -22
  278. package/jsutils/find.js.flow +0 -19
  279. 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
- * strict
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
- 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; }
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
- for (var i = 0; i < documentAST.definitions.length; i++) {
76
- var def = documentAST.definitions[i];
77
-
78
- if (def.kind === _kinds.Kind.SCHEMA_DEFINITION) {
79
- schemaDef = def;
80
- } else if ((0, _predicates.isTypeDefinitionNode)(def)) {
81
- var typeName = def.name.value;
82
-
83
- if (nodeMap[typeName]) {
84
- throw new Error("Type \"".concat(typeName, "\" was defined more than once."));
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 (typeRef) {
100
- throw new Error("Type \"".concat(typeRef.name.value, "\" not found in document."));
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: typeDefs.map(function (node) {
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 _iteratorNormalCompletion = true;
143
- var _didIteratorError = false;
144
- var _iteratorError = undefined;
161
+ var _iteratorNormalCompletion2 = true;
162
+ var _didIteratorError2 = false;
163
+ var _iteratorError2 = undefined;
145
164
 
146
165
  try {
147
- for (var _iterator = schema.operationTypes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
148
- var operationType = _step.value;
149
- var _typeName = operationType.type.name.value;
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
- _didIteratorError = true;
164
- _iteratorError = err;
171
+ _didIteratorError2 = true;
172
+ _iteratorError2 = err;
165
173
  } finally {
166
174
  try {
167
- if (!_iteratorNormalCompletion && _iterator.return != null) {
168
- _iterator.return();
175
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
176
+ _iterator2.return();
169
177
  }
170
178
  } finally {
171
- if (_didIteratorError) {
172
- throw _iteratorError;
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
- for (let i = 0; i < documentAST.definitions.length; i++) {
136
- const def = documentAST.definitions[i];
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
- const typeName = def.name.value;
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
- typeRef => {
163
- throw new Error(`Type "${typeRef.name.value}" not found in document.`);
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: typeDefs.map(node => definitionBuilder.buildType(node)),
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
- const typeName = operationType.type.name.value;
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 = (typeRef: NamedTypeNode) => GraphQLNamedType;
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
- * strict
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
- for (var i = 0; i < documentAST.definitions.length; i++) {
57
- var def = documentAST.definitions[i];
58
-
59
- if (def.kind === Kind.SCHEMA_DEFINITION) {
60
- schemaDef = def;
61
- } else if (isTypeDefinitionNode(def)) {
62
- var typeName = def.name.value;
63
-
64
- if (nodeMap[typeName]) {
65
- throw new Error("Type \"".concat(typeName, "\" was defined more than once."));
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 (typeRef) {
81
- throw new Error("Type \"".concat(typeRef.name.value, "\" not found in document."));
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: typeDefs.map(function (node) {
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 _iteratorNormalCompletion = true;
124
- var _didIteratorError = false;
125
- var _iteratorError = undefined;
132
+ var _iteratorNormalCompletion2 = true;
133
+ var _didIteratorError2 = false;
134
+ var _iteratorError2 = undefined;
126
135
 
127
136
  try {
128
- for (var _iterator = schema.operationTypes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
129
- var operationType = _step.value;
130
- var _typeName = operationType.type.name.value;
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
- _didIteratorError = true;
145
- _iteratorError = err;
142
+ _didIteratorError2 = true;
143
+ _iteratorError2 = err;
146
144
  } finally {
147
145
  try {
148
- if (!_iteratorNormalCompletion && _iterator.return != null) {
149
- _iterator.return();
146
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
147
+ _iterator2.return();
150
148
  }
151
149
  } finally {
152
- if (_didIteratorError) {
153
- throw _iteratorError;
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
- * strict
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
- * strict
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
 
@@ -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
- for (var fieldName in fields) {
115
- if (hasOwnProperty.call(fields, fieldName)) {
116
- var field = fields[fieldName];
117
- var fieldValue = value[fieldName];
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[fieldName] = field.defaultValue;
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, fieldName)), " of required ") + "type ".concat((0, _inspect.default)(field.type), " was not provided"), blameNode));
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, fieldName));
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[fieldName] = coercedField.value;
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
- } // Ensure every provided field is defined.
155
+ }
136
156
 
157
+ var _arr = Object.keys(value);
137
158
 
138
- for (var _fieldName in value) {
139
- if (hasOwnProperty.call(value, _fieldName)) {
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
- var _didYouMean = _suggestions.length !== 0 ? "did you mean ".concat((0, _orList.default)(_suggestions), "?") : undefined;
162
+ if (!fields[fieldName]) {
163
+ var _suggestions = (0, _suggestionList.default)(fieldName, Object.keys(fields));
144
164
 
145
- _errors = add(_errors, coercionError("Field \"".concat(_fieldName, "\" is not defined by type ").concat(type.name), blameNode, path, _didYouMean));
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
+ }