graphql 15.2.0 → 15.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +19 -10
  3. package/error/GraphQLError.js +8 -8
  4. package/error/GraphQLError.js.flow +2 -3
  5. package/error/GraphQLError.mjs +2 -2
  6. package/error/formatError.js +1 -1
  7. package/error/formatError.js.flow +0 -1
  8. package/error/index.js +4 -4
  9. package/error/index.js.flow +0 -1
  10. package/error/locatedError.d.ts +2 -2
  11. package/error/locatedError.js +10 -5
  12. package/error/locatedError.js.flow +10 -4
  13. package/error/locatedError.mjs +6 -4
  14. package/error/syntaxError.js +1 -1
  15. package/error/syntaxError.js.flow +0 -1
  16. package/execution/execute.d.ts +11 -15
  17. package/execution/execute.js +110 -110
  18. package/execution/execute.js.flow +132 -139
  19. package/execution/execute.mjs +92 -88
  20. package/execution/index.d.ts +1 -0
  21. package/execution/index.js +3 -3
  22. package/execution/index.js.flow +6 -2
  23. package/execution/values.js +11 -11
  24. package/execution/values.js.flow +0 -1
  25. package/graphql.js +5 -5
  26. package/graphql.js.flow +0 -1
  27. package/index.d.ts +2 -0
  28. package/index.js +9 -9
  29. package/index.js.flow +5 -2
  30. package/jsutils/ObjMap.js.flow +0 -1
  31. package/jsutils/Path.js.flow +0 -1
  32. package/jsutils/PromiseOrValue.js.flow +0 -1
  33. package/jsutils/defineInspect.js +2 -2
  34. package/jsutils/defineInspect.js.flow +0 -1
  35. package/jsutils/devAssert.js.flow +0 -1
  36. package/jsutils/didYouMean.js.flow +0 -1
  37. package/jsutils/identityFunc.js.flow +0 -1
  38. package/jsutils/inspect.js +1 -2
  39. package/jsutils/inspect.js.flow +10 -8
  40. package/jsutils/inspect.mjs +1 -1
  41. package/jsutils/instanceOf.js.flow +2 -3
  42. package/jsutils/invariant.js.flow +0 -1
  43. package/jsutils/isAsyncIterable.js +13 -0
  44. package/jsutils/isAsyncIterable.js.flow +14 -0
  45. package/jsutils/isAsyncIterable.mjs +10 -0
  46. package/jsutils/isObjectLike.js.flow +0 -1
  47. package/jsutils/isPromise.js.flow +0 -1
  48. package/jsutils/keyMap.js.flow +0 -1
  49. package/jsutils/keyValMap.js.flow +0 -1
  50. package/jsutils/mapValue.js +1 -1
  51. package/jsutils/mapValue.js.flow +0 -1
  52. package/jsutils/memoize3.js +2 -5
  53. package/jsutils/memoize3.js.flow +2 -5
  54. package/jsutils/memoize3.mjs +2 -5
  55. package/jsutils/naturalCompare.js +69 -0
  56. package/jsutils/naturalCompare.js.flow +59 -0
  57. package/jsutils/naturalCompare.mjs +61 -0
  58. package/jsutils/nodejsCustomInspectSymbol.js.flow +0 -1
  59. package/jsutils/printPathArray.js.flow +0 -1
  60. package/jsutils/promiseForObject.js.flow +0 -1
  61. package/jsutils/promiseReduce.js +1 -1
  62. package/jsutils/promiseReduce.js.flow +0 -1
  63. package/jsutils/safeArrayFrom.js +73 -0
  64. package/jsutils/safeArrayFrom.js.flow +59 -0
  65. package/jsutils/safeArrayFrom.mjs +66 -0
  66. package/jsutils/suggestionList.js +5 -1
  67. package/jsutils/suggestionList.js.flow +3 -2
  68. package/jsutils/suggestionList.mjs +3 -1
  69. package/jsutils/toObjMap.js +1 -1
  70. package/jsutils/toObjMap.js.flow +0 -1
  71. package/language/ast.js +1 -1
  72. package/language/ast.js.flow +0 -1
  73. package/language/blockString.d.ts +1 -1
  74. package/language/blockString.js +53 -32
  75. package/language/blockString.js.flow +51 -36
  76. package/language/blockString.mjs +54 -33
  77. package/language/directiveLocation.js.flow +0 -1
  78. package/language/experimentalOnlineParser/grammar.d.ts +1006 -0
  79. package/language/experimentalOnlineParser/grammar.js +987 -0
  80. package/language/experimentalOnlineParser/grammar.js.flow +1000 -0
  81. package/language/experimentalOnlineParser/grammar.mjs +980 -0
  82. package/language/experimentalOnlineParser/index.d.ts +6 -0
  83. package/language/experimentalOnlineParser/index.js +31 -0
  84. package/language/experimentalOnlineParser/index.js.flow +7 -0
  85. package/language/experimentalOnlineParser/index.mjs +1 -0
  86. package/language/experimentalOnlineParser/onlineParser.d.ts +125 -0
  87. package/language/experimentalOnlineParser/onlineParser.js +604 -0
  88. package/language/experimentalOnlineParser/onlineParser.js.flow +723 -0
  89. package/language/experimentalOnlineParser/onlineParser.mjs +587 -0
  90. package/language/index.js +12 -12
  91. package/language/index.js.flow +0 -1
  92. package/language/kinds.js.flow +0 -1
  93. package/language/lexer.js +242 -183
  94. package/language/lexer.js.flow +188 -184
  95. package/language/lexer.mjs +238 -179
  96. package/language/location.js.flow +0 -1
  97. package/language/parser.js +73 -68
  98. package/language/parser.js.flow +62 -57
  99. package/language/parser.mjs +64 -60
  100. package/language/predicates.js +1 -1
  101. package/language/predicates.js.flow +0 -1
  102. package/language/printLocation.js +1 -1
  103. package/language/printLocation.js.flow +0 -1
  104. package/language/printer.js +20 -13
  105. package/language/printer.js.flow +26 -25
  106. package/language/printer.mjs +18 -11
  107. package/language/source.d.ts +12 -6
  108. package/language/source.js +25 -9
  109. package/language/source.js.flow +26 -9
  110. package/language/source.mjs +19 -7
  111. package/language/tokenKind.js.flow +0 -1
  112. package/language/visitor.d.ts +3 -3
  113. package/language/visitor.js +5 -5
  114. package/language/visitor.js.flow +3 -4
  115. package/language/visitor.mjs +3 -3
  116. package/package.json +2 -3
  117. package/polyfills/arrayFrom.js +2 -2
  118. package/polyfills/arrayFrom.js.flow +1 -2
  119. package/polyfills/arrayFrom.mjs +1 -1
  120. package/polyfills/find.js +1 -1
  121. package/polyfills/find.js.flow +1 -2
  122. package/polyfills/find.mjs +1 -1
  123. package/polyfills/isFinite.js +1 -1
  124. package/polyfills/isFinite.js.flow +1 -2
  125. package/polyfills/isFinite.mjs +1 -1
  126. package/polyfills/isInteger.js +1 -1
  127. package/polyfills/isInteger.js.flow +1 -2
  128. package/polyfills/isInteger.mjs +1 -1
  129. package/polyfills/objectEntries.js +1 -1
  130. package/polyfills/objectEntries.js.flow +1 -2
  131. package/polyfills/objectEntries.mjs +1 -1
  132. package/polyfills/objectValues.js +1 -1
  133. package/polyfills/objectValues.js.flow +1 -2
  134. package/polyfills/objectValues.mjs +1 -1
  135. package/polyfills/symbols.js +3 -5
  136. package/polyfills/symbols.js.flow +9 -6
  137. package/polyfills/symbols.mjs +3 -5
  138. package/subscription/index.js +1 -1
  139. package/subscription/index.js.flow +0 -1
  140. package/subscription/mapAsyncIterator.js +2 -2
  141. package/subscription/mapAsyncIterator.js.flow +8 -9
  142. package/subscription/mapAsyncIterator.mjs +1 -1
  143. package/subscription/subscribe.js +61 -73
  144. package/subscription/subscribe.js.flow +71 -85
  145. package/subscription/subscribe.mjs +53 -65
  146. package/type/definition.d.ts +17 -9
  147. package/type/definition.js +37 -32
  148. package/type/definition.js.flow +93 -63
  149. package/type/definition.mjs +19 -14
  150. package/type/directives.js +17 -16
  151. package/type/directives.js.flow +20 -13
  152. package/type/directives.mjs +6 -5
  153. package/type/index.js +6 -6
  154. package/type/index.js.flow +0 -1
  155. package/type/introspection.js +86 -65
  156. package/type/introspection.js.flow +75 -43
  157. package/type/introspection.mjs +79 -58
  158. package/type/scalars.js +9 -9
  159. package/type/scalars.js.flow +1 -2
  160. package/type/scalars.mjs +1 -1
  161. package/type/schema.js +13 -13
  162. package/type/schema.js.flow +2 -3
  163. package/type/schema.mjs +1 -1
  164. package/type/validate.js +52 -19
  165. package/type/validate.js.flow +54 -8
  166. package/type/validate.mjs +43 -9
  167. package/utilities/TypeInfo.js +7 -7
  168. package/utilities/TypeInfo.js.flow +1 -2
  169. package/utilities/assertValidName.js +2 -2
  170. package/utilities/assertValidName.js.flow +0 -1
  171. package/utilities/astFromValue.js +14 -16
  172. package/utilities/astFromValue.js.flow +6 -7
  173. package/utilities/astFromValue.mjs +6 -7
  174. package/utilities/buildASTSchema.js +17 -27
  175. package/utilities/buildASTSchema.js.flow +5 -21
  176. package/utilities/buildASTSchema.mjs +11 -21
  177. package/utilities/buildClientSchema.js +16 -15
  178. package/utilities/buildClientSchema.js.flow +28 -12
  179. package/utilities/buildClientSchema.mjs +5 -4
  180. package/utilities/coerceInputValue.js +17 -18
  181. package/utilities/coerceInputValue.js.flow +12 -10
  182. package/utilities/coerceInputValue.mjs +7 -7
  183. package/utilities/concatAST.js +9 -8
  184. package/utilities/concatAST.js.flow +8 -8
  185. package/utilities/concatAST.mjs +9 -6
  186. package/utilities/extendSchema.js +26 -19
  187. package/utilities/extendSchema.js.flow +19 -7
  188. package/utilities/extendSchema.mjs +8 -1
  189. package/utilities/findBreakingChanges.js +15 -11
  190. package/utilities/findBreakingChanges.js.flow +6 -3
  191. package/utilities/findBreakingChanges.mjs +5 -2
  192. package/utilities/findDeprecatedUsages.js +2 -2
  193. package/utilities/findDeprecatedUsages.js.flow +0 -1
  194. package/utilities/getIntrospectionQuery.d.ts +6 -0
  195. package/utilities/getIntrospectionQuery.js +8 -2
  196. package/utilities/getIntrospectionQuery.js.flow +17 -5
  197. package/utilities/getIntrospectionQuery.mjs +8 -2
  198. package/utilities/getOperationAST.js +1 -1
  199. package/utilities/getOperationAST.js.flow +0 -1
  200. package/utilities/getOperationRootType.js +1 -1
  201. package/utilities/getOperationRootType.js.flow +0 -1
  202. package/utilities/index.d.ts +3 -0
  203. package/utilities/index.js +22 -22
  204. package/utilities/index.js.flow +0 -1
  205. package/utilities/introspectionFromSchema.js +7 -5
  206. package/utilities/introspectionFromSchema.js.flow +2 -1
  207. package/utilities/introspectionFromSchema.mjs +3 -1
  208. package/utilities/lexicographicSortSchema.js +13 -9
  209. package/utilities/lexicographicSortSchema.js.flow +21 -13
  210. package/utilities/lexicographicSortSchema.mjs +5 -2
  211. package/utilities/printSchema.js +15 -16
  212. package/utilities/printSchema.js.flow +23 -16
  213. package/utilities/printSchema.mjs +5 -6
  214. package/utilities/separateOperations.js +46 -42
  215. package/utilities/separateOperations.js.flow +46 -37
  216. package/utilities/separateOperations.mjs +44 -40
  217. package/utilities/stripIgnoredCharacters.js +6 -16
  218. package/utilities/stripIgnoredCharacters.js.flow +4 -13
  219. package/utilities/stripIgnoredCharacters.mjs +3 -10
  220. package/utilities/typeComparators.js +1 -1
  221. package/utilities/typeComparators.js.flow +0 -1
  222. package/utilities/typeFromAST.js +6 -6
  223. package/utilities/typeFromAST.js.flow +2 -3
  224. package/utilities/typeFromAST.mjs +2 -2
  225. package/utilities/typedQueryDocumentNode.d.ts +20 -0
  226. package/utilities/valueFromAST.js +6 -6
  227. package/utilities/valueFromAST.js.flow +4 -2
  228. package/utilities/valueFromASTUntyped.js +4 -4
  229. package/utilities/valueFromASTUntyped.js.flow +0 -1
  230. package/validation/ValidationContext.js +3 -3
  231. package/validation/ValidationContext.js.flow +3 -4
  232. package/validation/index.js +38 -38
  233. package/validation/index.js.flow +0 -1
  234. package/validation/rules/ExecutableDefinitions.js +1 -1
  235. package/validation/rules/ExecutableDefinitions.js.flow +0 -1
  236. package/validation/rules/ExecutableDefinitionsRule.js +3 -3
  237. package/validation/rules/ExecutableDefinitionsRule.js.flow +0 -1
  238. package/validation/rules/FieldsOnCorrectTypeRule.js +8 -6
  239. package/validation/rules/FieldsOnCorrectTypeRule.js.flow +2 -2
  240. package/validation/rules/FieldsOnCorrectTypeRule.mjs +2 -1
  241. package/validation/rules/FragmentsOnCompositeTypesRule.js +4 -4
  242. package/validation/rules/FragmentsOnCompositeTypesRule.js.flow +0 -1
  243. package/validation/rules/KnownArgumentNamesRule.js +5 -5
  244. package/validation/rules/KnownArgumentNamesRule.js.flow +1 -1
  245. package/validation/rules/KnownDirectivesRule.js +6 -6
  246. package/validation/rules/KnownDirectivesRule.js.flow +4 -3
  247. package/validation/rules/KnownFragmentNamesRule.js +1 -1
  248. package/validation/rules/KnownFragmentNamesRule.js.flow +0 -1
  249. package/validation/rules/KnownTypeNamesRule.js +6 -6
  250. package/validation/rules/KnownTypeNamesRule.js.flow +1 -2
  251. package/validation/rules/LoneAnonymousOperationRule.js +2 -2
  252. package/validation/rules/LoneAnonymousOperationRule.js.flow +0 -1
  253. package/validation/rules/LoneSchemaDefinition.js +1 -1
  254. package/validation/rules/LoneSchemaDefinition.js.flow +0 -1
  255. package/validation/rules/LoneSchemaDefinitionRule.js +1 -1
  256. package/validation/rules/LoneSchemaDefinitionRule.js.flow +0 -1
  257. package/validation/rules/NoFragmentCyclesRule.js +1 -1
  258. package/validation/rules/NoFragmentCyclesRule.js.flow +1 -2
  259. package/validation/rules/NoUndefinedVariablesRule.js +1 -1
  260. package/validation/rules/NoUndefinedVariablesRule.js.flow +0 -1
  261. package/validation/rules/NoUnusedFragmentsRule.js +1 -1
  262. package/validation/rules/NoUnusedFragmentsRule.js.flow +0 -1
  263. package/validation/rules/NoUnusedVariablesRule.js +1 -1
  264. package/validation/rules/NoUnusedVariablesRule.js.flow +0 -1
  265. package/validation/rules/OverlappingFieldsCanBeMergedRule.js +20 -20
  266. package/validation/rules/OverlappingFieldsCanBeMergedRule.js.flow +14 -14
  267. package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +12 -12
  268. package/validation/rules/PossibleFragmentSpreadsRule.js +5 -5
  269. package/validation/rules/PossibleFragmentSpreadsRule.js.flow +5 -2
  270. package/validation/rules/PossibleTypeExtensions.js +1 -1
  271. package/validation/rules/PossibleTypeExtensions.js.flow +0 -1
  272. package/validation/rules/PossibleTypeExtensionsRule.js +8 -8
  273. package/validation/rules/PossibleTypeExtensionsRule.js.flow +6 -4
  274. package/validation/rules/ProvidedRequiredArgumentsRule.js +7 -7
  275. package/validation/rules/ProvidedRequiredArgumentsRule.js.flow +4 -3
  276. package/validation/rules/ScalarLeafsRule.js +3 -3
  277. package/validation/rules/ScalarLeafsRule.js.flow +0 -1
  278. package/validation/rules/SingleFieldSubscriptionsRule.js +1 -1
  279. package/validation/rules/SingleFieldSubscriptionsRule.js.flow +0 -1
  280. package/validation/rules/UniqueArgumentNamesRule.js +1 -1
  281. package/validation/rules/UniqueArgumentNamesRule.js.flow +0 -1
  282. package/validation/rules/UniqueDirectiveNames.js +1 -1
  283. package/validation/rules/UniqueDirectiveNames.js.flow +0 -1
  284. package/validation/rules/UniqueDirectiveNamesRule.js +2 -2
  285. package/validation/rules/UniqueDirectiveNamesRule.js.flow +0 -1
  286. package/validation/rules/UniqueDirectiveNamesRule.mjs +1 -1
  287. package/validation/rules/UniqueDirectivesPerLocationRule.js +4 -4
  288. package/validation/rules/UniqueDirectivesPerLocationRule.js.flow +0 -1
  289. package/validation/rules/UniqueEnumValueNames.js +1 -1
  290. package/validation/rules/UniqueEnumValueNames.js.flow +0 -1
  291. package/validation/rules/UniqueEnumValueNamesRule.js +2 -2
  292. package/validation/rules/UniqueEnumValueNamesRule.js.flow +7 -2
  293. package/validation/rules/UniqueFieldDefinitionNames.js +1 -1
  294. package/validation/rules/UniqueFieldDefinitionNames.js.flow +0 -1
  295. package/validation/rules/UniqueFieldDefinitionNamesRule.js +3 -3
  296. package/validation/rules/UniqueFieldDefinitionNamesRule.js.flow +13 -4
  297. package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +1 -1
  298. package/validation/rules/UniqueFragmentNamesRule.js +1 -1
  299. package/validation/rules/UniqueFragmentNamesRule.js.flow +0 -1
  300. package/validation/rules/UniqueInputFieldNamesRule.js +1 -1
  301. package/validation/rules/UniqueInputFieldNamesRule.js.flow +0 -1
  302. package/validation/rules/UniqueOperationNamesRule.js +1 -1
  303. package/validation/rules/UniqueOperationNamesRule.js.flow +0 -1
  304. package/validation/rules/UniqueOperationTypes.js +1 -1
  305. package/validation/rules/UniqueOperationTypes.js.flow +0 -1
  306. package/validation/rules/UniqueOperationTypesRule.js +1 -1
  307. package/validation/rules/UniqueOperationTypesRule.js.flow +7 -2
  308. package/validation/rules/UniqueTypeNames.js +1 -1
  309. package/validation/rules/UniqueTypeNames.js.flow +0 -1
  310. package/validation/rules/UniqueTypeNamesRule.js +2 -2
  311. package/validation/rules/UniqueTypeNamesRule.js.flow +0 -1
  312. package/validation/rules/UniqueTypeNamesRule.mjs +1 -1
  313. package/validation/rules/UniqueVariableNamesRule.js +1 -1
  314. package/validation/rules/UniqueVariableNamesRule.js.flow +0 -1
  315. package/validation/rules/ValuesOfCorrectTypeRule.js +8 -8
  316. package/validation/rules/ValuesOfCorrectTypeRule.js.flow +0 -1
  317. package/validation/rules/VariablesAreInputTypesRule.js +4 -4
  318. package/validation/rules/VariablesAreInputTypesRule.js.flow +0 -1
  319. package/validation/rules/VariablesInAllowedPositionRule.js +6 -6
  320. package/validation/rules/VariablesInAllowedPositionRule.js.flow +0 -1
  321. package/validation/rules/custom/NoDeprecatedCustomRule.js +47 -9
  322. package/validation/rules/custom/NoDeprecatedCustomRule.js.flow +56 -13
  323. package/validation/rules/custom/NoDeprecatedCustomRule.mjs +43 -8
  324. package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +3 -3
  325. package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js.flow +0 -1
  326. package/validation/specifiedRules.js +33 -33
  327. package/validation/specifiedRules.js.flow +0 -1
  328. package/validation/validate.js +7 -7
  329. package/validation/validate.js.flow +4 -5
  330. package/version.js +2 -2
  331. package/version.js.flow +2 -3
  332. package/version.mjs +2 -2
  333. package/jsutils/isCollection.js +0 -47
  334. package/jsutils/isCollection.js.flow +0 -39
  335. package/jsutils/isCollection.mjs +0 -40
  336. package/polyfills/flatMap.js +0 -30
  337. package/polyfills/flatMap.js.flow +0 -28
  338. package/polyfills/flatMap.mjs +0 -23
