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
@@ -5,8 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.extendSchema = extendSchema;
7
7
 
8
+ var _flatMap = _interopRequireDefault(require("../polyfills/flatMap"));
9
+
8
10
  var _objectValues = _interopRequireDefault(require("../polyfills/objectValues"));
9
11
 
12
+ var _inspect = _interopRequireDefault(require("../jsutils/inspect"));
13
+
10
14
  var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
11
15
 
12
16
  var _mapValue = _interopRequireDefault(require("../jsutils/mapValue"));
@@ -64,14 +68,14 @@ function extendSchema(schema, documentAST, options) {
64
68
  } // Collect the type definitions and extensions found in the document.
65
69
 
66
70
 
67
- var typeDefinitionMap = Object.create(null);
68
- var typeExtensionsMap = Object.create(null); // New directives and types are separate because a directives and types can
71
+ var typeDefs = [];
72
+ var typeExtsMap = Object.create(null); // New directives and types are separate because a directives and types can
69
73
  // have the same name. For example, a type named "skip".
70
74
 
71
- var directiveDefinitions = [];
75
+ var directiveDefs = [];
72
76
  var schemaDef; // Schema extensions are collected which may add additional operation types.
73
77
 
74
- var schemaExtensions = [];
78
+ var schemaExts = [];
75
79
  var _iteratorNormalCompletion = true;
76
80
  var _didIteratorError = false;
77
81
  var _iteratorError = undefined;
@@ -83,16 +87,15 @@ function extendSchema(schema, documentAST, options) {
83
87
  if (def.kind === _kinds.Kind.SCHEMA_DEFINITION) {
84
88
  schemaDef = def;
85
89
  } else if (def.kind === _kinds.Kind.SCHEMA_EXTENSION) {
86
- schemaExtensions.push(def);
90
+ schemaExts.push(def);
87
91
  } else if ((0, _predicates.isTypeDefinitionNode)(def)) {
88
- var typeName = def.name.value;
89
- typeDefinitionMap[typeName] = def;
92
+ typeDefs.push(def);
90
93
  } else if ((0, _predicates.isTypeExtensionNode)(def)) {
91
94
  var extendedTypeName = def.name.value;
92
- var existingTypeExtensions = typeExtensionsMap[extendedTypeName];
93
- typeExtensionsMap[extendedTypeName] = existingTypeExtensions ? existingTypeExtensions.concat([def]) : [def];
95
+ var existingTypeExts = typeExtsMap[extendedTypeName];
96
+ typeExtsMap[extendedTypeName] = existingTypeExts ? existingTypeExts.concat([def]) : [def];
94
97
  } else if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) {
95
- directiveDefinitions.push(def);
98
+ directiveDefs.push(def);
96
99
  }
97
100
  } // If this document contains no new types, extensions, or directives then
98
101
  // return the same unmodified GraphQLSchema instance.
@@ -112,599 +115,304 @@ function extendSchema(schema, documentAST, options) {
112
115
  }
113
116
  }
114
117
 
