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
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -17,15 +17,18 @@ import { typeFromAST } from '../utilities/typeFromAST';
17
17
  import { valueFromAST } from '../utilities/valueFromAST';
18
18
  import { Kind } from '../language/kinds';
19
19
  import { print } from '../language/printer';
20
- import { isInputType, isNonNullType } from '../type/definition';
21
- import type { ObjMap } from '../jsutils/ObjMap';
22
- import type { GraphQLField } from '../type/definition';
23
- import type { GraphQLDirective } from '../type/directives';
24
- import type { GraphQLSchema } from '../type/schema';
25
- import type {
26
- FieldNode,
27
- DirectiveNode,
28
- VariableDefinitionNode,
20
+ import {
21
+ type GraphQLField,
22
+ isInputType,
23
+ isNonNullType,
24
+ } from '../type/definition';
25
+ import { type GraphQLDirective } from '../type/directives';
26
+ import { type ObjMap } from '../jsutils/ObjMap';
27
+ import { type GraphQLSchema } from '../type/schema';
28
+ import {
29
+ type FieldNode,
30
+ type DirectiveNode,
31
+ type VariableDefinitionNode,
29
32
  } from '../language/ast';
30
33
 
31
34
  type CoercedVariableValues = {|
@@ -62,7 +65,7 @@ export function getVariableValues(
62
65
  `"${print(
63
66
  varDefNode.type,
64
67
  )}" which cannot be used as an input type.`,
65
- [varDefNode.type],
68
+ varDefNode.type,
66
69
  ),
67
70
  );
68
71
  } else {
@@ -82,7 +85,7 @@ export function getVariableValues(
82
85
  `"${inspect(varType)}" must not be null.`
83
86
  : `Variable "$${varName}" of required type ` +
84
87
  `"${inspect(varType)}" was not provided.`,
85
- [varDefNode],
88
+ varDefNode,
86
89
  ),
87
90
  );