@@ -1,7 +1,4 @@
1
1
  // @flow strict
2
-
3
- import arrayFrom from '../polyfills/arrayFrom';
4
-
5
2
  import type { Path } from '../jsutils/Path';
6
3
  import type { ObjMap } from '../jsutils/ObjMap';
7
4
  import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
@@ -11,11 +8,12 @@ import invariant from '../jsutils/invariant';
11
8
  import devAssert from '../jsutils/devAssert';
12
9
  import isPromise from '../jsutils/isPromise';
13
10
  import isObjectLike from '../jsutils/isObjectLike';
14
- import isCollection from '../jsutils/isCollection';
11
+ import safeArrayFrom from '../jsutils/safeArrayFrom';
15
12
  import promiseReduce from '../jsutils/promiseReduce';
16
13
  import promiseForObject from '../jsutils/promiseForObject';
17
14
  import { addPath, pathToArray } from '../jsutils/Path';
18
15
 
16
+ import type { GraphQLFormattedError } from '../error/formatError';
19
17
  import { GraphQLError } from '../error/GraphQLError';
20
18
  import { locatedError } from '../error/locatedError';
21
19
 
@@ -53,6 +51,7 @@ import {
53
51
  GraphQLSkipDirective,
54
52
  } from '../type/directives';
55
53
  import {
54
+ isNamedType,
56
55
  isObjectType,
57
56
  isAbstractType,
58
57
  isLeafType,
@@ -120,6 +119,12 @@ export type ExecutionResult = {|
120
119
  extensions?: ObjMap<mixed>,
121
120
  |};
122
121
 
122
+ export type FormattedExecutionResult = {|
123
+ errors?: $ReadOnlyArray<GraphQLFormattedError>,
124
+ data?: ObjMap<mixed> | null,
125
+ extensions?: ObjMap<mixed>,
126
+ |};
127
+
123
128
  export type ExecutionArgs = {|
124
129
  schema: GraphQLSchema,
125
130
  document: DocumentNode,
@@ -381,8 +386,6 @@ function executeOperation(
381
386
  // Errors from sub-fields of a NonNull type may propagate to the top level,
382
387
  // at which point we still log the error and null the parent field, which
383
388
  // in this case is the entire response.
384
- //
385
- // Similar to completeValueCatchingError.
386
389
  try {
387
390
  const result =
388
391
  operation.operation === 'mutation'
@@ -467,7 +470,7 @@ function executeFields(
467
470
 
468
471
  if (result !== undefined) {
469
472
  results[responseName] = result;
470
- if (!containsPromise && isPromise(result)) {
473
+ if (isPromise(result)) {
471
474
  containsPromise = true;
472
475
  }
473
476
  }
@@ -638,6 +641,7 @@ function resolveField(
638
641
  return;
639
642
  }
640
643
 
644
+ const returnType = fieldDef.type;
641
645
  const resolveFn = fieldDef.resolve ?? exeContext.fieldResolver;
642
646
 
643
647
  const info = buildResolveInfo(
@@ -648,67 +652,7 @@ function resolveField(
648
652
  path,
649
653
  );
650
654
 
651
- // Get the resolve function, regardless of if its result is normal
652
- // or abrupt (error).
653
- const result = resolveFieldValueOrError(
654
- exeContext,
655
- fieldDef,
656
- fieldNodes,
657
- resolveFn,
658
- source,
659
- info,
660
- );
661
-
662
- return completeValueCatchingError(
663
- exeContext,
664
- fieldDef.type,
665
- fieldNodes,
666
- info,
667
- path,
668
- result,
669
- );
670
- }
671
-
672
- /**
673
- * @internal
674
- */
675
- export function buildResolveInfo(
676
- exeContext: ExecutionContext,
677
- fieldDef: GraphQLField<mixed, mixed>,
678
- fieldNodes: $ReadOnlyArray<FieldNode>,
679
- parentType: GraphQLObjectType,
680
- path: Path,
681
- ): GraphQLResolveInfo {
682
- // The resolve function's optional fourth argument is a collection of
683
- // information about the current execution state.
684
- return {
685
- fieldName: fieldDef.name,
686
- fieldNodes,
687
- returnType: fieldDef.type,
688
- parentType,
689
- path,
690
- schema: exeContext.schema,
691
- fragments: exeContext.fragments,
692
- rootValue: exeContext.rootValue,
693
- operation: exeContext.operation,
694
- variableValues: exeContext.variableValues,
695
- };
696
- }
697
-
698
- /**
699
- * Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
700
- * function. Returns the result of resolveFn or the abrupt-return Error object.
701
- *
702
- * @internal
703
- */
704
- export function resolveFieldValueOrError(
705
- exeContext: ExecutionContext,
706
- fieldDef: GraphQLField<mixed, mixed>,
707
- fieldNodes: $ReadOnlyArray<FieldNode>,
708
- resolveFn: GraphQLFieldResolver<mixed, mixed>,
709
- source: mixed,
710
- info: GraphQLResolveInfo,
711
- ): Error | mixed {
655
+ // Get the resolve function, regardless of if its result is normal or abrupt (error).
712
656
  try {
713
657
  // Build a JS object of arguments from the field.arguments AST, using the
714
658
  // variables scope to fulfill any variable references.
@@ -725,32 +669,7 @@ export function resolveFieldValueOrError(
725
669
  const contextValue = exeContext.contextValue;
726
670
 
727
671
  const result = resolveFn(source, args, contextValue, info);
728
- return isPromise(result) ? result.then(undefined, asErrorInstance) : result;
729
- } catch (error) {
730
- return asErrorInstance(error);
731
- }
732
- }
733
-
734
- // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a
735
- // consistent Error interface.
736
- function asErrorInstance(error: mixed): Error {
737
- if (error instanceof Error) {
738
- return error;
739
- }
740
- return new Error('Unexpected error value: ' + inspect(error));
741
- }
742
672
 
743
- // This is a small wrapper around completeValue which detects and logs errors
744
- // in the execution context.
745
- function completeValueCatchingError(
746
- exeContext: ExecutionContext,
747
- returnType: GraphQLOutputType,
748
- fieldNodes: $ReadOnlyArray<FieldNode>,
749
- info: GraphQLResolveInfo,
750
- path: Path,
751
- result: mixed,
752
- ): PromiseOrValue<mixed> {
753
- try {
754
673
  let completed;
755
674
  if (isPromise(result)) {
756
675
  completed = result.then((resolved) =>
@@ -770,23 +689,49 @@ function completeValueCatchingError(
770
689
  if (isPromise(completed)) {
771
690
  // Note: we don't rely on a `catch` method, but we do expect "thenable"
772
691
  // to take a second callback for the error case.
773
- return completed.then(undefined, (error) =>
774
- handleFieldError(error, fieldNodes, path, returnType, exeContext),
775
- );
692
+ return completed.then(undefined, (rawError) => {
693
+ const error = locatedError(rawError, fieldNodes, pathToArray(path));
694
+ return handleFieldError(error, returnType, exeContext);
695
+ });
776
696
  }
777
697
  return completed;
778
- } catch (error) {
779
- return handleFieldError(error, fieldNodes, path, returnType, exeContext);
698
+ } catch (rawError) {
699
+ const error = locatedError(rawError, fieldNodes, pathToArray(path));
700
+ return handleFieldError(error, returnType, exeContext);
780
701
  }
781
702
  }
782
703
 
783
- function handleFieldError(rawError, fieldNodes, path, returnType, exeContext) {
784
- const error = locatedError(
785
- asErrorInstance(rawError),
704
+ /**
705
+ * @internal
706
+ */
707
+ export function buildResolveInfo(
708
+ exeContext: ExecutionContext,
709
+ fieldDef: GraphQLField<mixed, mixed>,
710
+ fieldNodes: $ReadOnlyArray<FieldNode>,
711
+ parentType: GraphQLObjectType,
712
+ path: Path,
713
+ ): GraphQLResolveInfo {
714
+ // The resolve function's optional fourth argument is a collection of
715
+ // information about the current execution state.
716
+ return {
717
+ fieldName: fieldDef.name,
786
718
  fieldNodes,
787
- pathToArray(path),
788
- );
719
+ returnType: fieldDef.type,
720
+ parentType,
721
+ path,
722
+ schema: exeContext.schema,
723
+ fragments: exeContext.fragments,
724
+ rootValue: exeContext.rootValue,
725
+ operation: exeContext.operation,
726
+ variableValues: exeContext.variableValues,
727
+ };
728
+ }
789
729
 
730
+ function handleFieldError(
731
+ error: GraphQLError,
732
+ returnType: GraphQLOutputType,
733
+ exeContext: ExecutionContext,
734
+ ): null {
790
735
  // If the field type is non-nullable, then it is resolved without any
791
736
  // protection from errors, however it still properly locates the error.
792
737
  if (isNonNullType(returnType)) {
@@ -921,36 +866,64 @@ function completeListValue(
921
866
  path: Path,
922
867
  result: mixed,
923
868
  ): PromiseOrValue<$ReadOnlyArray<mixed>> {
924
- if (!isCollection(result)) {
925
- throw new GraphQLError(
926
- `Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`,
927
- );
928
- }
929
-
930
869
  // This is specified as a simple map, however we're optimizing the path
931
870
  // where the list contains no Promises by avoiding creating another Promise.
932
871
  const itemType = returnType.ofType;
933
872
  let containsPromise = false;
934
- const completedResults = arrayFrom(result, (item, index) => {
873
+ const completedResults = safeArrayFrom(result, (item, index) => {
935
874
  // No need to modify the info object containing the path,
936
875
  // since from here on it is not ever accessed by resolver functions.
937
- const fieldPath = addPath(path, index, undefined);
938
- const completedItem = completeValueCatchingError(
939
- exeContext,
940
- itemType,
941
- fieldNodes,
942
- info,
943
- fieldPath,
944
- item,
945
- );
876
+ const itemPath = addPath(path, index, undefined);
877
+ try {
878
+ let completedItem;
879
+ if (isPromise(item)) {
880
+ completedItem = item.then((resolved) =>
881
+ completeValue(
882
+ exeContext,
883
+ itemType,
884
+ fieldNodes,
885
+ info,
886
+ itemPath,
887
+ resolved,
888
+ ),
889
+ );
890
+ } else {
891
+ completedItem = completeValue(
892
+ exeContext,
893
+ itemType,
894
+ fieldNodes,
895
+ info,
896
+ itemPath,
897
+ item,
898
+ );
899
+ }
946
900
 
947
- if (!containsPromise && isPromise(completedItem)) {
948
- containsPromise = true;
901
+ if (isPromise(completedItem)) {
902
+ containsPromise = true;
903
+ // Note: we don't rely on a `catch` method, but we do expect "thenable"
904
+ // to take a second callback for the error case.
905
+ return completedItem.then(undefined, (rawError) => {
906
+ const error = locatedError(
907
+ rawError,
908
+ fieldNodes,
909
+ pathToArray(itemPath),
910
+ );
911
+ return handleFieldError(error, itemType, exeContext);
912
+ });
913
+ }
914
+ return completedItem;
915
+ } catch (rawError) {
916
+ const error = locatedError(rawError, fieldNodes, pathToArray(itemPath));
917
+ return handleFieldError(error, itemType, exeContext);
949
918
  }
950
-
951
- return completedItem;
952
919
  });
953
920
 
921
+ if (completedResults == null) {
922
+ throw new GraphQLError(
923
+ `Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`,
924
+ );
925
+ }
926
+
954
927
  return containsPromise ? Promise.all(completedResults) : completedResults;
955
928
  }
956
929
 
@@ -1023,23 +996,43 @@ function completeAbstractValue(
1023
996
  }
1024
997
 
1025
998
  function ensureValidRuntimeType(
1026
- runtimeTypeOrName: ?GraphQLObjectType | string,
999
+ runtimeTypeOrName: mixed,
1027
1000
  exeContext: ExecutionContext,
1028
1001
  returnType: GraphQLAbstractType,
1029
1002
  fieldNodes: $ReadOnlyArray<FieldNode>,
1030
1003
  info: GraphQLResolveInfo,
1031
1004
  result: mixed,
1032
1005
  ): GraphQLObjectType {
1033
- const runtimeType =
1034
- typeof runtimeTypeOrName === 'string'
1035
- ? exeContext.schema.getType(runtimeTypeOrName)
1036
- : runtimeTypeOrName;
1006
+ if (runtimeTypeOrName == null) {
1007
+ throw new GraphQLError(
1008
+ `Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}". Either the "${returnType.name}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`,
1009
+ fieldNodes,
1010
+ );
1011
+ }
1037
1012
 
1038
- if (!isObjectType(runtimeType)) {
1013
+ // FIXME: temporary workaround until support for passing object types would be removed in v16.0.0
1014
+ const runtimeTypeName = isNamedType(runtimeTypeOrName)
1015
+ ? runtimeTypeOrName.name
1016
+ : runtimeTypeOrName;
1017
+
1018
+ if (typeof runtimeTypeName !== 'string') {
1039
1019
  throw new GraphQLError(
1040
1020
  `Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}" with ` +
1041
- `value ${inspect(result)}, received "${inspect(runtimeType)}". ` +
1042
- `Either the "${returnType.name}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`,
1021
+ `value ${inspect(result)}, received "${inspect(runtimeTypeOrName)}".`,
1022
+ );
1023
+ }
1024
+
1025
+ const runtimeType = exeContext.schema.getType(runtimeTypeName);
1026
+ if (runtimeType == null) {
1027
+ throw new GraphQLError(
1028
+ `Abstract type "${returnType.name}" was resolve to a type "${runtimeTypeName}" that does not exist inside schema.`,
1029
+ fieldNodes,
1030
+ );
1031
+ }
1032
+
1033
+ if (!isObjectType(runtimeType)) {
1034
+ throw new GraphQLError(
1035
+ `Abstract type "${returnType.name}" was resolve to a non-object type "${runtimeTypeName}".`,
1043
1036
  fieldNodes,
1044
1037
  );
1045
1038
  }
@@ -1184,7 +1177,7 @@ export const defaultTypeResolver: GraphQLTypeResolver<mixed, mixed> = function (
1184
1177
  if (isPromise(isTypeOfResult)) {
1185
1178
  promisedIsTypeOfResults[i] = isTypeOfResult;
1186
1179
  } else if (isTypeOfResult) {
1187
- return type;
1180
+ return type.name;
1188
1181
  }
1189
1182
  }
1190
1183
  }
@@ -1193,7 +1186,7 @@ export const defaultTypeResolver: GraphQLTypeResolver<mixed, mixed> = function (
1193
1186
  return Promise.all(promisedIsTypeOfResults).then((isTypeOfResults) => {
1194
1187
  for (let i = 0; i < isTypeOfResults.length; i++) {
1195
1188
  if (isTypeOfResults[i]) {
1196
- return possibleTypes[i];
1189
+ return possibleTypes[i].name;
1197
1190
  }
1198
1191
  }
1199
1192
  });
@@ -1222,12 +1215,12 @@ export const defaultFieldResolver: GraphQLFieldResolver<
1222
1215
 
1223
1216
  /**
1224
1217
  * This method looks up the field on the given type definition.
1225
- * It has special casing for the two introspection fields, __schema
1226
- * and __typename. __typename is special because it can always be
1227
- * queried as a field, even in situations where no other fields
1228
- * are allowed, like on a Union. __schema could get automatically
1229
- * added to the query type, but that would require mutating type
1230
- * definitions, which would cause issues.
1218
+ * It has special casing for the three introspection fields,
1219
+ * __schema, __type and __typename. __typename is special because
1220
+ * it can always be queried as a field, even in situations where no
1221
+ * other fields are allowed, like on a Union. __schema and __type
1222
+ * could get automatically added to the query type, but that would
1223
+ * require mutating type definitions, which would cause issues.
1231
1224
  *
1232
1225
  * @internal
1233
1226
  */
@@ -1,11 +1,10 @@
1
- import arrayFrom from "../polyfills/arrayFrom.mjs";
2
1
  import inspect from "../jsutils/inspect.mjs";
3
2
  import memoize3 from "../jsutils/memoize3.mjs";
4
3
  import invariant from "../jsutils/invariant.mjs";
5
4
  import devAssert from "../jsutils/devAssert.mjs";
6
5
  import isPromise from "../jsutils/isPromise.mjs";
7
6
  import isObjectLike from "../jsutils/isObjectLike.mjs";
8
- import isCollection from "../jsutils/isCollection.mjs";
7
+ import safeArrayFrom from "../jsutils/safeArrayFrom.mjs";
9
8
  import promiseReduce from "../jsutils/promiseReduce.mjs";
10
9
  import promiseForObject from "../jsutils/promiseForObject.mjs";
11
10
  import { addPath, pathToArray } from "../jsutils/Path.mjs";
@@ -15,7 +14,7 @@ import { Kind } from "../language/kinds.mjs";
15
14
  import { assertValidSchema } from "../type/validate.mjs";
16
15
  import { SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef } from "../type/introspection.mjs";
17
16
  import { GraphQLIncludeDirective, GraphQLSkipDirective } from "../type/directives.mjs";
18
- import { isObjectType, isAbstractType, isLeafType, isListType, isNonNullType } from "../type/definition.mjs";
17
+ import { isNamedType, isObjectType, isAbstractType, isLeafType, isListType, isNonNullType } from "../type/definition.mjs";
19
18
  import { typeFromAST } from "../utilities/typeFromAST.mjs";
20
19
  import { getOperationRootType } from "../utilities/getOperationRootType.mjs";
21
20
  import { getVariableValues, getArgumentValues, getDirectiveValues } from "./values.mjs";
@@ -220,8 +219,6 @@ function executeOperation(exeContext, operation, rootValue) {
220
219
  var path = undefined; // Errors from sub-fields of a NonNull type may propagate to the top level,
221
220
  // at which point we still log the error and null the parent field, which
222
221
  // in this case is the entire response.
223
- //
224
- // Similar to completeValueCatchingError.
225
222
 
226
223
  try {
227
224
  var result = operation.operation === 'mutation' ? executeFieldsSerially(exeContext, type, rootValue, path, fields) : executeFields(exeContext, type, rootValue, path, fields);
@@ -285,7 +282,7 @@ function executeFields(exeContext, parentType, sourceValue, path, fields) {
285
282
  if (result !== undefined) {
286
283
  results[responseName] = result;
287
284
 
288
- if (!containsPromise && isPromise(result)) {
285
+ if (isPromise(result)) {
289
286
  containsPromise = true;
290
287
  }
291
288
  }
@@ -438,42 +435,10 @@ function resolveField(exeContext, parentType, source, fieldNodes, path) {
438
435
  return;
439
436
  }
440
437
 
438
+ var returnType = fieldDef.type;
441
439
  var resolveFn = (_fieldDef$resolve = fieldDef.resolve) !== null && _fieldDef$resolve !== void 0 ? _fieldDef$resolve : exeContext.fieldResolver;
442
- var info = buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path); // Get the resolve function, regardless of if its result is normal
443
- // or abrupt (error).
444
-
445
- var result = resolveFieldValueOrError(exeContext, fieldDef, fieldNodes, resolveFn, source, info);
446
- return completeValueCatchingError(exeContext, fieldDef.type, fieldNodes, info, path, result);
447
- }
448
- /**
449
- * @internal
450
- */
451
-
452
-
453
- export function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) {
454
- // The resolve function's optional fourth argument is a collection of
455
- // information about the current execution state.
456
- return {
457
- fieldName: fieldDef.name,
458
- fieldNodes: fieldNodes,
459
- returnType: fieldDef.type,
460
- parentType: parentType,
461
- path: path,
462
- schema: exeContext.schema,
463
- fragments: exeContext.fragments,
464
- rootValue: exeContext.rootValue,
465
- operation: exeContext.operation,
466
- variableValues: exeContext.variableValues
467
- };
468
- }
469
- /**
470
- * Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
471
- * function. Returns the result of resolveFn or the abrupt-return Error object.
472
- *
473
- * @internal
474
- */
440
+ var info = buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path); // Get the resolve function, regardless of if its result is normal or abrupt (error).
475
441
 
476
- export function resolveFieldValueOrError(exeContext, fieldDef, fieldNodes, resolveFn, source, info) {
477
442
  try {
478
443
  // Build a JS object of arguments from the field.arguments AST, using the
479
444
  // variables scope to fulfill any variable references.
@@ -484,25 +449,6 @@ export function resolveFieldValueOrError(exeContext, fieldDef, fieldNodes, resol
484
449
 
485
450
  var _contextValue = exeContext.contextValue;
486
451
  var result = resolveFn(source, args, _contextValue, info);
487
- return isPromise(result) ? result.then(undefined, asErrorInstance) : result;
488
- } catch (error) {
489
- return asErrorInstance(error);
490
- }
491
- } // Sometimes a non-error is thrown, wrap it as an Error instance to ensure a
492
- // consistent Error interface.
493
-
494
- function asErrorInstance(error) {
495
- if (error instanceof Error) {
496
- return error;
497
- }
498
-
499
- return new Error('Unexpected error value: ' + inspect(error));
500
- } // This is a small wrapper around completeValue which detects and logs errors
501
- // in the execution context.
502
-
503
-
504
- function completeValueCatchingError(exeContext, returnType, fieldNodes, info, path, result) {
505
- try {
506
452
  var completed;
507
453
 
508
454
  if (isPromise(result)) {
@@ -516,21 +462,43 @@ function completeValueCatchingError(exeContext, returnType, fieldNodes, info, pa
516
462
  if (isPromise(completed)) {
517
463
  // Note: we don't rely on a `catch` method, but we do expect "thenable"
518
464
  // to take a second callback for the error case.
519
- return completed.then(undefined, function (error) {
520
- return handleFieldError(error, fieldNodes, path, returnType, exeContext);
465
+ return completed.then(undefined, function (rawError) {
466
+ var error = locatedError(rawError, fieldNodes, pathToArray(path));
467
+ return handleFieldError(error, returnType, exeContext);
521
468
  });
522
469
  }
523
470
 
524
471
  return completed;
525
- } catch (error) {
526
- return handleFieldError(error, fieldNodes, path, returnType, exeContext);
472
+ } catch (rawError) {
473
+ var error = locatedError(rawError, fieldNodes, pathToArray(path));
474
+ return handleFieldError(error, returnType, exeContext);
527
475
  }
528
476
  }
477
+ /**
478
+ * @internal
479
+ */
480
+
481
+
482
+ export function buildResolveInfo(exeContext, fieldDef, fieldNodes, parentType, path) {
483
+ // The resolve function's optional fourth argument is a collection of
484
+ // information about the current execution state.
485
+ return {
486
+ fieldName: fieldDef.name,
487
+ fieldNodes: fieldNodes,
488
+ returnType: fieldDef.type,
489
+ parentType: parentType,
490
+ path: path,
491
+ schema: exeContext.schema,
492
+ fragments: exeContext.fragments,
493
+ rootValue: exeContext.rootValue,
494
+ operation: exeContext.operation,
495
+ variableValues: exeContext.variableValues
496
+ };
497
+ }
529
498
 
530
- function handleFieldError(rawError, fieldNodes, path, returnType, exeContext) {
531
- var error = locatedError(asErrorInstance(rawError), fieldNodes, pathToArray(path)); // If the field type is non-nullable, then it is resolved without any
499
+ function handleFieldError(error, returnType, exeContext) {
500
+ // If the field type is non-nullable, then it is resolved without any
532
501
  // protection from errors, however it still properly locates the error.
533
-
534
502
  if (isNonNullType(returnType)) {
535
503
  throw error;
536
504
  } // Otherwise, error protection is applied, logging the error and resolving
@@ -619,26 +587,47 @@ function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
619
587
 
620
588
 
621
589
  function completeListValue(exeContext, returnType, fieldNodes, info, path, result) {
622
- if (!isCollection(result)) {
623
- throw new GraphQLError("Expected Iterable, but did not find one for field \"".concat(info.parentType.name, ".").concat(info.fieldName, "\"."));
624
- } // This is specified as a simple map, however we're optimizing the path
590
+ // This is specified as a simple map, however we're optimizing the path
625
591
  // where the list contains no Promises by avoiding creating another Promise.
626
-
627
-
628
592
  var itemType = returnType.ofType;
629
593
  var containsPromise = false;
630
- var completedResults = arrayFrom(result, function (item, index) {
594
+ var completedResults = safeArrayFrom(result, function (item, index) {
631
595
  // No need to modify the info object containing the path,
632
596
  // since from here on it is not ever accessed by resolver functions.
633
- var fieldPath = addPath(path, index, undefined);
634
- var completedItem = completeValueCatchingError(exeContext, itemType, fieldNodes, info, fieldPath, item);
597
+ var itemPath = addPath(path, index, undefined);
635
598
 
636
- if (!containsPromise && isPromise(completedItem)) {
637
- containsPromise = true;
638
- }
599
+ try {
600
+ var completedItem;
601
+
602
+ if (isPromise(item)) {
603
+ completedItem = item.then(function (resolved) {
604
+ return completeValue(exeContext, itemType, fieldNodes, info, itemPath, resolved);
605
+ });
606
+ } else {
607
+ completedItem = completeValue(exeContext, itemType, fieldNodes, info, itemPath, item);
608
+ }
639
609
 
640
- return completedItem;
610
+ if (isPromise(completedItem)) {
611
+ containsPromise = true; // Note: we don't rely on a `catch` method, but we do expect "thenable"
612
+ // to take a second callback for the error case.
613
+
614
+ return completedItem.then(undefined, function (rawError) {
615
+ var error = locatedError(rawError, fieldNodes, pathToArray(itemPath));
616
+ return handleFieldError(error, itemType, exeContext);
617
+ });
618
+ }
619
+
620
+ return completedItem;
621
+ } catch (rawError) {
622
+ var error = locatedError(rawError, fieldNodes, pathToArray(itemPath));
623
+ return handleFieldError(error, itemType, exeContext);
624
+ }
641
625
  });
626
+
627
+ if (completedResults == null) {
628
+ throw new GraphQLError("Expected Iterable, but did not find one for field \"".concat(info.parentType.name, ".").concat(info.fieldName, "\"."));
629
+ }
630
+
642
631
  return containsPromise ? Promise.all(completedResults) : completedResults;
643
632
  }
644
633
  /**
@@ -679,10 +668,25 @@ function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, r
679
668
  }
680
669
 
681
670
  function ensureValidRuntimeType(runtimeTypeOrName, exeContext, returnType, fieldNodes, info, result) {
682
- var runtimeType = typeof runtimeTypeOrName === 'string' ? exeContext.schema.getType(runtimeTypeOrName) : runtimeTypeOrName;
671
+ if (runtimeTypeOrName == null) {
672
+ throw new GraphQLError("Abstract type \"".concat(returnType.name, "\" must resolve to an Object type at runtime for field \"").concat(info.parentType.name, ".").concat(info.fieldName, "\". Either the \"").concat(returnType.name, "\" type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function."), fieldNodes);
673
+ } // FIXME: temporary workaround until support for passing object types would be removed in v16.0.0
674
+
675
+
676
+ var runtimeTypeName = isNamedType(runtimeTypeOrName) ? runtimeTypeOrName.name : runtimeTypeOrName;
677
+
678
+ if (typeof runtimeTypeName !== 'string') {
679
+ throw new GraphQLError("Abstract type \"".concat(returnType.name, "\" must resolve to an Object type at runtime for field \"").concat(info.parentType.name, ".").concat(info.fieldName, "\" with ") + "value ".concat(inspect(result), ", received \"").concat(inspect(runtimeTypeOrName), "\"."));
680
+ }
681
+
682
+ var runtimeType = exeContext.schema.getType(runtimeTypeName);
683
+
684
+ if (runtimeType == null) {
685
+ throw new GraphQLError("Abstract type \"".concat(returnType.name, "\" was resolve to a type \"").concat(runtimeTypeName, "\" that does not exist inside schema."), fieldNodes);
686
+ }
683
687
 
684
688
  if (!isObjectType(runtimeType)) {
685
- throw new GraphQLError("Abstract type \"".concat(returnType.name, "\" must resolve to an Object type at runtime for field \"").concat(info.parentType.name, ".").concat(info.fieldName, "\" with ") + "value ".concat(inspect(result), ", received \"").concat(inspect(runtimeType), "\". ") + "Either the \"".concat(returnType.name, "\" type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function."), fieldNodes);
689
+ throw new GraphQLError("Abstract type \"".concat(returnType.name, "\" was resolve to a non-object type \"").concat(runtimeTypeName, "\"."), fieldNodes);
686
690
  }
687
691
 
688
692
  if (!exeContext.schema.isSubType(returnType, runtimeType)) {
@@ -784,7 +788,7 @@ export var defaultTypeResolver = function defaultTypeResolver(value, contextValu
784
788
  if (isPromise(isTypeOfResult)) {
785
789
  promisedIsTypeOfResults[i] = isTypeOfResult;
786
790
  } else if (isTypeOfResult) {
787
- return type;
791
+ return type.name;
788
792
  }
789
793
  }
790
794
  }
@@ -793,7 +797,7 @@ export var defaultTypeResolver = function defaultTypeResolver(value, contextValu
793
797
  return Promise.all(promisedIsTypeOfResults).then(function (isTypeOfResults) {
794
798
  for (var _i9 = 0; _i9 < isTypeOfResults.length; _i9++) {
795
799
  if (isTypeOfResults[_i9]) {
796
- return possibleTypes[_i9];
800
+ return possibleTypes[_i9].name;
797
801
  }
798
802
  }
799
803
  });
@@ -820,12 +824,12 @@ export var defaultFieldResolver = function defaultFieldResolver(source, args, co
820
824
  };
821
825
  /**
822
826
  * This method looks up the field on the given type definition.
823
- * It has special casing for the two introspection fields, __schema
824
- * and __typename. __typename is special because it can always be
825
- * queried as a field, even in situations where no other fields
826
- * are allowed, like on a Union. __schema could get automatically
827
- * added to the query type, but that would require mutating type
828
- * definitions, which would cause issues.
827
+ * It has special casing for the three introspection fields,
828
+ * __schema, __type and __typename. __typename is special because
829
+ * it can always be queried as a field, even in situations where no
830
+ * other fields are allowed, like on a Union. __schema and __type
831
+ * could get automatically added to the query type, but that would
832
+ * require mutating type definitions, which would cause issues.
829
833
  *
830
834
  * @internal
831
835
  */