graphql 14.1.1 → 14.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (377) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/error/GraphQLError.js +12 -10
  4. package/error/GraphQLError.js.flow +11 -6
  5. package/error/GraphQLError.mjs +20 -3
  6. package/error/formatError.js +2 -2
  7. package/error/formatError.js.flow +3 -3
  8. package/error/formatError.mjs +2 -2
  9. package/error/index.js +1 -1
  10. package/error/index.js.flow +5 -2
  11. package/error/index.mjs +2 -2
  12. package/error/locatedError.js +2 -2
  13. package/error/locatedError.js.flow +2 -2
  14. package/error/locatedError.mjs +2 -2
  15. package/error/printError.js +2 -2
  16. package/error/printError.js.flow +4 -5
  17. package/error/printError.mjs +2 -2
  18. package/error/syntaxError.js +2 -2
  19. package/error/syntaxError.js.flow +2 -2
  20. package/error/syntaxError.mjs +2 -2
  21. package/execution/execute.js +52 -37
  22. package/execution/execute.js.flow +66 -51
  23. package/execution/execute.mjs +50 -38
  24. package/execution/index.js +7 -1
  25. package/execution/index.js.flow +9 -4
  26. package/execution/index.mjs +3 -3
  27. package/execution/values.js +11 -11
  28. package/execution/values.js.flow +23 -19
  29. package/execution/values.mjs +11 -11
  30. package/graphql.js +13 -9
  31. package/graphql.js.flow +28 -10
  32. package/graphql.mjs +10 -9
  33. package/index.js +83 -53
  34. package/index.js.flow +60 -47
  35. package/index.mjs +26 -23
  36. package/jsutils/ObjMap.js +1 -1
  37. package/jsutils/ObjMap.js.flow +1 -1
  38. package/jsutils/ObjMap.mjs +1 -0
  39. package/jsutils/PromiseOrValue.js +1 -0
  40. package/jsutils/{MaybePromise.js.flow → PromiseOrValue.js.flow} +2 -2
  41. package/jsutils/PromiseOrValue.mjs +1 -0
  42. package/jsutils/dedent.js +2 -2
  43. package/jsutils/dedent.js.flow +1 -1
  44. package/jsutils/dedent.mjs +2 -2
  45. package/jsutils/defineToJSON.js +2 -2
  46. package/jsutils/defineToJSON.js.flow +1 -1
  47. package/jsutils/defineToJSON.mjs +2 -2
  48. package/jsutils/defineToStringTag.js +2 -2
  49. package/jsutils/defineToStringTag.js.flow +1 -1
  50. package/jsutils/defineToStringTag.mjs +2 -2
  51. package/jsutils/inspect.js +94 -19
  52. package/jsutils/inspect.js.flow +98 -20
  53. package/jsutils/inspect.mjs +94 -20
  54. package/jsutils/instanceOf.js +2 -2
  55. package/jsutils/instanceOf.js.flow +1 -1
  56. package/jsutils/instanceOf.mjs +2 -2
  57. package/jsutils/invariant.js +5 -3
  58. package/jsutils/invariant.js.flow +3 -2
  59. package/jsutils/invariant.mjs +5 -3
  60. package/jsutils/isInvalid.js +2 -2
  61. package/jsutils/isInvalid.js.flow +1 -1
  62. package/jsutils/isInvalid.mjs +2 -2
  63. package/jsutils/isNullish.js +2 -2
  64. package/jsutils/isNullish.js.flow +1 -1
  65. package/jsutils/isNullish.mjs +2 -2
  66. package/jsutils/isPromise.js +2 -2
  67. package/jsutils/isPromise.js.flow +1 -1
  68. package/jsutils/isPromise.mjs +2 -2
  69. package/jsutils/keyMap.js +4 -3
  70. package/jsutils/keyMap.js.flow +6 -6
  71. package/jsutils/keyMap.mjs +4 -3
  72. package/jsutils/keyValMap.js +4 -3
  73. package/jsutils/keyValMap.js.flow +6 -6
  74. package/jsutils/keyValMap.mjs +4 -3
  75. package/jsutils/mapValue.js +2 -2
  76. package/jsutils/mapValue.js.flow +2 -2
  77. package/jsutils/mapValue.mjs +2 -2
  78. package/jsutils/memoize3.js +3 -3
  79. package/jsutils/memoize3.js.flow +2 -2
  80. package/jsutils/memoize3.mjs +3 -3
  81. package/jsutils/nodejsCustomInspectSymbol.js +2 -2
  82. package/jsutils/nodejsCustomInspectSymbol.js.flow +1 -1
  83. package/jsutils/nodejsCustomInspectSymbol.mjs +2 -2
  84. package/jsutils/orList.js +2 -2
  85. package/jsutils/orList.js.flow +1 -1
  86. package/jsutils/orList.mjs +2 -2
  87. package/jsutils/promiseForObject.js +2 -2
  88. package/jsutils/promiseForObject.js.flow +2 -2
  89. package/jsutils/promiseForObject.mjs +2 -2
  90. package/jsutils/promiseReduce.js +2 -2
  91. package/jsutils/promiseReduce.js.flow +5 -5
  92. package/jsutils/promiseReduce.mjs +2 -2
  93. package/jsutils/quotedOrList.js +2 -2
  94. package/jsutils/quotedOrList.js.flow +1 -1
  95. package/jsutils/quotedOrList.mjs +2 -2
  96. package/jsutils/suggestionList.js +2 -2
  97. package/jsutils/suggestionList.js.flow +1 -1
  98. package/jsutils/suggestionList.mjs +2 -2
  99. package/language/ast.js +1 -1
  100. package/language/ast.js.flow +3 -3
  101. package/language/ast.mjs +1 -0
  102. package/language/blockString.js +114 -0
  103. package/language/blockString.js.flow +102 -0
  104. package/language/blockString.mjs +104 -0
  105. package/language/directiveLocation.js +2 -2
  106. package/language/directiveLocation.js.flow +1 -1
  107. package/language/directiveLocation.mjs +2 -2
  108. package/language/index.js +9 -9
  109. package/language/index.js.flow +10 -5
  110. package/language/index.mjs +3 -3
  111. package/language/kinds.js +2 -2
  112. package/language/kinds.js.flow +1 -1
  113. package/language/kinds.mjs +2 -2
  114. package/language/lexer.js +52 -44
  115. package/language/lexer.js.flow +65 -54
  116. package/language/lexer.mjs +49 -43
  117. package/language/location.js +2 -2
  118. package/language/location.js.flow +2 -2
  119. package/language/location.mjs +2 -2
  120. package/language/parser.js +75 -67
  121. package/language/parser.js.flow +138 -127
  122. package/language/parser.mjs +76 -68
  123. package/language/predicates.js +2 -2
  124. package/language/predicates.js.flow +2 -2
  125. package/language/predicates.mjs +2 -2
  126. package/language/printer.js +6 -14
  127. package/language/printer.js.flow +8 -17
  128. package/language/printer.mjs +5 -14
  129. package/language/source.js +2 -2
  130. package/language/source.js.flow +1 -1
  131. package/language/source.mjs +2 -2
  132. package/language/visitor.js +4 -6
  133. package/language/visitor.js.flow +3 -3
  134. package/language/visitor.mjs +4 -6
  135. package/package.json +1 -1
  136. package/polyfills/find.js +2 -2
  137. package/polyfills/find.js.flow +1 -1
  138. package/polyfills/find.mjs +2 -2
  139. package/polyfills/flatMap.js +38 -0
  140. package/polyfills/flatMap.js.flow +34 -0
  141. package/polyfills/flatMap.mjs +30 -0
  142. package/polyfills/isFinite.js +2 -2
  143. package/polyfills/isFinite.js.flow +1 -1
  144. package/polyfills/isFinite.mjs +2 -2
  145. package/polyfills/isInteger.js +2 -2
  146. package/polyfills/isInteger.js.flow +1 -1
  147. package/polyfills/isInteger.mjs +2 -2
  148. package/polyfills/objectEntries.js +2 -2
  149. package/polyfills/objectEntries.js.flow +2 -2
  150. package/polyfills/objectEntries.mjs +2 -2
  151. package/polyfills/objectValues.js +2 -2
  152. package/polyfills/objectValues.js.flow +2 -2
  153. package/polyfills/objectValues.mjs +2 -2
  154. package/subscription/asyncIteratorReject.js +1 -1
  155. package/subscription/asyncIteratorReject.js.flow +1 -1
  156. package/subscription/asyncIteratorReject.mjs +2 -2
  157. package/subscription/index.js +1 -1
  158. package/subscription/index.js.flow +1 -1
  159. package/subscription/index.mjs +2 -2
  160. package/subscription/mapAsyncIterator.js +1 -1
  161. package/subscription/mapAsyncIterator.js.flow +5 -5
  162. package/subscription/mapAsyncIterator.mjs +2 -2
  163. package/subscription/subscribe.js +2 -2
  164. package/subscription/subscribe.js.flow +6 -6
  165. package/subscription/subscribe.mjs +2 -2
  166. package/type/definition.js +138 -22
  167. package/type/definition.js.flow +184 -36
  168. package/type/definition.mjs +136 -23
  169. package/type/directives.js +14 -3
  170. package/type/directives.js.flow +24 -11
  171. package/type/directives.mjs +16 -5
  172. package/type/index.js +7 -7
  173. package/type/index.js.flow +8 -4
  174. package/type/index.mjs +10 -6
  175. package/type/introspection.js +14 -9
  176. package/type/introspection.js.flow +12 -18
  177. package/type/introspection.mjs +14 -9
  178. package/type/scalars.js +5 -4
  179. package/type/scalars.js.flow +4 -10
  180. package/type/scalars.mjs +7 -6
  181. package/type/schema.js +55 -3
  182. package/type/schema.js.flow +73 -17
  183. package/type/schema.mjs +56 -4
  184. package/type/validate.js +19 -47
  185. package/type/validate.js.flow +17 -29
  186. package/type/validate.mjs +18 -47
  187. package/utilities/TypeInfo.js +93 -73
  188. package/utilities/TypeInfo.js.flow +30 -23
  189. package/utilities/TypeInfo.mjs +93 -73
  190. package/utilities/assertValidName.js +2 -2
  191. package/utilities/assertValidName.js.flow +2 -2
  192. package/utilities/assertValidName.mjs +2 -2
  193. package/utilities/astFromValue.js +5 -4
  194. package/utilities/astFromValue.js.flow +8 -7
  195. package/utilities/astFromValue.mjs +7 -6
  196. package/utilities/buildASTSchema.js +63 -62
  197. package/utilities/buildASTSchema.js.flow +92 -108
  198. package/utilities/buildASTSchema.mjs +61 -62
  199. package/utilities/buildClientSchema.js +38 -45
  200. package/utilities/buildClientSchema.js.flow +66 -79
  201. package/utilities/buildClientSchema.mjs +37 -44
  202. package/utilities/coerceValue.js +6 -7
  203. package/utilities/coerceValue.js.flow +5 -4
  204. package/utilities/coerceValue.mjs +7 -8
  205. package/utilities/concatAST.js +9 -13
  206. package/utilities/concatAST.js.flow +4 -10
  207. package/utilities/concatAST.mjs +6 -13
  208. package/utilities/extendSchema.js +219 -511
  209. package/utilities/extendSchema.js.flow +195 -304
  210. package/utilities/extendSchema.mjs +218 -512
  211. package/utilities/findBreakingChanges.js +54 -95
  212. package/utilities/findBreakingChanges.js.flow +49 -47
  213. package/utilities/findBreakingChanges.mjs +80 -95
  214. package/utilities/findDeprecatedUsages.js +4 -4
  215. package/utilities/findDeprecatedUsages.js.flow +5 -5
  216. package/utilities/findDeprecatedUsages.mjs +4 -4
  217. package/utilities/getOperationAST.js +2 -2
  218. package/utilities/getOperationAST.js.flow +5 -2
  219. package/utilities/getOperationAST.mjs +2 -2
  220. package/utilities/getOperationRootType.js +24 -24
  221. package/utilities/getOperationRootType.js.flow +40 -35
  222. package/utilities/getOperationRootType.mjs +24 -24
  223. package/utilities/index.js +9 -1
  224. package/utilities/index.js.flow +13 -6
  225. package/utilities/index.mjs +13 -8
  226. package/utilities/introspectionFromSchema.js +6 -4
  227. package/utilities/introspectionFromSchema.js.flow +8 -7
  228. package/utilities/introspectionFromSchema.mjs +6 -5
  229. package/utilities/introspectionQuery.js +2 -2
  230. package/utilities/introspectionQuery.js.flow +2 -2
  231. package/utilities/introspectionQuery.mjs +2 -2
  232. package/utilities/isValidJSValue.js +4 -2
  233. package/utilities/isValidJSValue.js.flow +3 -2
  234. package/utilities/isValidJSValue.mjs +4 -2
  235. package/utilities/isValidLiteralValue.js +2 -2
  236. package/utilities/isValidLiteralValue.js.flow +4 -4
  237. package/utilities/isValidLiteralValue.mjs +2 -2
  238. package/utilities/lexicographicSortSchema.js +84 -123
  239. package/utilities/lexicographicSortSchema.js.flow +68 -96
  240. package/utilities/lexicographicSortSchema.mjs +84 -123
  241. package/utilities/schemaPrinter.js +47 -73
  242. package/utilities/schemaPrinter.js.flow +69 -120
  243. package/utilities/schemaPrinter.mjs +45 -72
  244. package/utilities/separateOperations.js +8 -12
  245. package/utilities/separateOperations.js.flow +6 -3
  246. package/utilities/separateOperations.mjs +8 -12
  247. package/utilities/stripIgnoredCharacters.js +140 -0
  248. package/utilities/stripIgnoredCharacters.js.flow +129 -0
  249. package/utilities/stripIgnoredCharacters.mjs +127 -0
  250. package/utilities/typeComparators.js +2 -2
  251. package/utilities/typeComparators.js.flow +4 -3
  252. package/utilities/typeComparators.mjs +2 -2
  253. package/utilities/typeFromAST.js +9 -4
  254. package/utilities/typeFromAST.js.flow +15 -9
  255. package/utilities/typeFromAST.mjs +6 -4
  256. package/utilities/valueFromAST.js +7 -4
  257. package/utilities/valueFromAST.js.flow +7 -5
  258. package/utilities/valueFromAST.mjs +6 -4
  259. package/utilities/valueFromASTUntyped.js +11 -6
  260. package/utilities/valueFromASTUntyped.js.flow +9 -5
  261. package/utilities/valueFromASTUntyped.mjs +10 -6
  262. package/validation/ValidationContext.js +1 -1
  263. package/validation/ValidationContext.js.flow +19 -20
  264. package/validation/ValidationContext.mjs +2 -2
  265. package/validation/index.js +1 -1
  266. package/validation/index.js.flow +2 -1
  267. package/validation/index.mjs +3 -2
  268. package/validation/rules/ExecutableDefinitions.js +3 -3
  269. package/validation/rules/ExecutableDefinitions.js.flow +4 -4
  270. package/validation/rules/ExecutableDefinitions.mjs +3 -3
  271. package/validation/rules/FieldsOnCorrectType.js +3 -3
  272. package/validation/rules/FieldsOnCorrectType.js.flow +7 -7
  273. package/validation/rules/FieldsOnCorrectType.mjs +3 -3
  274. package/validation/rules/FragmentsOnCompositeTypes.js +4 -4
  275. package/validation/rules/FragmentsOnCompositeTypes.js.flow +5 -5
  276. package/validation/rules/FragmentsOnCompositeTypes.mjs +4 -4
  277. package/validation/rules/KnownArgumentNames.js +1 -1
  278. package/validation/rules/KnownArgumentNames.js.flow +5 -5
  279. package/validation/rules/KnownArgumentNames.mjs +2 -2
  280. package/validation/rules/KnownDirectives.js +8 -6
  281. package/validation/rules/KnownDirectives.js.flow +11 -9
  282. package/validation/rules/KnownDirectives.mjs +8 -6
  283. package/validation/rules/KnownFragmentNames.js +3 -3
  284. package/validation/rules/KnownFragmentNames.js.flow +4 -4
  285. package/validation/rules/KnownFragmentNames.mjs +3 -3
  286. package/validation/rules/KnownTypeNames.js +2 -2
  287. package/validation/rules/KnownTypeNames.js.flow +6 -6
  288. package/validation/rules/KnownTypeNames.mjs +2 -2
  289. package/validation/rules/LoneAnonymousOperation.js +3 -3
  290. package/validation/rules/LoneAnonymousOperation.js.flow +4 -4
  291. package/validation/rules/LoneAnonymousOperation.mjs +3 -3
  292. package/validation/rules/LoneSchemaDefinition.js +2 -2
  293. package/validation/rules/LoneSchemaDefinition.js.flow +3 -3
  294. package/validation/rules/LoneSchemaDefinition.mjs +2 -2
  295. package/validation/rules/NoFragmentCycles.js +2 -2
  296. package/validation/rules/NoFragmentCycles.js.flow +4 -4
  297. package/validation/rules/NoFragmentCycles.mjs +2 -2
  298. package/validation/rules/NoUndefinedVariables.js +2 -2
  299. package/validation/rules/NoUndefinedVariables.js.flow +3 -3
  300. package/validation/rules/NoUndefinedVariables.mjs +2 -2
  301. package/validation/rules/NoUnusedFragments.js +7 -7
  302. package/validation/rules/NoUnusedFragments.js.flow +4 -4
  303. package/validation/rules/NoUnusedFragments.mjs +7 -7
  304. package/validation/rules/NoUnusedVariables.js +5 -5
  305. package/validation/rules/NoUnusedVariables.js.flow +6 -5
  306. package/validation/rules/NoUnusedVariables.mjs +5 -5
  307. package/validation/rules/OverlappingFieldsCanBeMerged.js +26 -23
  308. package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +17 -17
  309. package/validation/rules/OverlappingFieldsCanBeMerged.mjs +26 -23
  310. package/validation/rules/PossibleFragmentSpreads.js +4 -4
  311. package/validation/rules/PossibleFragmentSpreads.js.flow +5 -5
  312. package/validation/rules/PossibleFragmentSpreads.mjs +4 -4
  313. package/validation/rules/PossibleTypeExtensions.js +3 -3
  314. package/validation/rules/PossibleTypeExtensions.js.flow +5 -5
  315. package/validation/rules/PossibleTypeExtensions.mjs +4 -4
  316. package/validation/rules/ProvidedRequiredArguments.js +6 -8
  317. package/validation/rules/ProvidedRequiredArguments.js.flow +8 -8
  318. package/validation/rules/ProvidedRequiredArguments.mjs +7 -9
  319. package/validation/rules/ScalarLeafs.js +4 -4
  320. package/validation/rules/ScalarLeafs.js.flow +6 -6
  321. package/validation/rules/ScalarLeafs.mjs +4 -4
  322. package/validation/rules/SingleFieldSubscriptions.js +2 -2
  323. package/validation/rules/SingleFieldSubscriptions.js.flow +4 -4
  324. package/validation/rules/SingleFieldSubscriptions.mjs +2 -2
  325. package/validation/rules/UniqueArgumentNames.js +2 -2
  326. package/validation/rules/UniqueArgumentNames.js.flow +3 -3
  327. package/validation/rules/UniqueArgumentNames.mjs +2 -2
  328. package/validation/rules/UniqueDirectiveNames.js +2 -2
  329. package/validation/rules/UniqueDirectiveNames.js.flow +3 -3
  330. package/validation/rules/UniqueDirectiveNames.mjs +2 -2
  331. package/validation/rules/UniqueDirectivesPerLocation.js +3 -2
  332. package/validation/rules/UniqueDirectivesPerLocation.js.flow +4 -4
  333. package/validation/rules/UniqueDirectivesPerLocation.mjs +3 -2
  334. package/validation/rules/UniqueEnumValueNames.js +4 -8
  335. package/validation/rules/UniqueEnumValueNames.js.flow +6 -8
  336. package/validation/rules/UniqueEnumValueNames.mjs +4 -8
  337. package/validation/rules/UniqueFieldDefinitionNames.js +4 -8
  338. package/validation/rules/UniqueFieldDefinitionNames.js.flow +6 -8
  339. package/validation/rules/UniqueFieldDefinitionNames.mjs +4 -8
  340. package/validation/rules/UniqueFragmentNames.js +2 -2
  341. package/validation/rules/UniqueFragmentNames.js.flow +3 -3
  342. package/validation/rules/UniqueFragmentNames.mjs +2 -2
  343. package/validation/rules/UniqueInputFieldNames.js +2 -4
  344. package/validation/rules/UniqueInputFieldNames.js.flow +3 -4
  345. package/validation/rules/UniqueInputFieldNames.mjs +2 -4
  346. package/validation/rules/UniqueOperationNames.js +2 -2
  347. package/validation/rules/UniqueOperationNames.js.flow +3 -3
  348. package/validation/rules/UniqueOperationNames.mjs +2 -2
  349. package/validation/rules/UniqueOperationTypes.js +2 -2
  350. package/validation/rules/UniqueOperationTypes.js.flow +3 -3
  351. package/validation/rules/UniqueOperationTypes.mjs +2 -2
  352. package/validation/rules/UniqueTypeNames.js +2 -2
  353. package/validation/rules/UniqueTypeNames.js.flow +4 -4
  354. package/validation/rules/UniqueTypeNames.mjs +2 -2
  355. package/validation/rules/UniqueVariableNames.js +2 -2
  356. package/validation/rules/UniqueVariableNames.js.flow +4 -4
  357. package/validation/rules/UniqueVariableNames.mjs +2 -2
  358. package/validation/rules/ValuesOfCorrectType.js +2 -2
  359. package/validation/rules/ValuesOfCorrectType.js.flow +5 -5
  360. package/validation/rules/ValuesOfCorrectType.mjs +2 -2
  361. package/validation/rules/VariablesAreInputTypes.js +3 -3
  362. package/validation/rules/VariablesAreInputTypes.js.flow +5 -5
  363. package/validation/rules/VariablesAreInputTypes.mjs +3 -3
  364. package/validation/rules/VariablesInAllowedPosition.js +3 -3
  365. package/validation/rules/VariablesInAllowedPosition.js.flow +7 -8
  366. package/validation/rules/VariablesInAllowedPosition.mjs +3 -3
  367. package/validation/specifiedRules.js +2 -2
  368. package/validation/specifiedRules.js.flow +13 -6
  369. package/validation/specifiedRules.mjs +7 -7
  370. package/validation/validate.js +2 -2
  371. package/validation/validate.js.flow +10 -6
  372. package/validation/validate.mjs +2 -2
  373. package/jsutils/MaybePromise.js +0 -1
  374. package/jsutils/MaybePromise.mjs +0 -0
  375. package/language/blockStringValue.js +0 -73
  376. package/language/blockStringValue.js.flow +0 -64
  377. package/language/blockStringValue.mjs +0 -66