88
91
  } else if (hasValue) {
@@ -143,11 +146,12 @@ export function getArgumentValues(
143
146
  let isNull;
144
147
  if (argumentNode && argumentNode.value.kind === Kind.VARIABLE) {
145
148
  const variableName = argumentNode.value.name.value;
146
- hasValue = variableValues && hasOwnProperty(variableValues, variableName);
147
- isNull = variableValues && variableValues[variableName] === null;
149
+ hasValue =
150
+ variableValues != null && hasOwnProperty(variableValues, variableName);
151
+ isNull = variableValues != null && variableValues[variableName] === null;
148
152
  } else {
149
153
  hasValue = argumentNode != null;
150
- isNull = argumentNode && argumentNode.value.kind === Kind.NULL;
154
+ isNull = argumentNode != null && argumentNode.value.kind === Kind.NULL;
151
155
  }
152
156
 
153
157
  if (!hasValue && argDef.defaultValue !== undefined) {
@@ -161,7 +165,7 @@ export function getArgumentValues(
161
165
  throw new GraphQLError(
162
166
  `Argument "${name}" of non-null type "${inspect(argType)}" ` +
163
167
  'must not be null.',
164
- [argumentNode.value],
168
+ argumentNode.value,
165
169
  );
166
170
  } else if (argumentNode && argumentNode.value.kind === Kind.VARIABLE) {
167
171
  const variableName = argumentNode.value.name.value;
@@ -169,13 +173,13 @@ export function getArgumentValues(
169
173
  `Argument "${name}" of required type "${inspect(argType)}" ` +
170
174
  `was provided the variable "$${variableName}" ` +
171
175
  'which was not provided a runtime value.',
172
- [argumentNode.value],
176
+ argumentNode.value,
173
177
  );
174
178
  } else {
175
179
  throw new GraphQLError(
176
180
  `Argument "${name}" of required type "${inspect(argType)}" ` +
177
181
  'was not provided.',
178
- [node],
182
+ node,
179
183
  );
180
184
  }
181
185
  } else if (hasValue) {
@@ -199,7 +203,7 @@ export function getArgumentValues(
199
203
  // continue with an invalid argument value.
200
204
  throw new GraphQLError(
201
205
  `Argument "${name}" has invalid value ${print(valueNode)}.`,
202
- [argumentNode.value],
206
+ argumentNode.value,
203
207
  );
204
208
  }
205
209
  coercedValues[name] = coercedValue;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -39,7 +39,7 @@ export function getVariableValues(schema, varDefNodes, inputs) {
39
39
  if (!isInputType(varType)) {
40
40
  // Must use input types for variables. This should be caught during
41
41
  // validation, however is checked again here for safety.
42
- errors.push(new GraphQLError("Variable \"$".concat(varName, "\" expected value of type ") + "\"".concat(print(varDefNode.type), "\" which cannot be used as an input type."), [varDefNode.type]));
42
+ errors.push(new GraphQLError("Variable \"$".concat(varName, "\" expected value of type ") + "\"".concat(print(varDefNode.type), "\" which cannot be used as an input type."), varDefNode.type));
43
43
  } else {
44
44
  var hasValue = hasOwnProperty(inputs, varName);
45
45
  var value = hasValue ? inputs[varName] : undefined;
@@ -51,7 +51,7 @@ export function getVariableValues(schema, varDefNodes, inputs) {
51
51
  } else if ((!hasValue || value === null) && isNonNullType(varType)) {
52
52
  // If no value or a nullish value was provided to a variable with a
53
53
  // non-null type (required), produce an error.
54
- errors.push(new GraphQLError(hasValue ? "Variable \"$".concat(varName, "\" of non-null type ") + "\"".concat(inspect(varType), "\" must not be null.") : "Variable \"$".concat(varName, "\" of required type ") + "\"".concat(inspect(varType), "\" was not provided."), [varDefNode]));
54
+ errors.push(new GraphQLError(hasValue ? "Variable \"$".concat(varName, "\" of non-null type ") + "\"".concat(inspect(varType), "\" must not be null.") : "Variable \"$".concat(varName, "\" of required type ") + "\"".concat(inspect(varType), "\" was not provided."), varDefNode));
55
55
  } else if (hasValue) {
56
56
  if (value === null) {
57
57
  // If the explicit value `null` was provided, an entry in the coerced
@@ -137,11 +137,11 @@ export function getArgumentValues(def, node, variableValues) {
137
137
 
138
138
  if (argumentNode && argumentNode.value.kind === Kind.VARIABLE) {
139
139
  var variableName = argumentNode.value.name.value;
140
- hasValue = variableValues && hasOwnProperty(variableValues, variableName);
141
- isNull = variableValues && variableValues[variableName] === null;
140
+ hasValue = variableValues != null && hasOwnProperty(variableValues, variableName);
141
+ isNull = variableValues != null && variableValues[variableName] === null;
142
142
  } else {
143
143
  hasValue = argumentNode != null;
144
- isNull = argumentNode && argumentNode.value.kind === Kind.NULL;
144
+ isNull = argumentNode != null && argumentNode.value.kind === Kind.NULL;
145
145
  }
146
146
 
147
147
  if (!hasValue && argDef.defaultValue !== undefined) {
@@ -152,12 +152,12 @@ export function getArgumentValues(def, node, variableValues) {
152
152
  // If no argument or a null value was provided to an argument with a
153
153
  // non-null type (required), produce a field error.
154
154
  if (isNull) {
155
- throw new GraphQLError("Argument \"".concat(name, "\" of non-null type \"").concat(inspect(argType), "\" ") + 'must not be null.', [argumentNode.value]);
155
+ throw new GraphQLError("Argument \"".concat(name, "\" of non-null type \"").concat(inspect(argType), "\" ") + 'must not be null.', argumentNode.value);
156
156
  } else if (argumentNode && argumentNode.value.kind === Kind.VARIABLE) {
157
157
  var _variableName = argumentNode.value.name.value;
158
- throw new GraphQLError("Argument \"".concat(name, "\" of required type \"").concat(inspect(argType), "\" ") + "was provided the variable \"$".concat(_variableName, "\" ") + 'which was not provided a runtime value.', [argumentNode.value]);
158
+ throw new GraphQLError("Argument \"".concat(name, "\" of required type \"").concat(inspect(argType), "\" ") + "was provided the variable \"$".concat(_variableName, "\" ") + 'which was not provided a runtime value.', argumentNode.value);
159
159
  } else {
160
- throw new GraphQLError("Argument \"".concat(name, "\" of required type \"").concat(inspect(argType), "\" ") + 'was not provided.', [node]);
160
+ throw new GraphQLError("Argument \"".concat(name, "\" of required type \"").concat(inspect(argType), "\" ") + 'was not provided.', node);
161
161
  }
162
162
  } else if (hasValue) {
163
163
  if (argumentNode.value.kind === Kind.NULL) {
@@ -179,7 +179,7 @@ export function getArgumentValues(def, node, variableValues) {
179
179
  // Note: ValuesOfCorrectType validation should catch this before
180
180
  // execution. This is a runtime check to ensure execution does not
181
181
  // continue with an invalid argument value.
182
- throw new GraphQLError("Argument \"".concat(name, "\" has invalid value ").concat(print(valueNode), "."), [argumentNode.value]);
182
+ throw new GraphQLError("Argument \"".concat(name, "\" has invalid value ").concat(print(valueNode), "."), argumentNode.value);
183
183
  }
184
184
 
185
185
  coercedValues[name] = coercedValue;
@@ -213,4 +213,4 @@ export function getDirectiveValues(directiveDef, node, variableValues) {
213
213
 
214
214
  function hasOwnProperty(obj, prop) {
215
215
  return Object.prototype.hasOwnProperty.call(obj, prop);
216
- }
216
+ }
package/graphql.js CHANGED
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.graphql = graphql;
7
7
  exports.graphqlSync = graphqlSync;
8
8
 
9
+ var _isPromise = _interopRequireDefault(require("./jsutils/isPromise"));
10
+
9
11
  var _validate = require("./type/validate");
10
12
 
11
13
  var _parser = require("./language/parser");
@@ -14,22 +16,24 @@ var _validate2 = require("./validation/validate");
14
16
 
15
17
  var _execute = require("./execution/execute");
16
18
 
19
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+
17
21
  /**
18
- * Copyright (c) 2015-present, Facebook, Inc.
22
+ * Copyright (c) Facebook, Inc. and its affiliates.
19
23
  *
20
24
  * This source code is licensed under the MIT license found in the
21
25
  * LICENSE file in the root directory of this source tree.
22
26
  *
23
27
  *
24
28
  */
25
- function graphql(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver) {
29
+ function graphql(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
26
30
  var _arguments = arguments;
27
31
 
28
32
  /* eslint-enable no-redeclare */
29
33
  // Always return a Promise for a consistent API.
30
34
  return new Promise(function (resolve) {
31
35
  return resolve( // Extract arguments from object args if provided.
32
- _arguments.length === 1 ? graphqlImpl(argsOrSchema.schema, argsOrSchema.source, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver) : graphqlImpl(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver));
36
+ _arguments.length === 1 ? graphqlImpl(argsOrSchema.schema, argsOrSchema.source, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver, argsOrSchema.typeResolver) : graphqlImpl(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver));
33
37
  });
34
38
  }
35
39
  /**
@@ -40,19 +44,19 @@ function graphql(argsOrSchema, source, rootValue, contextValue, variableValues,
40
44
  */
41
45
 
42
46
 
43
- function graphqlSync(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver) {
47
+ function graphqlSync(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
44
48
  /* eslint-enable no-redeclare */
45
49
  // Extract arguments from object args if provided.
46
- var result = arguments.length === 1 ? graphqlImpl(argsOrSchema.schema, argsOrSchema.source, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver) : graphqlImpl(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver); // Assert that the execution was synchronous.
50
+ var result = arguments.length === 1 ? graphqlImpl(argsOrSchema.schema, argsOrSchema.source, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver, argsOrSchema.typeResolver) : graphqlImpl(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver); // Assert that the execution was synchronous.
47
51
 
48
- if (result.then) {
52
+ if ((0, _isPromise.default)(result)) {
49
53
  throw new Error('GraphQL execution failed to complete synchronously.');
50
54
  }
51
55
 
52
56
  return result;
53
57
  }
54
58
 
55
- function graphqlImpl(schema, source, rootValue, contextValue, variableValues, operationName, fieldResolver) {
59
+ function graphqlImpl(schema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
56
60
  // Validate Schema
57
61
  var schemaValidationErrors = (0, _validate.validateSchema)(schema);
58
62
 
@@ -83,5 +87,5 @@ function graphqlImpl(schema, source, rootValue, contextValue, variableValues, op
83
87
  } // Execute
84
88
 
85
89
 
86
- return (0, _execute.execute)(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver);
87
- }
90
+ return (0, _execute.execute)(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver);
91
+ }
package/graphql.js.flow CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -7,16 +7,19 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
+ import isPromise from './jsutils/isPromise';
10
11
  import { validateSchema } from './type/validate';
11
12
  import { parse } from './language/parser';
12
13
  import { validate } from './validation/validate';
13
- import { execute } from './execution/execute';
14
- import type { ObjMap } from './jsutils/ObjMap';
15
- import type { Source } from './language/source';
16
- import type { GraphQLFieldResolver } from './type/definition';
17
- import type { GraphQLSchema } from './type/schema';
18
- import type { ExecutionResult } from './execution/execute';
19
- import type { MaybePromise } from './jsutils/MaybePromise';
14
+ import { type ExecutionResult, execute } from './execution/execute';
15
+ import { type ObjMap } from './jsutils/ObjMap';
16
+ import { type Source } from './language/source';
17
+ import {
18
+ type GraphQLFieldResolver,
19
+ type GraphQLTypeResolver,
20
+ } from './type/definition';
21
+ import { type GraphQLSchema } from './type/schema';
22
+ import { type PromiseOrValue } from './jsutils/PromiseOrValue';
20
23
 
21
24
  /**
22
25
  * This is the primary entry point function for fulfilling GraphQL operations
@@ -52,6 +55,10 @@ import type { MaybePromise } from './jsutils/MaybePromise';
52
55
  * A resolver function to use when one is not provided by the schema.
53
56
  * If not provided, the default field resolver is used (which looks for a
54
57
  * value or method on the source value with the field's name).
58
+ * typeResolver:
59
+ * A type resolver function to use when none is provided by the schema.
60
+ * If not provided, the default type resolver is used (which looks for a
61
+ * `__typename` field or alternatively calls the `isTypeOf` method).
55
62
  */
56
63
  export type GraphQLArgs = {|
57
64
  schema: GraphQLSchema,
@@ -61,6 +68,7 @@ export type GraphQLArgs = {|
61
68
  variableValues?: ?ObjMap<mixed>,
62
69
  operationName?: ?string,
63
70
  fieldResolver?: ?GraphQLFieldResolver<any, any>,
71
+ typeResolver?: ?GraphQLTypeResolver<any, any>,
64
72
  |};
65
73
  declare function graphql(GraphQLArgs, ..._: []): Promise<ExecutionResult>;
66
74
  /* eslint-disable no-redeclare */
@@ -72,6 +80,7 @@ declare function graphql(
72
80
  variableValues?: ?ObjMap<mixed>,
73
81
  operationName?: ?string,
74
82
  fieldResolver?: ?GraphQLFieldResolver<any, any>,
83
+ typeResolver?: ?GraphQLTypeResolver<any, any>,
75
84
  ): Promise<ExecutionResult>;
76
85
  export function graphql(
77
86
  argsOrSchema,
@@ -81,6 +90,7 @@ export function graphql(
81
90
  variableValues,
82
91
  operationName,
83
92
  fieldResolver,
93
+ typeResolver,
84
94
  ) {
85
95
  /* eslint-enable no-redeclare */
86
96
  // Always return a Promise for a consistent API.
@@ -96,6 +106,7 @@ export function graphql(
96
106
  argsOrSchema.variableValues,
97
107
  argsOrSchema.operationName,
98
108
  argsOrSchema.fieldResolver,
109
+ argsOrSchema.typeResolver,
99
110
  )
100
111
  : graphqlImpl(
101
112
  argsOrSchema,
@@ -105,6 +116,7 @@ export function graphql(
105
116
  variableValues,
106
117
  operationName,
107
118
  fieldResolver,
119
+ typeResolver,
108
120
  ),
109
121
  ),
110
122
  );
@@ -126,6 +138,7 @@ declare function graphqlSync(
126
138
  variableValues?: ?ObjMap<mixed>,
127
139
  operationName?: ?string,
128
140
  fieldResolver?: ?GraphQLFieldResolver<any, any>,
141
+ typeResolver?: ?GraphQLTypeResolver<any, any>,
129
142
  ): ExecutionResult;
130
143
  export function graphqlSync(
131
144
  argsOrSchema,
@@ -135,6 +148,7 @@ export function graphqlSync(
135
148
  variableValues,
136
149
  operationName,
137
150
  fieldResolver,
151
+ typeResolver,
138
152
  ) {
139
153
  /* eslint-enable no-redeclare */
140
154
  // Extract arguments from object args if provided.
@@ -148,6 +162,7 @@ export function graphqlSync(
148
162
  argsOrSchema.variableValues,
149
163
  argsOrSchema.operationName,
150
164
  argsOrSchema.fieldResolver,
165
+ argsOrSchema.typeResolver,
151
166
  )
152
167
  : graphqlImpl(
153
168
  argsOrSchema,
@@ -157,10 +172,11 @@ export function graphqlSync(
157
172
  variableValues,
158
173
  operationName,
159
174
  fieldResolver,
175
+ typeResolver,
160
176
  );
161
177
 
162
178
  // Assert that the execution was synchronous.
163
- if (result.then) {
179
+ if (isPromise(result)) {
164
180
  throw new Error('GraphQL execution failed to complete synchronously.');
165
181
  }
166
182
 
@@ -175,7 +191,8 @@ function graphqlImpl(
175
191
  variableValues,
176
192
  operationName,
177
193
  fieldResolver,
178
- ): MaybePromise<ExecutionResult> {
194
+ typeResolver,
195
+ ): PromiseOrValue<ExecutionResult> {
179
196
  // Validate Schema
180
197
  const schemaValidationErrors = validateSchema(schema);
181
198
  if (schemaValidationErrors.length > 0) {
@@ -205,5 +222,6 @@ function graphqlImpl(
205
222
  variableValues,
206
223
  operationName,
207
224
  fieldResolver,
225
+ typeResolver,
208
226
  );
209
227
  }
package/graphql.mjs CHANGED
@@ -1,23 +1,24 @@
1
1
  /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  *
8
8
  */
9
+ import isPromise from './jsutils/isPromise';
9
10
  import { validateSchema } from './type/validate';
10
11
  import { parse } from './language/parser';
11
12
  import { validate } from './validation/validate';
12
13
  import { execute } from './execution/execute';
13
- export function graphql(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver) {
14
+ export function graphql(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
14
15
  var _arguments = arguments;
15
16
 
16
17
  /* eslint-enable no-redeclare */
17
18
  // Always return a Promise for a consistent API.
18
19
  return new Promise(function (resolve) {
19
20
  return resolve( // Extract arguments from object args if provided.
20
- _arguments.length === 1 ? graphqlImpl(argsOrSchema.schema, argsOrSchema.source, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver) : graphqlImpl(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver));
21
+ _arguments.length === 1 ? graphqlImpl(argsOrSchema.schema, argsOrSchema.source, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver, argsOrSchema.typeResolver) : graphqlImpl(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver));
21
22
  });
22
23
  }
23
24
  /**
@@ -27,19 +28,19 @@ export function graphql(argsOrSchema, source, rootValue, contextValue, variableV
27
28
  * that all field resolvers are also synchronous.
28
29
  */
29
30
 
30
- export function graphqlSync(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver) {
31
+ export function graphqlSync(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
31
32
  /* eslint-enable no-redeclare */
32
33
  // Extract arguments from object args if provided.
33
- var result = arguments.length === 1 ? graphqlImpl(argsOrSchema.schema, argsOrSchema.source, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver) : graphqlImpl(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver); // Assert that the execution was synchronous.
34
+ var result = arguments.length === 1 ? graphqlImpl(argsOrSchema.schema, argsOrSchema.source, argsOrSchema.rootValue, argsOrSchema.contextValue, argsOrSchema.variableValues, argsOrSchema.operationName, argsOrSchema.fieldResolver, argsOrSchema.typeResolver) : graphqlImpl(argsOrSchema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver); // Assert that the execution was synchronous.
34
35
 
35
- if (result.then) {
36
+ if (isPromise(result)) {
36
37
  throw new Error('GraphQL execution failed to complete synchronously.');
37
38
  }
38
39
 
39
40
  return result;
40
41
  }
41
42
 
42
- function graphqlImpl(schema, source, rootValue, contextValue, variableValues, operationName, fieldResolver) {
43
+ function graphqlImpl(schema, source, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) {
43
44
  // Validate Schema
44
45
  var schemaValidationErrors = validateSchema(schema);
45
46
 
@@ -70,5 +71,5 @@ function graphqlImpl(schema, source, rootValue, contextValue, variableValues, op
70
71
  } // Execute
71
72
 
72
73
 
73
- return execute(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver);
74
- }
74
+ return execute(schema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver);
75
+ }