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.
Files changed (285) 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.js +4 -4
  15. package/execution/execute.js.flow +4 -6
  16. package/execution/execute.mjs +5 -5
  17. package/execution/index.mjs +1 -1
  18. package/execution/values.js +4 -4
  19. package/execution/values.js.flow +3 -3
  20. package/execution/values.mjs +3 -3
  21. package/graphql.js +1 -1
  22. package/graphql.mjs +1 -1
  23. package/index.js +12 -0
  24. package/index.js.flow +4 -0
  25. package/index.mjs +4 -4
  26. package/jsutils/dedent.js +2 -2
  27. package/jsutils/dedent.js.flow +1 -1
  28. package/jsutils/dedent.mjs +2 -2
  29. package/jsutils/defineToJSON.js +17 -6
  30. package/jsutils/defineToJSON.js.flow +14 -5
  31. package/jsutils/defineToJSON.mjs +14 -6
  32. package/jsutils/defineToStringTag.js +5 -5
  33. package/jsutils/defineToStringTag.js.flow +3 -3
  34. package/jsutils/defineToStringTag.mjs +4 -4
  35. package/jsutils/inspect.js +46 -12
  36. package/jsutils/inspect.js.flow +42 -15
  37. package/jsutils/inspect.mjs +45 -5
  38. package/jsutils/instanceOf.js +1 -1
  39. package/jsutils/instanceOf.mjs +1 -1
  40. package/jsutils/invariant.js +1 -1
  41. package/jsutils/invariant.mjs +1 -1
  42. package/jsutils/isInvalid.js +1 -1
  43. package/jsutils/isInvalid.mjs +1 -1
  44. package/jsutils/isNullish.js +1 -1
  45. package/jsutils/isNullish.mjs +1 -1
  46. package/jsutils/isPromise.js +1 -1
  47. package/jsutils/isPromise.mjs +1 -1
  48. package/jsutils/keyMap.js +1 -1
  49. package/jsutils/keyMap.mjs +1 -1
  50. package/jsutils/keyValMap.js +1 -1
  51. package/jsutils/keyValMap.mjs +1 -1
  52. package/jsutils/mapValue.js +54 -0
  53. package/jsutils/mapValue.js.flow +27 -0
  54. package/jsutils/mapValue.mjs +44 -0
  55. package/jsutils/memoize3.js +1 -1
  56. package/jsutils/memoize3.mjs +1 -1
  57. package/jsutils/nodejsCustomInspectSymbol.js +18 -0
  58. package/jsutils/nodejsCustomInspectSymbol.js.flow +15 -0
  59. package/jsutils/nodejsCustomInspectSymbol.mjs +10 -0
  60. package/jsutils/orList.js +17 -4
  61. package/jsutils/orList.js.flow +13 -7
  62. package/jsutils/orList.mjs +14 -4
  63. package/jsutils/promiseForObject.js +1 -1
  64. package/jsutils/promiseForObject.mjs +1 -1
  65. package/jsutils/promiseReduce.js +1 -1
  66. package/jsutils/promiseReduce.mjs +1 -1
  67. package/jsutils/quotedOrList.js +1 -1
  68. package/jsutils/quotedOrList.mjs +1 -1
  69. package/jsutils/suggestionList.js +1 -1
  70. package/jsutils/suggestionList.mjs +1 -1
  71. package/language/blockStringValue.js +2 -2
  72. package/language/blockStringValue.js.flow +1 -1
  73. package/language/blockStringValue.mjs +2 -2
  74. package/language/directiveLocation.js +1 -1
  75. package/language/directiveLocation.mjs +1 -1
  76. package/language/index.mjs +1 -1
  77. package/language/kinds.js +1 -1
  78. package/language/kinds.mjs +1 -1
  79. package/language/lexer.js +29 -13
  80. package/language/lexer.js.flow +34 -20
  81. package/language/lexer.mjs +28 -13
  82. package/language/location.js +1 -1
  83. package/language/location.mjs +1 -1
  84. package/language/parser.js +31 -38
  85. package/language/parser.js.flow +32 -48
  86. package/language/parser.mjs +30 -38
  87. package/language/predicates.js +1 -1
  88. package/language/predicates.mjs +1 -1
  89. package/language/printer.js +13 -7
  90. package/language/printer.js.flow +19 -9
  91. package/language/printer.mjs +13 -7
  92. package/language/source.js +8 -7
  93. package/language/source.mjs +1 -9
  94. package/language/visitor.js +11 -20
  95. package/language/visitor.js.flow +4 -5
  96. package/language/visitor.mjs +8 -20
  97. package/package.json +10 -3
  98. package/polyfills/find.js +31 -0
  99. package/polyfills/find.js.flow +29 -0
  100. package/polyfills/find.mjs +23 -0
  101. package/{jsutils → polyfills}/isFinite.js +1 -1
  102. package/{jsutils → polyfills}/isFinite.js.flow +0 -0
  103. package/{jsutils → polyfills}/isFinite.mjs +1 -1
  104. package/{jsutils → polyfills}/isInteger.js +1 -1
  105. package/{jsutils → polyfills}/isInteger.js.flow +0 -0
  106. package/{jsutils → polyfills}/isInteger.mjs +1 -1
  107. package/polyfills/objectEntries.js +26 -0
  108. package/polyfills/objectEntries.js.flow +19 -0
  109. package/polyfills/objectEntries.mjs +18 -0
  110. package/{jsutils → polyfills}/objectValues.js +1 -1
  111. package/{jsutils → polyfills}/objectValues.js.flow +1 -1
  112. package/{jsutils → polyfills}/objectValues.mjs +1 -1
  113. package/subscription/asyncIteratorReject.mjs +1 -1
  114. package/subscription/index.mjs +1 -1
  115. package/subscription/mapAsyncIterator.mjs +1 -1
  116. package/subscription/subscribe.js +1 -1
  117. package/subscription/subscribe.js.flow +1 -1
  118. package/subscription/subscribe.mjs +2 -2
  119. package/type/definition.js +31 -130
  120. package/type/definition.js.flow +35 -47
  121. package/type/definition.mjs +30 -131
  122. package/type/directives.js +25 -29
  123. package/type/directives.js.flow +24 -20
  124. package/type/directives.mjs +22 -30
  125. package/type/index.js +12 -0
  126. package/type/index.js.flow +4 -0
  127. package/type/index.mjs +5 -3
  128. package/type/introspection.js +3 -3
  129. package/type/introspection.js.flow +1 -1
  130. package/type/introspection.mjs +2 -2
  131. package/type/scalars.js +45 -34
  132. package/type/scalars.js.flow +40 -26
  133. package/type/scalars.mjs +44 -26
  134. package/type/schema.js +82 -87
  135. package/type/schema.js.flow +17 -9
  136. package/type/schema.mjs +79 -86
  137. package/type/validate.js +168 -175
  138. package/type/validate.js.flow +8 -49
  139. package/type/validate.mjs +159 -175
  140. package/utilities/TypeInfo.js +10 -23
  141. package/utilities/TypeInfo.js.flow +1 -1
  142. package/utilities/TypeInfo.mjs +2 -24
  143. package/utilities/assertValidName.js +1 -1
  144. package/utilities/assertValidName.mjs +1 -1
  145. package/utilities/astFromValue.js +2 -2
  146. package/utilities/astFromValue.js.flow +1 -1
  147. package/utilities/astFromValue.mjs +2 -2
  148. package/utilities/buildASTSchema.js +169 -152
  149. package/utilities/buildASTSchema.js.flow +117 -113
  150. package/utilities/buildASTSchema.mjs +160 -152
  151. package/utilities/buildClientSchema.js +24 -14
  152. package/utilities/buildClientSchema.js.flow +24 -14
  153. package/utilities/buildClientSchema.mjs +23 -14
  154. package/utilities/coerceValue.js +38 -19
  155. package/utilities/coerceValue.js.flow +41 -47
  156. package/utilities/coerceValue.mjs +38 -20
  157. package/utilities/concatAST.js +1 -1
  158. package/utilities/concatAST.mjs +1 -1
  159. package/utilities/extendSchema.js +228 -312
  160. package/utilities/extendSchema.js.flow +27 -152
  161. package/utilities/extendSchema.mjs +229 -312
  162. package/utilities/findBreakingChanges.js +7 -5
  163. package/utilities/findBreakingChanges.js.flow +3 -2
  164. package/utilities/findBreakingChanges.mjs +6 -5
  165. package/utilities/findDeprecatedUsages.js +1 -1
  166. package/utilities/findDeprecatedUsages.mjs +1 -1
  167. package/utilities/getOperationAST.js +1 -1
  168. package/utilities/getOperationAST.mjs +1 -1
  169. package/utilities/getOperationRootType.js +1 -1
  170. package/utilities/getOperationRootType.mjs +1 -1
  171. package/utilities/index.mjs +1 -1
  172. package/utilities/introspectionFromSchema.js +1 -1
  173. package/utilities/introspectionFromSchema.mjs +1 -1
  174. package/utilities/introspectionQuery.js +1 -1
  175. package/utilities/introspectionQuery.mjs +1 -1
  176. package/utilities/isValidJSValue.js +1 -1
  177. package/utilities/isValidJSValue.mjs +1 -1
  178. package/utilities/isValidLiteralValue.js +1 -1
  179. package/utilities/isValidLiteralValue.mjs +1 -1
  180. package/utilities/lexicographicSortSchema.js +2 -2
  181. package/utilities/lexicographicSortSchema.js.flow +1 -1
  182. package/utilities/lexicographicSortSchema.mjs +2 -2
  183. package/utilities/schemaPrinter.js +3 -3
  184. package/utilities/schemaPrinter.js.flow +1 -1
  185. package/utilities/schemaPrinter.mjs +2 -2
  186. package/utilities/separateOperations.js +1 -1
  187. package/utilities/separateOperations.mjs +1 -1
  188. package/utilities/typeComparators.js +1 -1
  189. package/utilities/typeComparators.mjs +1 -1
  190. package/utilities/typeFromAST.js +1 -1
  191. package/utilities/typeFromAST.mjs +1 -1
  192. package/utilities/valueFromAST.js +3 -3
  193. package/utilities/valueFromAST.js.flow +1 -1
  194. package/utilities/valueFromAST.mjs +2 -2
  195. package/utilities/valueFromASTUntyped.js +1 -1
  196. package/utilities/valueFromASTUntyped.mjs +1 -1
  197. package/validation/ValidationContext.js +57 -82
  198. package/validation/ValidationContext.js.flow +52 -49
  199. package/validation/ValidationContext.mjs +52 -77
  200. package/validation/index.js.flow +1 -0
  201. package/validation/index.mjs +1 -1
  202. package/validation/rules/ExecutableDefinitions.js +1 -1
  203. package/validation/rules/ExecutableDefinitions.js.flow +1 -1
  204. package/validation/rules/ExecutableDefinitions.mjs +1 -1
  205. package/validation/rules/FieldsOnCorrectType.js +1 -1
  206. package/validation/rules/FieldsOnCorrectType.mjs +1 -1
  207. package/validation/rules/FragmentsOnCompositeTypes.js +1 -1
  208. package/validation/rules/FragmentsOnCompositeTypes.mjs +1 -1
  209. package/validation/rules/KnownArgumentNames.mjs +1 -1
  210. package/validation/rules/KnownDirectives.js +1 -1
  211. package/validation/rules/KnownDirectives.mjs +1 -1
  212. package/validation/rules/KnownFragmentNames.js +1 -1
  213. package/validation/rules/KnownFragmentNames.mjs +1 -1
  214. package/validation/rules/KnownTypeNames.js +59 -21
  215. package/validation/rules/KnownTypeNames.js.flow +54 -20
  216. package/validation/rules/KnownTypeNames.mjs +56 -21
  217. package/validation/rules/LoneAnonymousOperation.js +1 -1
  218. package/validation/rules/LoneAnonymousOperation.mjs +1 -1
  219. package/validation/rules/LoneSchemaDefinition.js +1 -1
  220. package/validation/rules/LoneSchemaDefinition.mjs +1 -1
  221. package/validation/rules/NoFragmentCycles.js +1 -1
  222. package/validation/rules/NoFragmentCycles.js.flow +2 -2
  223. package/validation/rules/NoFragmentCycles.mjs +1 -1
  224. package/validation/rules/NoUndefinedVariables.js +1 -1
  225. package/validation/rules/NoUndefinedVariables.mjs +1 -1
  226. package/validation/rules/NoUnusedFragments.js +1 -1
  227. package/validation/rules/NoUnusedFragments.js.flow +2 -2
  228. package/validation/rules/NoUnusedFragments.mjs +1 -1
  229. package/validation/rules/NoUnusedVariables.js +1 -1
  230. package/validation/rules/NoUnusedVariables.mjs +1 -1
  231. package/validation/rules/OverlappingFieldsCanBeMerged.js +57 -33
  232. package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +5 -6
  233. package/validation/rules/OverlappingFieldsCanBeMerged.mjs +48 -33
  234. package/validation/rules/PossibleFragmentSpreads.js +1 -1
  235. package/validation/rules/PossibleFragmentSpreads.mjs +1 -1
  236. package/validation/rules/PossibleTypeExtensions.js +158 -0
  237. package/validation/rules/PossibleTypeExtensions.js.flow +160 -0
  238. package/validation/rules/PossibleTypeExtensions.mjs +146 -0
  239. package/validation/rules/ProvidedRequiredArguments.mjs +1 -1
  240. package/validation/rules/ScalarLeafs.js +1 -1
  241. package/validation/rules/ScalarLeafs.mjs +1 -1
  242. package/validation/rules/SingleFieldSubscriptions.js +1 -1
  243. package/validation/rules/SingleFieldSubscriptions.mjs +1 -1
  244. package/validation/rules/UniqueArgumentNames.js +1 -1
  245. package/validation/rules/UniqueArgumentNames.mjs +1 -1
  246. package/validation/rules/UniqueDirectiveNames.js +55 -0
  247. package/validation/rules/UniqueDirectiveNames.js.flow +64 -0
  248. package/validation/rules/UniqueDirectiveNames.mjs +43 -0
  249. package/validation/rules/UniqueDirectivesPerLocation.js +1 -1
  250. package/validation/rules/UniqueDirectivesPerLocation.mjs +1 -1
  251. package/validation/rules/UniqueEnumValueNames.js +94 -0
  252. package/validation/rules/UniqueEnumValueNames.js.flow +87 -0
  253. package/validation/rules/UniqueEnumValueNames.mjs +81 -0
  254. package/validation/rules/UniqueFieldDefinitionNames.js +105 -0
  255. package/validation/rules/UniqueFieldDefinitionNames.js.flow +101 -0
  256. package/validation/rules/UniqueFieldDefinitionNames.mjs +92 -0
  257. package/validation/rules/UniqueFragmentNames.js +1 -1
  258. package/validation/rules/UniqueFragmentNames.mjs +1 -1
  259. package/validation/rules/UniqueInputFieldNames.js +1 -1
  260. package/validation/rules/UniqueInputFieldNames.mjs +1 -1
  261. package/validation/rules/UniqueOperationNames.js +1 -1
  262. package/validation/rules/UniqueOperationNames.mjs +1 -1
  263. package/validation/rules/UniqueOperationTypes.js +85 -0
  264. package/validation/rules/UniqueOperationTypes.js.flow +76 -0
  265. package/validation/rules/UniqueOperationTypes.mjs +73 -0
  266. package/validation/rules/UniqueTypeNames.js +62 -0
  267. package/validation/rules/UniqueTypeNames.js.flow +67 -0
  268. package/validation/rules/UniqueTypeNames.mjs +50 -0
  269. package/validation/rules/UniqueVariableNames.js +1 -1
  270. package/validation/rules/UniqueVariableNames.mjs +1 -1
  271. package/validation/rules/ValuesOfCorrectType.js +29 -13
  272. package/validation/rules/ValuesOfCorrectType.js.flow +4 -5
  273. package/validation/rules/ValuesOfCorrectType.mjs +28 -13
  274. package/validation/rules/VariablesAreInputTypes.js +1 -1
  275. package/validation/rules/VariablesAreInputTypes.mjs +1 -1
  276. package/validation/rules/VariablesInAllowedPosition.js +4 -4
  277. package/validation/rules/VariablesInAllowedPosition.mjs +4 -4
  278. package/validation/specifiedRules.js +14 -2
  279. package/validation/specifiedRules.js.flow +13 -0
  280. package/validation/specifiedRules.mjs +8 -2
  281. package/validation/validate.js +1 -1
  282. package/validation/validate.mjs +1 -1
  283. package/jsutils/find.js +0 -22
  284. package/jsutils/find.js.flow +0 -19
  285. 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
  }
