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