@@ -10,6 +10,8 @@ exports.ASTDefinitionBuilder = void 0;
10
10
 
11
11
  var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
12
12
 
13
+ var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
14
+
13
15
  var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
14
16
 
15
17
  var _keyMap = _interopRequireDefault(require("../jsutils/keyMap"));
@@ -20,7 +22,7 @@ var _valueFromAST = require("./valueFromAST");
20
22
 
21
23
  var _validate = require("../validation/validate");
22
24
 
23
- var _blockStringValue = _interopRequireDefault(require("../language/blockStringValue"));
25
+ var _blockString = require("../language/blockString");
24
26
 
25
27
  var _lexer = require("../language/lexer");
26
28
 
@@ -45,7 +47,7 @@ var _schema = require("../type/schema");
45
47
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
46
48
 
47
49
  /**
48
- * Copyright (c) 2015-present, Facebook, Inc.
50
+ * Copyright (c) Facebook, Inc. and its affiliates.
49
51
  *
50
52
  * This source code is licensed under the MIT license found in the
51
53
  * LICENSE file in the root directory of this source tree.
@@ -77,7 +79,7 @@ function buildASTSchema(documentAST, options) {
77
79
  }
78
80
 
79
81
  var schemaDef;
80
- var nodeMap = Object.create(null);
82
+ var typeDefs = [];
81
83
  var directiveDefs = [];
82
84
  var _iteratorNormalCompletion = true;
83
85
  var _didIteratorError = false;
@@ -90,7 +92,7 @@ function buildASTSchema(documentAST, options) {
90
92
  if (def.kind === _kinds.Kind.SCHEMA_DEFINITION) {
91
93
  schemaDef = def;
92
94
  } else if ((0, _predicates.isTypeDefinitionNode)(def)) {
93
- nodeMap[def.name.value] = def;
95
+ typeDefs.push(def);
94
96
  } else if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
95
97
  directiveDefs.push(def);
96
98
  }
@@ -110,16 +112,21 @@ function buildASTSchema(documentAST, options) {
110
112
  }
111
113
  }
112
114
 
115
+ var astBuilder = new ASTDefinitionBuilder(options, function (typeName) {
116
+ var type = typeMap[typeName];
117
+ !type ? (0, _invariant.default)(0, "Type \"".concat(typeName, "\" not found in document.")) : void 0;
118
+ return type;
119
+ });
120
+ var typeMap = keyByNameNode(typeDefs, function (node) {
121
+ return astBuilder.buildType(node);
122
+ });
113
123
  var operationTypes = schemaDef ? getOperationTypes(schemaDef) : {
114
- query: nodeMap.Query,
115
- mutation: nodeMap.Mutation,
116
- subscription: nodeMap.Subscription
124
+ query: 'Query',
125
+ mutation: 'Mutation',
126
+ subscription: 'Subscription'
117
127
  };
118
- var definitionBuilder = new ASTDefinitionBuilder(nodeMap, options, function (typeName) {
119
- throw new Error("Type \"".concat(typeName, "\" not found in document."));
120
- });
121
128
  var directives = directiveDefs.map(function (def) {
122
- return definitionBuilder.buildDirective(def);
129
+ return astBuilder.buildDirective(def);
123
130
  }); // If specified directives were not explicitly declared, add them.
124
131
 
125
132
  if (!directives.some(function (directive) {
@@ -138,18 +145,16 @@ function buildASTSchema(documentAST, options) {
138
145
  return directive.name === 'deprecated';
139
146
  })) {
140
147
  directives.push(_directives.GraphQLDeprecatedDirective);
141
- } // Note: While this could make early assertions to get the correctly
142
- // typed values below, that would throw immediately while type system
143
- // validation with validateSchema() will produce more actionable results.
144
-
148
+ }
145
149
 
146
150
  return new _schema.GraphQLSchema({
147
- query: operationTypes.query ? definitionBuilder.buildType(operationTypes.query) : null,
148
- mutation: operationTypes.mutation ? definitionBuilder.buildType(operationTypes.mutation) : null,
149
- subscription: operationTypes.subscription ? definitionBuilder.buildType(operationTypes.subscription) : null,
150
- types: (0, _objectValues.default)(nodeMap).map(function (node) {
151
- return definitionBuilder.buildType(node);
152
- }),
151
+ // Note: While this could make early assertions to get the correctly
152
+ // typed values below, that would throw immediately while type system
153
+ // validation with validateSchema() will produce more actionable results.
154
+ query: operationTypes.query ? typeMap[operationTypes.query] : null,
155
+ mutation: operationTypes.mutation ? typeMap[operationTypes.mutation] : null,
156
+ subscription: operationTypes.subscription ? typeMap[operationTypes.subscription] : null,
157
+ types: (0, _objectValues.default)(typeMap),
153
158
  directives: directives,
154
159
  astNode: schemaDef,
155
160
  assumeValid: options && options.assumeValid,
@@ -165,7 +170,7 @@ function buildASTSchema(documentAST, options) {
165
170
  try {
166
171
  for (var _iterator2 = schema.operationTypes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
167
172
  var operationType = _step2.value;
168
- opTypes[operationType.operation] = operationType.type;
173
+ opTypes[operationType.operation] = operationType.type.name.value;
169
174
  }
170
175
  } catch (err) {
171
176
  _didIteratorError2 = true;
@@ -186,47 +191,35 @@ function buildASTSchema(documentAST, options) {
186
191
  }
187
192
  }
188
193
 
194
+ var stdTypeMap = (0, _keyMap.default)(_scalars.specifiedScalarTypes.concat(_introspection.introspectionTypes), function (type) {
195
+ return type.name;
196
+ });
197
+
189
198
  var ASTDefinitionBuilder =
190
199
  /*#__PURE__*/