@@ -229,38 +229,60 @@ function () {
229
229
  return this.buildType(typeNode);
230
230
  };
231
231
 
232
- _proto.buildDirective = function buildDirective(directiveNode) {
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: directiveNode.name.value,
235
- description: getDescription(directiveNode, this._options),
236
- locations: directiveNode.locations.map(function (node) {
237
- return node.value;
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
- args: directiveNode.arguments && this._makeInputValues(directiveNode.arguments),
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 && this._makeInputValues(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(def) {
280
- switch (def.kind) {
301
+ _proto._makeSchemaDef = function _makeSchemaDef(astNode) {
302
+ switch (astNode.kind) {
281
303
  case _kinds.Kind.OBJECT_TYPE_DEFINITION:
282
- return this._makeTypeDef(def);
304
+ return this._makeTypeDef(astNode);
283
305
 
284
306
  case _kinds.Kind.INTERFACE_TYPE_DEFINITION:
285
- return this._makeInterfaceDef(def);
307
+ return this._makeInterfaceDef(astNode);
286
308
 
287
309
  case _kinds.Kind.ENUM_TYPE_DEFINITION:
288
- return this._makeEnumDef(def);
310
+ return this._makeEnumDef(astNode);
289
311
 
290
312
  case _kinds.Kind.UNION_TYPE_DEFINITION:
291
- return this._makeUnionDef(def);
313
+ return this._makeUnionDef(astNode);
292
314
 
293
315
  case _kinds.Kind.SCALAR_TYPE_DEFINITION:
294
- return this._makeScalarDef(def);
316
+ return this._makeScalarDef(astNode);
295
317
 
296
318
  case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION:
297
- return this._makeInputObjectDef(def);
319
+ return this._makeInputObjectDef(astNode);
298
320
 
299
321
  default:
300
- throw new Error("Type kind \"".concat(def.kind, "\" not supported."));
322
+ throw new Error("Type kind \"".concat(astNode.kind, "\" not supported."));
301
323
  }
302
324
  };
303
325
 
304
- _proto._makeTypeDef = function _makeTypeDef(def) {
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
- return (0, _keyValMap.default)(values, function (value) {
340
- return value.name.value;
341
- }, function (value) {
342
- return _this3.buildInputField(value);
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(def) {
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: def.name.value,
351
- description: getDescription(def, this._options),
352
- fields: function fields() {
353
- return _this4._makeFieldDefMap(def);
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._makeValueDefMap = function _makeValueDefMap(def) {
370
+ _proto._makeEnumDef = function _makeEnumDef(astNode) {
369
371
  var _this5 = this;
370
372
 
371
- return def.values ? (0, _keyValMap.default)(def.values, function (enumValue) {
372
- return enumValue.name.value;
373
- }, function (enumValue) {
374
- return _this5.buildEnumValue(enumValue);
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(def) {
384
+ _proto._makeUnionDef = function _makeUnionDef(astNode) {
379
385
  var _this6 = this;
380
386
 
381
- var types = def.types;
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: def.name.value,
384
- description: getDescription(def, this._options),
385
- // Note: While this could make assertions to get the correctly typed
386
- // values below, that would throw immediately while type system
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(def) {
404
+ _proto._makeScalarDef = function _makeScalarDef(astNode) {
398
405
  return new _definition.GraphQLScalarType({
399
- name: def.name.value,
400
- description: getDescription(def, this._options),
401
- astNode: def,
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 fields() {
415
- return def.fields ? _this7._makeInputValues(def.fields) : {};
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;