115
- if (Object.keys(typeExtensionsMap).length === 0 && Object.keys(typeDefinitionMap).length === 0 && directiveDefinitions.length === 0 && schemaExtensions.length === 0 && !schemaDef) {
118
+ if (Object.keys(typeExtsMap).length === 0 && typeDefs.length === 0 && directiveDefs.length === 0 && schemaExts.length === 0 && !schemaDef) {
116
119
  return schema;
117
120
  }
118
121
 
119
- var astBuilder = new _buildASTSchema.ASTDefinitionBuilder(typeDefinitionMap, options, function (typeName) {
120
- var existingType = schema.getType(typeName);
121
- !existingType ? (0, _invariant.default)(0, "Unknown type: \"".concat(typeName, "\".")) : void 0;
122
- return extendNamedType(existingType);
122
+ var schemaConfig = schema.toConfig();
123
+ var astBuilder = new _buildASTSchema.ASTDefinitionBuilder(options, function (typeName) {
124
+ var type = typeMap[typeName];
125
+ !type ? (0, _invariant.default)(0, "Unknown type: \"".concat(typeName, "\".")) : void 0;
126
+ return type;
127
+ });
128
+ var typeMap = (0, _keyValMap.default)(typeDefs, function (node) {
129
+ return node.name.value;
130
+ }, function (node) {
131
+ return astBuilder.buildType(node);
123
132
  });
124
- var extendTypeCache = Object.create(null); // Get the extended root operation types.
133
+ var _iteratorNormalCompletion2 = true;
134
+ var _didIteratorError2 = false;
135
+ var _iteratorError2 = undefined;
136
+
137
+ try {
138
+ for (var _iterator2 = schemaConfig.types[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
139
+ var existingType = _step2.value;
140
+ typeMap[existingType.name] = extendNamedType(existingType);
141
+ } // Get the extended root operation types.
142
+
143
+ } catch (err) {
144
+ _didIteratorError2 = true;
145
+ _iteratorError2 = err;
146
+ } finally {
147
+ try {
148
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
149
+ _iterator2.return();
150
+ }
151
+ } finally {
152
+ if (_didIteratorError2) {
153
+ throw _iteratorError2;
154
+ }
155
+ }
156
+ }
125
157
 
126
158
  var operationTypes = {
127
- query: extendMaybeNamedType(schema.getQueryType()),
128
- mutation: extendMaybeNamedType(schema.getMutationType()),
129
- subscription: extendMaybeNamedType(schema.getSubscriptionType())
159
+ query: schemaConfig.query && schemaConfig.query.name,
160
+ mutation: schemaConfig.mutation && schemaConfig.mutation.name,
161
+ subscription: schemaConfig.subscription && schemaConfig.subscription.name
130
162
  };
131
163
 
132
164
  if (schemaDef) {
133
- var _iteratorNormalCompletion2 = true;
134
- var _didIteratorError2 = false;
135
- var _iteratorError2 = undefined;
165
+ var _iteratorNormalCompletion3 = true;
166
+ var _didIteratorError3 = false;
167
+ var _iteratorError3 = undefined;
136
168
 
137
169
  try {
138
- for (var _iterator2 = schemaDef.operationTypes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
139
- var _ref2 = _step2.value;
170
+ for (var _iterator3 = schemaDef.operationTypes[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
171
+ var _ref2 = _step3.value;
140
172
  var operation = _ref2.operation;
141
173
  var type = _ref2.type;
142
- // Note: While this could make early assertions to get the correctly
143
- // typed values, that would throw immediately while type system
144
- // validation with validateSchema() will produce more actionable results.
145
- operationTypes[operation] = astBuilder.buildType(type);
174
+ operationTypes[operation] = type.name.value;
146
175
  }
147
176
  } catch (err) {
148
- _didIteratorError2 = true;
149
- _iteratorError2 = err;
177
+ _didIteratorError3 = true;
178
+ _iteratorError3 = err;
150
179
  } finally {
151
180
  try {
152
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
153
- _iterator2.return();
181
+ if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
182
+ _iterator3.return();
154
183
  }
155
184
  } finally {
156
- if (_didIteratorError2) {
157
- throw _iteratorError2;
185
+ if (_didIteratorError3) {
186
+ throw _iteratorError3;
158
187
  }
159
188
  }
160
189
  }
161
190
  } // Then, incorporate schema definition and all schema extensions.
162
191
 
163
192
 
164
- for (var _i = 0; _i < schemaExtensions.length; _i++) {
165
- var schemaExtension = schemaExtensions[_i];
193
+ for (var _i = 0, _schemaExts = schemaExts; _i < _schemaExts.length; _i++) {
194
+ var schemaExt = _schemaExts[_i];
166
195
 
167
- if (schemaExtension.operationTypes) {
168
- var _iteratorNormalCompletion14 = true;
169
- var _didIteratorError14 = false;
170
- var _iteratorError14 = undefined;
196
+ if (schemaExt.operationTypes) {
197
+ var _iteratorNormalCompletion4 = true;
198
+ var _didIteratorError4 = false;
199
+ var _iteratorError4 = undefined;
171
200
 
172
201
  try {
173
- for (var _iterator14 = schemaExtension.operationTypes[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
174
- var _ref4 = _step14.value;
202
+ for (var _iterator4 = schemaExt.operationTypes[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
203
+ var _ref4 = _step4.value;
175
204
  var _operation = _ref4.operation;
176
205
  var _type = _ref4.type;
177
- // Note: While this could make early assertions to get the correctly
178
- // typed values, that would throw immediately while type system
179
- // validation with validateSchema() will produce more actionable results.
180
- operationTypes[_operation] = astBuilder.buildType(_type);
206
+ operationTypes[_operation] = _type.name.value;
181
207
  }
182
208
  } catch (err) {
183
- _didIteratorError14 = true;
184
- _iteratorError14 = err;
209
+ _didIteratorError4 = true;
210
+ _iteratorError4 = err;
185
211
  } finally {
186
212
  try {
187
- if (!_iteratorNormalCompletion14 && _iterator14.return != null) {
188
- _iterator14.return();
213
+ if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
214
+ _iterator4.return();
189
215
  }
190
216
  } finally {
191
- if (_didIteratorError14) {
192
- throw _iteratorError14;
217
+ if (_didIteratorError4) {
218
+ throw _iteratorError4;
193
219
  }
194
220
  }
195
221
  }
196
222
  }
197
- }
223
+ } // Support both original legacy names and extended legacy names.
198
224
 
199
- var schemaExtensionASTNodes = schemaExtensions ? schema.extensionASTNodes ? schema.extensionASTNodes.concat(schemaExtensions) : schemaExtensions : schema.extensionASTNodes;
200
- var types = [].concat((0, _objectValues.default)(schema.getTypeMap()).map(function (type) {
201
- return extendNamedType(type);
202
- }), (0, _objectValues.default)(typeDefinitionMap).map(function (type) {
203
- return astBuilder.buildType(type);
204
- })); // Support both original legacy names and extended legacy names.
205
225
 
206
- var allowedLegacyNames = schema.__allowedLegacyNames.concat(options && options.allowedLegacyNames || []); // Then produce and return a Schema with these types.
226
+ var allowedLegacyNames = schemaConfig.allowedLegacyNames.concat(options && options.allowedLegacyNames || []); // Then produce and return a Schema with these types.
207
227
 
208
-
209
- return new _schema.GraphQLSchema(_objectSpread({}, operationTypes, {
210
- types: types,
228
+ return new _schema.GraphQLSchema({
229
+ // Note: While this could make early assertions to get the correctly
230
+ // typed values, that would throw immediately while type system
231
+ // validation with validateSchema() will produce more actionable results.
232
+ query: getMaybeTypeByName(operationTypes.query),
233
+ mutation: getMaybeTypeByName(operationTypes.mutation),
234
+ subscription: getMaybeTypeByName(operationTypes.subscription),
235
+ types: (0, _objectValues.default)(typeMap),
211
236
  directives: getMergedDirectives(),
212
- astNode: schema.astNode,
213
- extensionASTNodes: schemaExtensionASTNodes,
237
+ astNode: schemaDef || schemaConfig.astNode,
238
+ extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExts),
214
239
  allowedLegacyNames: allowedLegacyNames
215
- })); // Below are functions used for producing this schema that have closed over
240
+ }); // Below are functions used for producing this schema that have closed over
216
241
  // this scope and have access to the schema, cache, and newly defined types.
217
242
 
243
+ function replaceType(type) {
244
+ if ((0, _definition.isListType)(type)) {
245
+ return new _definition.GraphQLList(replaceType(type.ofType));
246
+ } else if ((0, _definition.isNonNullType)(type)) {
247
+ return new _definition.GraphQLNonNull(replaceType(type.ofType));
248
+ }
249
+
250
+ return replaceNamedType(type);
251
+ }
252
+
253
+ function replaceNamedType(type) {
254
+ return typeMap[type.name];
255
+ }
256
+
257
+ function getMaybeTypeByName(typeName) {
258
+ return typeName ? typeMap[typeName] : null;
259
+ }
260
+
218
261
  function getMergedDirectives() {
219
262
  var existingDirectives = schema.getDirectives().map(extendDirective);
220
263
  !existingDirectives ? (0, _invariant.default)(0, 'schema must have default directives') : void 0;
221
- return existingDirectives.concat(directiveDefinitions.map(function (node) {
264
+ return existingDirectives.concat(directiveDefs.map(function (node) {
222
265
  return astBuilder.buildDirective(node);
223
266
  }));
224
267
  }
225
268
 
226
- function extendMaybeNamedType(type) {
227
- return type ? extendNamedType(type) : null;
228
- }
229
-
230
269
  function extendNamedType(type) {
231
270
  if ((0, _introspection.isIntrospectionType)(type) || (0, _scalars.isSpecifiedScalarType)(type)) {
232
271
  // Builtin types are not extended.
233
272
  return type;
234
- }
235
-
236
- var name = type.name;
237
-
238
- if (!extendTypeCache[name]) {
239
- if ((0, _definition.isScalarType)(type)) {
240
- extendTypeCache[name] = extendScalarType(type);
241
- } else if ((0, _definition.isObjectType)(type)) {
242
- extendTypeCache[name] = extendObjectType(type);
243
- } else if ((0, _definition.isInterfaceType)(type)) {
244
- extendTypeCache[name] = extendInterfaceType(type);
245
- } else if ((0, _definition.isUnionType)(type)) {
246
- extendTypeCache[name] = extendUnionType(type);
247
- } else if ((0, _definition.isEnumType)(type)) {
248
- extendTypeCache[name] = extendEnumType(type);
249
- } else if ((0, _definition.isInputObjectType)(type)) {
250
- extendTypeCache[name] = extendInputObjectType(type);
251
- }
252
- }
253
-
254
- return extendTypeCache[name];
273
+ } else if ((0, _definition.isScalarType)(type)) {
274
+ return extendScalarType(type);
275
+ } else if ((0, _definition.isObjectType)(type)) {
276
+ return extendObjectType(type);
277
+ } else if ((0, _definition.isInterfaceType)(type)) {
278
+ return extendInterfaceType(type);
279
+ } else if ((0, _definition.isUnionType)(type)) {
280
+ return extendUnionType(type);
281
+ } else if ((0, _definition.isEnumType)(type)) {
282
+ return extendEnumType(type);
283
+ } else if ((0, _definition.isInputObjectType)(type)) {
284
+ return extendInputObjectType(type);
285
+ } // Not reachable. All possible types have been considered.
286
+
287
+ /* istanbul ignore next */
288
+
289
+
290
+ throw new Error("Unexpected type: \"".concat((0, _inspect.default)(type), "\"."));
255
291
  }
256
292
 
257
293
  function extendDirective(directive) {
258
- return new _directives.GraphQLDirective({
259
- name: directive.name,
260
- description: directive.description,
261
- locations: directive.locations,
262
- args: extendArgs(directive.args),
263
- astNode: directive.astNode
264
- });
294
+ var config = directive.toConfig();
295
+ return new _directives.GraphQLDirective(_objectSpread({}, config, {
296
+ args: (0, _mapValue.default)(config.args, extendArg)
297
+ }));
265
298
  }
266
299
 
267
300
  function extendInputObjectType(type) {
268
- var name = type.name;
269
- var extensionASTNodes = typeExtensionsMap[name] ? type.extensionASTNodes ? type.extensionASTNodes.concat(typeExtensionsMap[name]) : typeExtensionsMap[name] : type.extensionASTNodes;
270
- return new _definition.GraphQLInputObjectType({
271
- name: name,
272
- description: type.description,
301
+ var config = type.toConfig();
302
+ var extensions = typeExtsMap[config.name] || [];
303
+ var fieldNodes = (0, _flatMap.default)(extensions, function (node) {
304
+ return node.fields || [];
305
+ });
306
+ return new _definition.GraphQLInputObjectType(_objectSpread({}, config, {
273
307
  fields: function fields() {
274
- return extendInputFieldMap(type);
308
+ return _objectSpread({}, (0, _mapValue.default)(config.fields, function (field) {
309
+ return _objectSpread({}, field, {
310
+ type: replaceType(field.type)
311
+ });
312
+ }), (0, _keyValMap.default)(fieldNodes, function (field) {
313
+ return field.name.value;
314
+ }, function (field) {
315
+ return astBuilder.buildInputField(field);
316
+ }));
275
317
  },
276
- astNode: type.astNode,
277
- extensionASTNodes: extensionASTNodes
278
- });
279
- }
280
-
281
- function extendInputFieldMap(type) {
282
- var newFieldMap = (0, _mapValue.default)(type.getFields(), function (field) {
283
- return {
284
- description: field.description,
285
- type: extendType(field.type),
286
- defaultValue: field.defaultValue,
287
- astNode: field.astNode
288
- };
289
- }); // If there are any extensions to the fields, apply those here.
290
-
291
- var extensions = typeExtensionsMap[type.name];
292
-
293
- if (extensions) {
294
- var _iteratorNormalCompletion3 = true;
295
- var _didIteratorError3 = false;
296
- var _iteratorError3 = undefined;
297
-
298
- try {
299
- for (var _iterator3 = extensions[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
300
- var extension = _step3.value;
301
- var _iteratorNormalCompletion4 = true;
302
- var _didIteratorError4 = false;
303
- var _iteratorError4 = undefined;
304
-
305
- try {
306
- for (var _iterator4 = extension.fields[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
307
- var field = _step4.value;
308
- newFieldMap[field.name.value] = astBuilder.buildInputField(field);
309
- }
310
- } catch (err) {
311
- _didIteratorError4 = true;
312
- _iteratorError4 = err;
313
- } finally {
314
- try {
315
- if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
316
- _iterator4.return();
317
- }
318
- } finally {
319
- if (_didIteratorError4) {
320
- throw _iteratorError4;
321
- }
322
- }
323
- }
324
- }
325
- } catch (err) {
326
- _didIteratorError3 = true;
327
- _iteratorError3 = err;
328
- } finally {
329
- try {
330
- if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
331
- _iterator3.return();
332
- }
333
- } finally {
334
- if (_didIteratorError3) {
335
- throw _iteratorError3;
336
- }
337
- }
338
- }
339
- }
340
-
341
- return newFieldMap;
318
+ extensionASTNodes: config.extensionASTNodes.concat(extensions)
319
+ }));
342
320
  }
343
321
 
344
322
  function extendEnumType(type) {
345
- var name = type.name;
346
- var extensionASTNodes = typeExtensionsMap[name] ? type.extensionASTNodes ? type.extensionASTNodes.concat(typeExtensionsMap[name]) : typeExtensionsMap[name] : type.extensionASTNodes;
347
- return new _definition.GraphQLEnumType({
348
- name: name,
349
- description: type.description,
350
- values: extendValueMap(type),
351
- astNode: type.astNode,
352
- extensionASTNodes: extensionASTNodes
323
+ var config = type.toConfig();
324
+ var extensions = typeExtsMap[type.name] || [];
325
+ var valueNodes = (0, _flatMap.default)(extensions, function (node) {
326
+ return node.values || [];
353
327
  });
354
- }
355
-
356
- function extendValueMap(type) {
357
- var newValueMap = Object.create(null);
358
- var _iteratorNormalCompletion5 = true;
359
- var _didIteratorError5 = false;
360
- var _iteratorError5 = undefined;
361
-
362
- try {
363
- for (var _iterator5 = type.getValues()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
364
- var _value = _step5.value;
365
- newValueMap[_value.name] = {
366
- description: _value.description,
367
- value: _value.value,
368
- deprecationReason: _value.deprecationReason,
369
- astNode: _value.astNode
370
- };
371
- } // If there are any extensions to the values, apply those here.
372
-
373
- } catch (err) {
374
- _didIteratorError5 = true;
375
- _iteratorError5 = err;
376
- } finally {
377
- try {
378
- if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
379
- _iterator5.return();
380
- }
381
- } finally {
382
- if (_didIteratorError5) {
383
- throw _iteratorError5;
384
- }
385
- }
386
- }
387
-
388
- var extensions = typeExtensionsMap[type.name];
389
-
390
- if (extensions) {
391
- var _iteratorNormalCompletion6 = true;
392
- var _didIteratorError6 = false;
393
- var _iteratorError6 = undefined;
394
-
395
- try {
396
- for (var _iterator6 = extensions[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
397
- var extension = _step6.value;
398
- var _iteratorNormalCompletion7 = true;
399
- var _didIteratorError7 = false;
400
- var _iteratorError7 = undefined;
401
-
402
- try {
403
- for (var _iterator7 = extension.values[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
404
- var value = _step7.value;
405
- newValueMap[value.name.value] = astBuilder.buildEnumValue(value);
406
- }
407
- } catch (err) {
408
- _didIteratorError7 = true;
409
- _iteratorError7 = err;
410
- } finally {
411
- try {
412
- if (!_iteratorNormalCompletion7 && _iterator7.return != null) {
413
- _iterator7.return();
414
- }
415
- } finally {
416
- if (_didIteratorError7) {
417
- throw _iteratorError7;
418
- }
419
- }
420
- }
421
- }
422
- } catch (err) {
423
- _didIteratorError6 = true;
424
- _iteratorError6 = err;
425
- } finally {
426
- try {
427
- if (!_iteratorNormalCompletion6 && _iterator6.return != null) {
428
- _iterator6.return();
429
- }
430
- } finally {
431
- if (_didIteratorError6) {
432
- throw _iteratorError6;
433
- }
434
- }
435
- }
436
- }
437
-
438
- return newValueMap;
328
+ return new _definition.GraphQLEnumType(_objectSpread({}, config, {
329
+ values: _objectSpread({}, config.values, (0, _keyValMap.default)(valueNodes, function (value) {
330
+ return value.name.value;
331
+ }, function (value) {
332
+ return astBuilder.buildEnumValue(value);
333
+ })),
334
+ extensionASTNodes: config.extensionASTNodes.concat(extensions)
335
+ }));
439
336
  }
440
337
 
441
338
  function extendScalarType(type) {
442
- var name = type.name;
443
- var extensionASTNodes = typeExtensionsMap[name] ? type.extensionASTNodes ? type.extensionASTNodes.concat(typeExtensionsMap[name]) : typeExtensionsMap[name] : type.extensionASTNodes;
444
- return new _definition.GraphQLScalarType({
445
- name: name,
446
- description: type.description,
447
- astNode: type.astNode,
448
- extensionASTNodes: extensionASTNodes,
449
- serialize: type.serialize,
450
- parseValue: type.parseValue,
451
- parseLiteral: type.parseLiteral
452
- });
339
+ var config = type.toConfig();
340
+ var extensions = typeExtsMap[config.name] || [];
341
+ return new _definition.GraphQLScalarType(_objectSpread({}, config, {
342
+ extensionASTNodes: config.extensionASTNodes.concat(extensions)
343
+ }));
453
344
  }
454
345
 
455
346
  function extendObjectType(type) {
456
- var name = type.name;
457
- var extensionASTNodes = typeExtensionsMap[name] ? type.extensionASTNodes ? type.extensionASTNodes.concat(typeExtensionsMap[name]) : typeExtensionsMap[name] : type.extensionASTNodes;
458
- return new _definition.GraphQLObjectType({
459
- name: name,
460
- description: type.description,
347
+ var config = type.toConfig();
348
+ var extensions = typeExtsMap[config.name] || [];
349
+ var interfaceNodes = (0, _flatMap.default)(extensions, function (node) {
350
+ return node.interfaces || [];
351
+ });
352
+ var fieldNodes = (0, _flatMap.default)(extensions, function (node) {
353
+ return node.fields || [];
354
+ });
355
+ return new _definition.GraphQLObjectType(_objectSpread({}, config, {
461
356
  interfaces: function interfaces() {
462
- return extendImplementedInterfaces(type);
357
+ return [].concat(type.getInterfaces().map(replaceNamedType), interfaceNodes.map(function (node) {
358
+ return astBuilder.getNamedType(node);
359
+ }));
463
360
  },
464
361
  fields: function fields() {
465
- return extendFieldMap(type);
362
+ return _objectSpread({}, (0, _mapValue.default)(config.fields, extendField), (0, _keyValMap.default)(fieldNodes, function (node) {
363
+ return node.name.value;
364
+ }, function (node) {
365
+ return astBuilder.buildField(node);
366
+ }));
466
367
  },
467
- astNode: type.astNode,
468
- extensionASTNodes: extensionASTNodes,
469
- isTypeOf: type.isTypeOf
470
- });
471
- }
472
-
473
- function extendArgs(args) {
474
- return (0, _keyValMap.default)(args, function (arg) {
475
- return arg.name;
476
- }, function (arg) {
477
- return {
478
- type: extendType(arg.type),
479
- defaultValue: arg.defaultValue,
480
- description: arg.description,
481
- astNode: arg.astNode
482
- };
483
- });
368
+ extensionASTNodes: config.extensionASTNodes.concat(extensions)
369
+ }));
484
370
  }
485
371
 
486
372
  function extendInterfaceType(type) {
487
- var name = type.name;
488
- var extensionASTNodes = typeExtensionsMap[name] ? type.extensionASTNodes ? type.extensionASTNodes.concat(typeExtensionsMap[name]) : typeExtensionsMap[name] : type.extensionASTNodes;
489
- return new _definition.GraphQLInterfaceType({
490
- name: type.name,
491
- description: type.description,
373
+ var config = type.toConfig();
374
+ var extensions = typeExtsMap[config.name] || [];
375
+ var fieldNodes = (0, _flatMap.default)(extensions, function (node) {
376
+ return node.fields || [];
377
+ });
378
+ return new _definition.GraphQLInterfaceType(_objectSpread({}, config, {
492
379
  fields: function fields() {
493
- return extendFieldMap(type);
380
+ return _objectSpread({}, (0, _mapValue.default)(config.fields, extendField), (0, _keyValMap.default)(fieldNodes, function (node) {
381
+ return node.name.value;
382
+ }, function (node) {
383
+ return astBuilder.buildField(node);
384
+ }));
494
385
  },
495
- astNode: type.astNode,
496
- extensionASTNodes: extensionASTNodes,
497
- resolveType: type.resolveType
498
- });
386
+ extensionASTNodes: config.extensionASTNodes.concat(extensions)
387
+ }));
499
388
  }
500
389
 
501
390
  function extendUnionType(type) {
502
- var name = type.name;
503
- var extensionASTNodes = typeExtensionsMap[name] ? type.extensionASTNodes ? type.extensionASTNodes.concat(typeExtensionsMap[name]) : typeExtensionsMap[name] : type.extensionASTNodes;
504
- return new _definition.GraphQLUnionType({
505
- name: name,
506
- description: type.description,
391
+ var config = type.toConfig();
392
+ var extensions = typeExtsMap[config.name] || [];
393
+ var typeNodes = (0, _flatMap.default)(extensions, function (node) {
394
+ return node.types || [];
395
+ });
396
+ return new _definition.GraphQLUnionType(_objectSpread({}, config, {
507
397
  types: function types() {
508
- return extendPossibleTypes(type);
398
+ return [].concat(type.getTypes().map(replaceNamedType), typeNodes.map(function (node) {
399
+ return astBuilder.getNamedType(node);
400
+ }));
509
401
  },
510
- astNode: type.astNode,
511
- resolveType: type.resolveType,
512
- extensionASTNodes: extensionASTNodes
513
- });
514
- }
515
-
516
- function extendPossibleTypes(type) {
517
- var possibleTypes = type.getTypes().map(extendNamedType); // If there are any extensions to the union, apply those here.
518
-
519
- var extensions = typeExtensionsMap[type.name];
520
-
521
- if (extensions) {
522
- var _iteratorNormalCompletion8 = true;
523
- var _didIteratorError8 = false;
524
- var _iteratorError8 = undefined;
525
-
526
- try {
527
- for (var _iterator8 = extensions[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
528
- var extension = _step8.value;
529
- var _iteratorNormalCompletion9 = true;
530
- var _didIteratorError9 = false;
531
- var _iteratorError9 = undefined;
532
-
533
- try {
534
- for (var _iterator9 = extension.types[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
535
- var namedType = _step9.value;
536
- // Note: While this could make early assertions to get the correctly
537
- // typed values, that would throw immediately while type system
538
- // validation with validateSchema() will produce more actionable results.
539
- possibleTypes.push(astBuilder.buildType(namedType));
540
- }
541
- } catch (err) {
542
- _didIteratorError9 = true;
543
- _iteratorError9 = err;
544
- } finally {
545
- try {
546
- if (!_iteratorNormalCompletion9 && _iterator9.return != null) {
547
- _iterator9.return();
548
- }
549
- } finally {
550
- if (_didIteratorError9) {
551
- throw _iteratorError9;
552
- }
553
- }
554
- }
555
- }
556
- } catch (err) {
557
- _didIteratorError8 = true;
558
- _iteratorError8 = err;
559
- } finally {
560
- try {
561
- if (!_iteratorNormalCompletion8 && _iterator8.return != null) {
562
- _iterator8.return();
563
- }
564
- } finally {
565
- if (_didIteratorError8) {
566
- throw _iteratorError8;
567
- }
568
- }
569
- }
570
- }
571
-
572
- return possibleTypes;
573
- }
574
-
575
- function extendImplementedInterfaces(type) {
576
- var interfaces = type.getInterfaces().map(extendNamedType); // If there are any extensions to the interfaces, apply those here.
577
-
578
- var extensions = typeExtensionsMap[type.name];
579
-
580
- if (extensions) {
581
- var _iteratorNormalCompletion10 = true;
582
- var _didIteratorError10 = false;
583
- var _iteratorError10 = undefined;
584
-
585
- try {
586
- for (var _iterator10 = extensions[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
587
- var extension = _step10.value;
588
- var _iteratorNormalCompletion11 = true;
589
- var _didIteratorError11 = false;
590
- var _iteratorError11 = undefined;
591
-
592
- try {
593
- for (var _iterator11 = extension.interfaces[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
594
- var namedType = _step11.value;
595
- // Note: While this could make early assertions to get the correctly
596
- // typed values, that would throw immediately while type system
597
- // validation with validateSchema() will produce more actionable results.
598
- interfaces.push(astBuilder.buildType(namedType));
599
- }
600
- } catch (err) {
601
- _didIteratorError11 = true;
602
- _iteratorError11 = err;
603
- } finally {
604
- try {
605
- if (!_iteratorNormalCompletion11 && _iterator11.return != null) {
606
- _iterator11.return();
607
- }
608
- } finally {
609
- if (_didIteratorError11) {
610
- throw _iteratorError11;
611
- }
612
- }
613
- }
614
- }
615
- } catch (err) {
616
- _didIteratorError10 = true;
617
- _iteratorError10 = err;
618
- } finally {
619
- try {
620
- if (!_iteratorNormalCompletion10 && _iterator10.return != null) {
621
- _iterator10.return();
622
- }
623
- } finally {
624
- if (_didIteratorError10) {
625
- throw _iteratorError10;
626
- }
627
- }
628
- }
629
- }
630
-
631
- return interfaces;
402
+ extensionASTNodes: config.extensionASTNodes.concat(extensions)
403
+ }));
632
404
  }
633
405
 
634
- function extendFieldMap(type) {
635
- var newFieldMap = (0, _mapValue.default)(type.getFields(), function (field) {
636
- return {
637
- description: field.description,
638
- deprecationReason: field.deprecationReason,
639
- type: extendType(field.type),
640
- args: extendArgs(field.args),
641
- astNode: field.astNode,
642
- resolve: field.resolve
643
- };
644
- }); // If there are any extensions to the fields, apply those here.
645
-
646
- var extensions = typeExtensionsMap[type.name];
647
-
648
- if (extensions) {
649
- var _iteratorNormalCompletion12 = true;
650
- var _didIteratorError12 = false;
651
- var _iteratorError12 = undefined;
652
-
653
- try {
654
- for (var _iterator12 = extensions[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
655
- var extension = _step12.value;
656
- var _iteratorNormalCompletion13 = true;
657
- var _didIteratorError13 = false;
658
- var _iteratorError13 = undefined;
659
-
660
- try {
661
- for (var _iterator13 = extension.fields[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
662
- var field = _step13.value;
663
- newFieldMap[field.name.value] = astBuilder.buildField(field);
664
- }
665
- } catch (err) {
666
- _didIteratorError13 = true;
667
- _iteratorError13 = err;
668
- } finally {
669
- try {
670
- if (!_iteratorNormalCompletion13 && _iterator13.return != null) {
671
- _iterator13.return();
672
- }
673
- } finally {
674
- if (_didIteratorError13) {
675
- throw _iteratorError13;
676
- }
677
- }
678
- }
679
- }
680
- } catch (err) {
681
- _didIteratorError12 = true;
682
- _iteratorError12 = err;
683
- } finally {
684
- try {
685
- if (!_iteratorNormalCompletion12 && _iterator12.return != null) {
686
- _iterator12.return();
687
- }
688
- } finally {
689
- if (_didIteratorError12) {
690
- throw _iteratorError12;
691
- }
692
- }
693
- }
694
- }
695
-
696
- return newFieldMap;
406
+ function extendField(field) {
407
+ return _objectSpread({}, field, {
408
+ type: replaceType(field.type),
409
+ args: (0, _mapValue.default)(field.args, extendArg)
410
+ });
697
411
  }
698
412
 
699
- function extendType(typeDef) {
700
- if ((0, _definition.isListType)(typeDef)) {
701
- return (0, _definition.GraphQLList)(extendType(typeDef.ofType));
702
- }
703
-
704
- if ((0, _definition.isNonNullType)(typeDef)) {
705
- return (0, _definition.GraphQLNonNull)(extendType(typeDef.ofType));
706
- }
707
-
708
- return extendNamedType(typeDef);
413
+ function extendArg(arg) {
414
+ return _objectSpread({}, arg, {
415
+ type: replaceType(arg.type)
416
+ });
709
417
  }
710
- }
418
+ }