191
200
  function () {
192
- function ASTDefinitionBuilder(typeDefinitionsMap, options, resolveType) {
193
- this._typeDefinitionsMap = typeDefinitionsMap;
201
+ function ASTDefinitionBuilder(options, resolveType) {
194
202
  this._options = options;
195
- this._resolveType = resolveType; // Initialize to the GraphQL built in scalars and introspection types.
196
-
197
- this._cache = (0, _keyMap.default)(_scalars.specifiedScalarTypes.concat(_introspection.introspectionTypes), function (type) {
198
- return type.name;
199
- });
203
+ this._resolveType = resolveType;
200
204
  }
201
205
 
202
206
  var _proto = ASTDefinitionBuilder.prototype;
203
207
 
204
- _proto.buildType = function buildType(node) {
205
- var typeName = node.name.value;
206
-
207
- if (!this._cache[typeName]) {
208
- if (node.kind === _kinds.Kind.NAMED_TYPE) {
209
- var defNode = this._typeDefinitionsMap[typeName];
210
- this._cache[typeName] = defNode ? this._makeSchemaDef(defNode) : this._resolveType(node.name.value);
211
- } else {
212
- this._cache[typeName] = this._makeSchemaDef(node);
213
- }
214
- }
215
-
216
- return this._cache[typeName];
208
+ _proto.getNamedType = function getNamedType(node) {
209
+ var name = node.name.value;
210
+ return stdTypeMap[name] || this._resolveType(name);
217
211
  };
218
212
 
219
- _proto._buildWrappedType = function _buildWrappedType(typeNode) {
220
- if (typeNode.kind === _kinds.Kind.LIST_TYPE) {
221
- return (0, _definition.GraphQLList)(this._buildWrappedType(typeNode.type));
213
+ _proto.getWrappedType = function getWrappedType(node) {
214
+ if (node.kind === _kinds.Kind.LIST_TYPE) {
215
+ return new _definition.GraphQLList(this.getWrappedType(node.type));
222
216
  }
223
217
 
224
- if (typeNode.kind === _kinds.Kind.NON_NULL_TYPE) {
225
- return (0, _definition.GraphQLNonNull)( // Note: GraphQLNonNull constructor validates this type
226
- this._buildWrappedType(typeNode.type));
218
+ if (node.kind === _kinds.Kind.NON_NULL_TYPE) {
219
+ return new _definition.GraphQLNonNull(this.getWrappedType(node.type));
227
220
  }
228
221
 
229
- return this.buildType(typeNode);
222
+ return this.getNamedType(node);
230
223
  };
231
224
 
232
225
  _proto.buildDirective = function buildDirective(directive) {
@@ -254,7 +247,7 @@ function () {
254
247
  // Note: While this could make assertions to get the correctly typed
255
248
  // value, that would throw immediately while type system validation
256
249
  // with validateSchema() will produce more actionable results.
257
- type: this._buildWrappedType(field.type),
250
+ type: this.getWrappedType(field.type),
258
251
  description: getDescription(field, this._options),
259
252
  args: keyByNameNode(field.arguments || [], function (arg) {
260
253
  return _this2.buildArg(arg);
@@ -267,8 +260,8 @@ function () {
267
260
  _proto.buildArg = function buildArg(value) {
268
261
  // Note: While this could make assertions to get the correctly typed
269
262
  // value, that would throw immediately while type system validation
270
- var type = this._buildWrappedType(value.type);
271
-
263
+ // with validateSchema() will produce more actionable results.
264
+ var type = this.getWrappedType(value.type);
272
265
  return {
273
266
  type: type,
274
267
  description: getDescription(value, this._options),
@@ -280,8 +273,8 @@ function () {
280
273
  _proto.buildInputField = function buildInputField(value) {
281
274
  // Note: While this could make assertions to get the correctly typed
282
275
  // value, that would throw immediately while type system validation
283
- var type = this._buildWrappedType(value.type);
284
-
276
+ // with validateSchema() will produce more actionable results.
277
+ var type = this.getWrappedType(value.type);
285
278
  return {
286
279
  type: type,
287
280
  description: getDescription(value, this._options),
@@ -298,7 +291,13 @@ function () {
298
291
  };
299
292
  };
300
293
 
301
- _proto._makeSchemaDef = function _makeSchemaDef(astNode) {
294
+ _proto.buildType = function buildType(astNode) {
295
+ var name = astNode.name.value;
296
+
297
+ if (stdTypeMap[name]) {
298
+ return stdTypeMap[name];
299
+ }
300
+
302
301
  switch (astNode.kind) {
303
302
  case _kinds.Kind.OBJECT_TYPE_DEFINITION:
304
303
  return this._makeTypeDef(astNode);
@@ -317,10 +316,12 @@ function () {
317
316
 
318
317
  case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION:
319
318
  return this._makeInputObjectDef(astNode);
319
+ } // Not reachable. All possible type definition nodes have been considered.
320
320
 
321
- default:
322
- throw new Error("Type kind \"".concat(astNode.kind, "\" not supported."));
323
- }
321
+ /* istanbul ignore next */
322
+
323
+
324
+ throw new Error("Unexpected type definition node: \"".concat((0, _inspect.default)(astNode), "\"."));
324
325
  };
325
326
 
326
327
  _proto._makeTypeDef = function _makeTypeDef(astNode) {
@@ -333,7 +334,7 @@ function () {
333
334
 
334
335
  var interfaces = interfaceNodes && interfaceNodes.length > 0 ? function () {
335
336
  return interfaceNodes.map(function (ref) {
336
- return _this3.buildType(ref);
337
+ return _this3.getNamedType(ref);
337
338
  });
338
339
  } : [];
339
340
  var fields = fieldNodes && fieldNodes.length > 0 ? function () {
@@ -390,7 +391,7 @@ function () {
390
391
 
391
392
  var types = typeNodes && typeNodes.length > 0 ? function () {
392
393
  return typeNodes.map(function (ref) {
393
- return _this6.buildType(ref);
394
+ return _this6.getNamedType(ref);
394
395
  });
395
396
  } : [];
396
397
  return new _definition.GraphQLUnionType({
@@ -470,7 +471,7 @@ function getDescription(node, options) {
470
471
  var rawValue = getLeadingCommentBlock(node);
471
472
 
472
473
  if (rawValue !== undefined) {
473
- return (0, _blockStringValue.default)('\n' + rawValue);
474
+ return (0, _blockString.dedentBlockStringValue)('\n' + rawValue);
474
475
  }
475
476
  }
476
477
  }
@@ -501,4 +502,4 @@ function getLeadingCommentBlock(node) {
501
502
 
502
503
  function buildSchema(source, options) {
503
504
  return buildASTSchema((0, _parser.parse)(source, options), options);
504
- }
505
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -8,54 +8,51 @@
8
8
  */
9
9
 
10
10
  import objectValues from '../polyfills/objectValues';
11
+ import inspect from '../jsutils/inspect';
11
12
  import invariant from '../jsutils/invariant';
12
13
  import keyMap from '../jsutils/keyMap';
13
14
  import keyValMap from '../jsutils/keyValMap';
14
- import type { ObjMap } from '../jsutils/ObjMap';
15
+ import { type ObjMap } from '../jsutils/ObjMap';
15
16
  import { valueFromAST } from './valueFromAST';
16
17
  import { assertValidSDL } from '../validation/validate';
17
- import blockStringValue from '../language/blockStringValue';
18
+ import { dedentBlockStringValue } from '../language/blockString';
18
19
  import { TokenKind } from '../language/lexer';
19
- import { parse } from '../language/parser';
20
- import type { ParseOptions } from '../language/parser';
21
- import type { Source } from '../language/source';
20
+ import { type ParseOptions, parse } from '../language/parser';
21
+ import { type Source } from '../language/source';
22
22
  import { getDirectiveValues } from '../execution/values';
23
23
  import { Kind } from '../language/kinds';
24
24
 
25
- import type {
26
- DocumentNode,
27
- NameNode,
28
- TypeNode,
29
- NamedTypeNode,
30
- SchemaDefinitionNode,
31
- TypeDefinitionNode,
32
- ScalarTypeDefinitionNode,
33
- ObjectTypeDefinitionNode,
34
- FieldDefinitionNode,
35
- InputValueDefinitionNode,
36
- InterfaceTypeDefinitionNode,
37
- UnionTypeDefinitionNode,
38
- EnumTypeDefinitionNode,
39
- EnumValueDefinitionNode,
40
- InputObjectTypeDefinitionNode,
41
- DirectiveDefinitionNode,
42
- StringValueNode,
43
- Location,
25
+ import {
26
+ type DocumentNode,
27
+ type NameNode,
28
+ type TypeNode,
29
+ type NamedTypeNode,
30
+ type SchemaDefinitionNode,
31
+ type TypeDefinitionNode,
32
+ type ScalarTypeDefinitionNode,
33
+ type ObjectTypeDefinitionNode,
34
+ type FieldDefinitionNode,
35
+ type InputValueDefinitionNode,
36
+ type InterfaceTypeDefinitionNode,
37
+ type UnionTypeDefinitionNode,
38
+ type EnumTypeDefinitionNode,
39
+ type EnumValueDefinitionNode,
40
+ type InputObjectTypeDefinitionNode,
41
+ type DirectiveDefinitionNode,
42
+ type StringValueNode,
43
+ type Location,
44
44
  } from '../language/ast';
45
45
  import { isTypeDefinitionNode } from '../language/predicates';
46
46
 
47
- import type { DirectiveLocationEnum } from '../language/directiveLocation';
48
-
49
- import type {
50
- GraphQLType,
51
- GraphQLNamedType,
52
- GraphQLFieldConfig,
53
- GraphQLArgumentConfig,
54
- GraphQLEnumValueConfig,
55
- GraphQLInputFieldConfig,
56
- } from '../type/definition';
47
+ import { type DirectiveLocationEnum } from '../language/directiveLocation';
57
48
 
58
49
  import {
50
+ type GraphQLType,
51
+ type GraphQLNamedType,
52
+ type GraphQLFieldConfig,
53
+ type GraphQLArgumentConfig,
54
+ type GraphQLEnumValueConfig,
55
+ type GraphQLInputFieldConfig,
59
56
  GraphQLScalarType,
60
57
  GraphQLObjectType,
61
58
  GraphQLInterfaceType,
@@ -77,8 +74,10 @@ import { introspectionTypes } from '../type/introspection';
77
74
 
78
75
  import { specifiedScalarTypes } from '../type/scalars';
79
76
 
80
- import { GraphQLSchema } from '../type/schema';
81
- import type { GraphQLSchemaValidationOptions } from '../type/schema';
77
+ import {
78
+ type GraphQLSchemaValidationOptions,
79
+ GraphQLSchema,
80
+ } from '../type/schema';
82
81
 
83
82
  export type BuildSchemaOptions = {
84
83
  ...GraphQLSchemaValidationOptions,
@@ -131,38 +130,36 @@ export function buildASTSchema(
131
130
  }
132
131
 
133
132
  let schemaDef: ?SchemaDefinitionNode;
134
- const nodeMap: ObjMap<TypeDefinitionNode> = Object.create(null);
133
+ const typeDefs: Array<TypeDefinitionNode> = [];
135
134
  const directiveDefs: Array<DirectiveDefinitionNode> = [];
136
135
 
137
136
  for (const def of documentAST.definitions) {
138
137
  if (def.kind === Kind.SCHEMA_DEFINITION) {
139
138
  schemaDef = def;
140
139
  } else if (isTypeDefinitionNode(def)) {
141
- nodeMap[def.name.value] = def;
140
+ typeDefs.push(def);
142
141
  } else if (def.kind === Kind.DIRECTIVE_DEFINITION) {
143
142
  directiveDefs.push(def);
144
143
  }
145
144
  }
146
145
 
146
+ const astBuilder = new ASTDefinitionBuilder(options, typeName => {
147
+ const type = typeMap[typeName];
148
+ invariant(type, `Type "${typeName}" not found in document.`);
149
+ return type;
150
+ });
151
+
152
+ const typeMap = keyByNameNode(typeDefs, node => astBuilder.buildType(node));
153
+
147
154
  const operationTypes = schemaDef
148
155
  ? getOperationTypes(schemaDef)
149
156
  : {
150
- query: nodeMap.Query,
151
- mutation: nodeMap.Mutation,
152
- subscription: nodeMap.Subscription,
157
+ query: 'Query',
158
+ mutation: 'Mutation',
159
+ subscription: 'Subscription',
153
160
  };
154
161
 
155
- const definitionBuilder = new ASTDefinitionBuilder(
156
- nodeMap,
157
- options,
158
- typeName => {
159
- throw new Error(`Type "${typeName}" not found in document.`);
160
- },
161
- );
162
-
163
- const directives = directiveDefs.map(def =>
164
- definitionBuilder.buildDirective(def),
165
- );
162
+ const directives = directiveDefs.map(def => astBuilder.buildDirective(def));
166
163
 
167
164
  // If specified directives were not explicitly declared, add them.
168
165
  if (!directives.some(directive => directive.name === 'skip')) {
@@ -177,20 +174,19 @@ export function buildASTSchema(
177
174
  directives.push(GraphQLDeprecatedDirective);
178
175
  }
179
176
 
180
- // Note: While this could make early assertions to get the correctly
181
- // typed values below, that would throw immediately while type system
182
- // validation with validateSchema() will produce more actionable results.
183
177
  return new GraphQLSchema({
184
- query: operationTypes.query
185
- ? (definitionBuilder.buildType(operationTypes.query): any)
186
- : null,
178
+ // Note: While this could make early assertions to get the correctly
179
+ // typed values below, that would throw immediately while type system
180
+ // validation with validateSchema() will produce more actionable results.
181
+ query: operationTypes.query ? (typeMap[operationTypes.query]: any) : null,
187
182
  mutation: operationTypes.mutation
188
- ? (definitionBuilder.buildType(operationTypes.mutation): any)
183
+ ? (typeMap[operationTypes.mutation]: any)
189
184
  : null,
190
185
  subscription: operationTypes.subscription
191
- ? (definitionBuilder.buildType(operationTypes.subscription): any)
186
+ ? (typeMap[operationTypes.subscription]: any)
192
187
  : null,
193
- types: objectValues(nodeMap).map(node => definitionBuilder.buildType(node)),
188
+
189
+ types: objectValues(typeMap),
194
190
  directives,
195
191
  astNode: schemaDef,
196
192
  assumeValid: options && options.assumeValid,
@@ -200,62 +196,41 @@ export function buildASTSchema(
200
196
  function getOperationTypes(schema: SchemaDefinitionNode) {
201
197
  const opTypes = {};
202
198
  for (const operationType of schema.operationTypes) {
203
- opTypes[operationType.operation] = operationType.type;
199
+ opTypes[operationType.operation] = operationType.type.name.value;
204
200
  }
205
201
  return opTypes;
206
202
  }
207
203
  }
208
204
 
209
- type TypeDefinitionsMap = ObjMap<TypeDefinitionNode>;
210
205
  type TypeResolver = (typeName: string) => GraphQLNamedType;
211
206
 
207
+ const stdTypeMap = keyMap(
208
+ specifiedScalarTypes.concat(introspectionTypes),
209
+ type => type.name,
210
+ );
211
+
212
212
  export class ASTDefinitionBuilder {
213
- _typeDefinitionsMap: TypeDefinitionsMap;
214
213
  _options: ?BuildSchemaOptions;
215
214
  _resolveType: TypeResolver;
216
- _cache: ObjMap<GraphQLNamedType>;
217
215
 
218
- constructor(
219
- typeDefinitionsMap: TypeDefinitionsMap,
220
- options: ?BuildSchemaOptions,
221
- resolveType: TypeResolver,
222
- ) {
223
- this._typeDefinitionsMap = typeDefinitionsMap;
216
+ constructor(options: ?BuildSchemaOptions, resolveType: TypeResolver) {
224
217
  this._options = options;
225
218
  this._resolveType = resolveType;
226
- // Initialize to the GraphQL built in scalars and introspection types.
227
- this._cache = keyMap(
228
- specifiedScalarTypes.concat(introspectionTypes),
229
- type => type.name,
230
- );
231
219
  }
232
220
 
233
- buildType(node: NamedTypeNode | TypeDefinitionNode): GraphQLNamedType {
234
- const typeName = node.name.value;
235
- if (!this._cache[typeName]) {
236
- if (node.kind === Kind.NAMED_TYPE) {
237
- const defNode = this._typeDefinitionsMap[typeName];
238
- this._cache[typeName] = defNode
239
- ? this._makeSchemaDef(defNode)
240
- : this._resolveType(node.name.value);
241
- } else {
242
- this._cache[typeName] = this._makeSchemaDef(node);
243
- }
244
- }
245
- return this._cache[typeName];
221
+ getNamedType(node: NamedTypeNode): GraphQLNamedType {
222
+ const name = node.name.value;
223
+ return stdTypeMap[name] || this._resolveType(name);
246
224
  }
247
225
 
248
- _buildWrappedType(typeNode: TypeNode): GraphQLType {
249
- if (typeNode.kind === Kind.LIST_TYPE) {
250
- return GraphQLList(this._buildWrappedType(typeNode.type));
226
+ getWrappedType(node: TypeNode): GraphQLType {
227
+ if (node.kind === Kind.LIST_TYPE) {
228
+ return new GraphQLList(this.getWrappedType(node.type));
251
229
  }
252
- if (typeNode.kind === Kind.NON_NULL_TYPE) {
253
- return GraphQLNonNull(
254
- // Note: GraphQLNonNull constructor validates this type
255
- (this._buildWrappedType(typeNode.type): any),
256
- );
230
+ if (node.kind === Kind.NON_NULL_TYPE) {
231
+ return new GraphQLNonNull(this.getWrappedType(node.type));
257
232
  }
258
- return this.buildType(typeNode);
233
+ return this.getNamedType(node);
259
234
  }
260
235
 
261
236
  buildDirective(directive: DirectiveDefinitionNode): GraphQLDirective {
@@ -277,7 +252,7 @@ export class ASTDefinitionBuilder {
277
252
  // Note: While this could make assertions to get the correctly typed
278
253
  // value, that would throw immediately while type system validation
279
254
  // with validateSchema() will produce more actionable results.
280
- type: (this._buildWrappedType(field.type): any),
255
+ type: (this.getWrappedType(field.type): any),
281
256
  description: getDescription(field, this._options),
282
257
  args: keyByNameNode(field.arguments || [], arg => this.buildArg(arg)),
283
258
  deprecationReason: getDeprecationReason(field),
@@ -289,7 +264,7 @@ export class ASTDefinitionBuilder {
289
264
  // Note: While this could make assertions to get the correctly typed
290
265
  // value, that would throw immediately while type system validation
291
266
  // with validateSchema() will produce more actionable results.
292
- const type: any = this._buildWrappedType(value.type);
267
+ const type: any = this.getWrappedType(value.type);
293
268
  return {
294
269
  type,
295
270
  description: getDescription(value, this._options),
@@ -302,7 +277,7 @@ export class ASTDefinitionBuilder {
302
277
  // Note: While this could make assertions to get the correctly typed
303
278
  // value, that would throw immediately while type system validation
304
279
  // with validateSchema() will produce more actionable results.
305
- const type: any = this._buildWrappedType(value.type);
280
+ const type: any = this.getWrappedType(value.type);
306
281
  return {
307
282
  type,
308
283
  description: getDescription(value, this._options),
@@ -319,7 +294,12 @@ export class ASTDefinitionBuilder {
319
294
  };
320
295
  }
321
296
 
322
- _makeSchemaDef(astNode: TypeDefinitionNode): GraphQLNamedType {
297
+ buildType(astNode: TypeDefinitionNode): GraphQLNamedType {
298
+ const name = astNode.name.value;
299
+ if (stdTypeMap[name]) {
300
+ return stdTypeMap[name];
301
+ }
302
+
323
303
  switch (astNode.kind) {
324
304
  case Kind.OBJECT_TYPE_DEFINITION:
325
305
  return this._makeTypeDef(astNode);
@@ -333,9 +313,13 @@ export class ASTDefinitionBuilder {
333
313
  return this._makeScalarDef(astNode);
334
314
  case Kind.INPUT_OBJECT_TYPE_DEFINITION:
335
315
  return this._makeInputObjectDef(astNode);
336
- default:
337
- throw new Error(`Type kind "${astNode.kind}" not supported.`);
338
316
  }
317
+
318
+ // Not reachable. All possible type definition nodes have been considered.
319
+ /* istanbul ignore next */
320
+ throw new Error(
321
+ `Unexpected type definition node: "${inspect((astNode: empty))}".`,
322
+ );
339
323
  }
340
324
 
341
325
  _makeTypeDef(astNode: ObjectTypeDefinitionNode) {
@@ -347,7 +331,7 @@ export class ASTDefinitionBuilder {
347
331
  // validation with validateSchema() will produce more actionable results.
348
332
  const interfaces =
349
333
  interfaceNodes && interfaceNodes.length > 0
350
- ? () => interfaceNodes.map(ref => (this.buildType(ref): any))
334
+ ? () => interfaceNodes.map(ref => (this.getNamedType(ref): any))
351
335
  : [];
352
336
 
353
337
  const fields =
@@ -399,7 +383,7 @@ export class ASTDefinitionBuilder {
399
383
  // validation with validateSchema() will produce more actionable results.
400
384
  const types =
401
385
  typeNodes && typeNodes.length > 0
402
- ? () => typeNodes.map(ref => (this.buildType(ref): any))
386
+ ? () => typeNodes.map(ref => (this.getNamedType(ref): any))
403
387
  : [];
404
388
 
405
389
  return new GraphQLUnionType({
@@ -471,7 +455,7 @@ export function getDescription(
471
455
  if (options && options.commentDescriptions) {
472
456
  const rawValue = getLeadingCommentBlock(node);
473
457
  if (rawValue !== undefined) {
474
- return blockStringValue('\n' + rawValue);
458
+ return dedentBlockStringValue('\n' + rawValue);
475
459
  }
476
460
  }
477
461
  }