graphql 14.4.2 → 14.5.3

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 (343) hide show
  1. package/README.md +5 -10
  2. package/error/GraphQLError.d.ts +87 -0
  3. package/error/GraphQLError.js +7 -45
  4. package/error/GraphQLError.js.flow +1 -0
  5. package/error/GraphQLError.mjs +7 -45
  6. package/error/formatError.d.ts +39 -0
  7. package/error/formatError.js +5 -2
  8. package/error/formatError.js.flow +27 -3
  9. package/error/formatError.mjs +5 -2
  10. package/error/index.d.ts +4 -0
  11. package/error/locatedError.d.ts +13 -0
  12. package/error/locatedError.js.flow +2 -1
  13. package/error/locatedError.mjs +1 -1
  14. package/error/syntaxError.d.ts +12 -0
  15. package/error/syntaxError.js.flow +1 -0
  16. package/execution/execute.d.ts +190 -0
  17. package/execution/execute.js +55 -89
  18. package/execution/execute.js.flow +95 -133
  19. package/execution/execute.mjs +75 -80
  20. package/execution/index.d.ts +11 -0
  21. package/execution/index.js +8 -6
  22. package/execution/index.js.flow +3 -6
  23. package/execution/index.mjs +2 -1
  24. package/execution/values.d.ts +68 -0
  25. package/execution/values.js +119 -128
  26. package/execution/values.js.flow +150 -127
  27. package/execution/values.mjs +117 -125
  28. package/graphql.d.ts +88 -0
  29. package/graphql.js +5 -5
  30. package/graphql.js.flow +9 -5
  31. package/graphql.mjs +41 -1
  32. package/index.d.ts +446 -0
  33. package/index.js +6 -0
  34. package/index.js.flow +3 -1
  35. package/index.mjs +2 -1
  36. package/jsutils/ObjMap.js.flow +6 -0
  37. package/jsutils/Path.d.ts +14 -0
  38. package/jsutils/Path.js +33 -0
  39. package/jsutils/Path.js.flow +26 -0
  40. package/jsutils/Path.mjs +24 -0
  41. package/jsutils/PromiseOrValue.d.ts +1 -0
  42. package/jsutils/dedent.js +6 -24
  43. package/jsutils/dedent.mjs +6 -24
  44. package/jsutils/defineToStringTag.js.flow +1 -1
  45. package/jsutils/devAssert.js +14 -0
  46. package/jsutils/devAssert.js.flow +8 -0
  47. package/jsutils/devAssert.mjs +7 -0
  48. package/jsutils/inspect.js +1 -1
  49. package/jsutils/inspect.js.flow +1 -1
  50. package/jsutils/inspect.mjs +1 -1
  51. package/jsutils/invariant.js +1 -2
  52. package/jsutils/invariant.js.flow +2 -3
  53. package/jsutils/invariant.mjs +1 -2
  54. package/jsutils/mapValue.js +6 -24
  55. package/jsutils/mapValue.js.flow +2 -1
  56. package/jsutils/mapValue.mjs +6 -24
  57. package/jsutils/printPathArray.js +15 -0
  58. package/jsutils/printPathArray.js.flow +14 -0
  59. package/jsutils/printPathArray.mjs +8 -0
  60. package/jsutils/suggestionList.js +14 -34
  61. package/jsutils/suggestionList.js.flow +4 -6
  62. package/jsutils/suggestionList.mjs +14 -34
  63. package/jsutils/toObjMap.js +28 -0
  64. package/jsutils/toObjMap.js.flow +26 -0
  65. package/jsutils/toObjMap.mjs +18 -0
  66. package/language/ast.d.ts +573 -0
  67. package/language/blockString.d.ts +21 -0
  68. package/language/directiveLocation.d.ts +35 -0
  69. package/language/index.d.ts +96 -0
  70. package/language/kinds.d.ts +77 -0
  71. package/language/lexer.d.ts +60 -0
  72. package/language/lexer.js +2 -12
  73. package/language/lexer.js.flow +6 -12
  74. package/language/lexer.mjs +1 -9
  75. package/language/location.d.ts +15 -0
  76. package/language/parser.d.ts +89 -0
  77. package/language/parser.js +1329 -1302
  78. package/language/parser.js.flow +1289 -1298
  79. package/language/parser.mjs +1326 -1297
  80. package/language/predicates.d.ts +36 -0
  81. package/language/predicates.js.flow +1 -1
  82. package/language/printLocation.d.ts +16 -0
  83. package/language/printLocation.js.flow +1 -1
  84. package/language/printer.d.ts +7 -0
  85. package/language/printer.js.flow +1 -1
  86. package/language/source.d.ts +19 -0
  87. package/language/source.js +3 -3
  88. package/language/source.js.flow +3 -3
  89. package/language/source.mjs +3 -3
  90. package/language/tokenKind.d.ts +35 -0
  91. package/language/visitor.d.ts +264 -0
  92. package/language/visitor.js +2 -2
  93. package/language/visitor.js.flow +3 -1
  94. package/language/visitor.mjs +2 -2
  95. package/package.json +1 -1
  96. package/polyfills/find.js +2 -2
  97. package/polyfills/find.js.flow +1 -2
  98. package/polyfills/find.mjs +2 -2
  99. package/polyfills/flatMap.js +3 -3
  100. package/polyfills/flatMap.js.flow +2 -3
  101. package/polyfills/flatMap.mjs +3 -3
  102. package/subscription/asyncIteratorReject.d.ts +6 -0
  103. package/subscription/index.d.ts +5 -0
  104. package/subscription/mapAsyncIterator.d.ts +9 -0
  105. package/subscription/mapAsyncIterator.js.flow +1 -0
  106. package/subscription/subscribe.d.ts +86 -0
  107. package/subscription/subscribe.js +29 -10
  108. package/subscription/subscribe.js.flow +45 -24
  109. package/subscription/subscribe.mjs +27 -9
  110. package/tsutils/Maybe.d.ts +4 -0
  111. package/type/definition.d.ts +805 -0
  112. package/type/definition.js +154 -70
  113. package/type/definition.js.flow +217 -160
  114. package/type/definition.mjs +149 -66
  115. package/type/directives.d.ts +72 -0
  116. package/type/directives.js +20 -12
  117. package/type/directives.js.flow +34 -19
  118. package/type/directives.mjs +17 -10
  119. package/type/index.d.ts +155 -0
  120. package/type/index.js.flow +2 -2
  121. package/type/introspection.d.ts +40 -0
  122. package/type/introspection.js +24 -10
  123. package/type/introspection.js.flow +29 -8
  124. package/type/introspection.mjs +23 -10
  125. package/type/scalars.d.ts +11 -0
  126. package/type/scalars.js +2 -2
  127. package/type/scalars.js.flow +4 -1
  128. package/type/scalars.mjs +2 -2
  129. package/type/schema.d.ts +108 -0
  130. package/type/schema.js +74 -151
  131. package/type/schema.js.flow +75 -73
  132. package/type/schema.mjs +75 -149
  133. package/type/validate.d.ts +19 -0
  134. package/type/validate.js +227 -486
  135. package/type/validate.js.flow +13 -8
  136. package/type/validate.mjs +218 -477
  137. package/utilities/TypeInfo.d.ts +49 -0
  138. package/utilities/TypeInfo.js.flow +9 -6
  139. package/utilities/assertValidName.d.ts +15 -0
  140. package/utilities/assertValidName.js +3 -3
  141. package/utilities/assertValidName.js.flow +3 -2
  142. package/utilities/assertValidName.mjs +2 -2
  143. package/utilities/astFromValue.d.ts +25 -0
  144. package/utilities/astFromValue.js +22 -38
  145. package/utilities/astFromValue.js.flow +7 -4
  146. package/utilities/astFromValue.mjs +19 -36
  147. package/utilities/buildASTSchema.d.ts +114 -0
  148. package/utilities/buildASTSchema.js +37 -68
  149. package/utilities/buildASTSchema.js.flow +32 -30
  150. package/utilities/buildASTSchema.mjs +32 -64
  151. package/utilities/buildClientSchema.d.ts +21 -0
  152. package/utilities/buildClientSchema.js +23 -15
  153. package/utilities/buildClientSchema.js.flow +17 -16
  154. package/utilities/buildClientSchema.mjs +20 -12
  155. package/utilities/coerceInputValue.d.ts +17 -0
  156. package/utilities/coerceInputValue.js +161 -0
  157. package/utilities/coerceInputValue.js.flow +214 -0
  158. package/utilities/coerceInputValue.mjs +142 -0
  159. package/utilities/coerceValue.d.ts +23 -0
  160. package/utilities/coerceValue.js +21 -199
  161. package/utilities/coerceValue.js.flow +31 -223
  162. package/utilities/coerceValue.mjs +20 -195
  163. package/utilities/concatAST.d.ts +8 -0
  164. package/utilities/concatAST.js.flow +1 -0
  165. package/utilities/extendSchema.d.ts +45 -0
  166. package/utilities/extendSchema.js +64 -131
  167. package/utilities/extendSchema.js.flow +27 -24
  168. package/utilities/extendSchema.mjs +61 -129
  169. package/utilities/findBreakingChanges.d.ts +64 -0
  170. package/utilities/findBreakingChanges.js +194 -619
  171. package/utilities/findBreakingChanges.js.flow +8 -5
  172. package/utilities/findBreakingChanges.mjs +194 -619
  173. package/utilities/findDeprecatedUsages.d.ts +13 -0
  174. package/utilities/findDeprecatedUsages.js.flow +4 -1
  175. package/utilities/getOperationAST.d.ts +12 -0
  176. package/utilities/getOperationAST.js +13 -31
  177. package/utilities/getOperationAST.mjs +13 -31
  178. package/utilities/getOperationRootType.d.ts +14 -0
  179. package/utilities/getOperationRootType.js.flow +2 -0
  180. package/utilities/index.d.ts +127 -0
  181. package/utilities/index.js +8 -0
  182. package/utilities/index.js.flow +4 -1
  183. package/utilities/index.mjs +3 -1
  184. package/utilities/introspectionFromSchema.d.ts +16 -0
  185. package/utilities/introspectionFromSchema.js +5 -3
  186. package/utilities/introspectionFromSchema.js.flow +4 -2
  187. package/utilities/introspectionFromSchema.mjs +4 -2
  188. package/utilities/introspectionQuery.d.ts +177 -0
  189. package/utilities/isValidJSValue.d.ts +8 -0
  190. package/utilities/isValidJSValue.js +1 -1
  191. package/utilities/isValidJSValue.js.flow +3 -2
  192. package/utilities/isValidJSValue.mjs +2 -2
  193. package/utilities/isValidLiteralValue.d.ts +15 -0
  194. package/utilities/isValidLiteralValue.js +4 -4
  195. package/utilities/isValidLiteralValue.js.flow +8 -4
  196. package/utilities/isValidLiteralValue.mjs +2 -2
  197. package/utilities/lexicographicSortSchema.d.ts +6 -0
  198. package/utilities/lexicographicSortSchema.js +11 -8
  199. package/utilities/lexicographicSortSchema.js.flow +5 -3
  200. package/utilities/lexicographicSortSchema.mjs +9 -7
  201. package/utilities/schemaPrinter.d.ts +30 -0
  202. package/utilities/schemaPrinter.js +15 -32
  203. package/utilities/schemaPrinter.js.flow +14 -10
  204. package/utilities/schemaPrinter.mjs +14 -32
  205. package/utilities/separateOperations.d.ts +11 -0
  206. package/utilities/separateOperations.js +6 -6
  207. package/utilities/separateOperations.js.flow +2 -1
  208. package/utilities/separateOperations.mjs +6 -6
  209. package/utilities/stripIgnoredCharacters.d.ts +55 -0
  210. package/utilities/stripIgnoredCharacters.js.flow +1 -0
  211. package/utilities/typeComparators.d.ts +32 -0
  212. package/utilities/typeComparators.js.flow +1 -1
  213. package/utilities/typeComparators.mjs +1 -1
  214. package/utilities/typeFromAST.d.ts +29 -0
  215. package/utilities/typeFromAST.js +5 -3
  216. package/utilities/typeFromAST.js.flow +5 -3
  217. package/utilities/typeFromAST.mjs +14 -3
  218. package/utilities/valueFromAST.d.ts +29 -0
  219. package/utilities/valueFromAST.js +40 -74
  220. package/utilities/valueFromAST.js.flow +7 -4
  221. package/utilities/valueFromAST.mjs +39 -74
  222. package/utilities/valueFromASTUntyped.d.ts +23 -0
  223. package/utilities/valueFromASTUntyped.js +4 -3
  224. package/utilities/valueFromASTUntyped.js.flow +3 -2
  225. package/utilities/valueFromASTUntyped.mjs +3 -3
  226. package/validation/ValidationContext.d.ts +96 -0
  227. package/validation/ValidationContext.js +38 -86
  228. package/validation/ValidationContext.js.flow +22 -7
  229. package/validation/ValidationContext.mjs +37 -85
  230. package/validation/index.d.ts +126 -0
  231. package/validation/rules/ExecutableDefinitions.d.ts +14 -0
  232. package/validation/rules/ExecutableDefinitions.js +4 -23
  233. package/validation/rules/ExecutableDefinitions.js.flow +4 -2
  234. package/validation/rules/ExecutableDefinitions.mjs +4 -23
  235. package/validation/rules/FieldsOnCorrectType.d.ts +17 -0
  236. package/validation/rules/FieldsOnCorrectType.js +21 -57
  237. package/validation/rules/FieldsOnCorrectType.js.flow +7 -3
  238. package/validation/rules/FieldsOnCorrectType.mjs +21 -57
  239. package/validation/rules/FragmentsOnCompositeTypes.d.ts +20 -0
  240. package/validation/rules/FragmentsOnCompositeTypes.js.flow +5 -1
  241. package/validation/rules/KnownArgumentNames.d.ts +28 -0
  242. package/validation/rules/KnownArgumentNames.js +26 -79
  243. package/validation/rules/KnownArgumentNames.js.flow +10 -6
  244. package/validation/rules/KnownArgumentNames.mjs +22 -75
  245. package/validation/rules/KnownDirectives.d.ts +19 -0
  246. package/validation/rules/KnownDirectives.js +12 -48
  247. package/validation/rules/KnownDirectives.js.flow +8 -5
  248. package/validation/rules/KnownDirectives.mjs +12 -48
  249. package/validation/rules/KnownFragmentNames.d.ts +12 -0
  250. package/validation/rules/KnownFragmentNames.js.flow +2 -1
  251. package/validation/rules/KnownTypeNames.d.ts +15 -0
  252. package/validation/rules/KnownTypeNames.js +6 -24
  253. package/validation/rules/KnownTypeNames.js.flow +10 -6
  254. package/validation/rules/KnownTypeNames.mjs +6 -24
  255. package/validation/rules/LoneAnonymousOperation.d.ts +14 -0
  256. package/validation/rules/LoneAnonymousOperation.js.flow +3 -1
  257. package/validation/rules/LoneSchemaDefinition.d.ts +13 -0
  258. package/validation/rules/LoneSchemaDefinition.js.flow +2 -1
  259. package/validation/rules/NoFragmentCycles.d.ts +9 -0
  260. package/validation/rules/NoFragmentCycles.js +17 -35
  261. package/validation/rules/NoFragmentCycles.js.flow +4 -2
  262. package/validation/rules/NoFragmentCycles.mjs +17 -35
  263. package/validation/rules/NoUndefinedVariables.d.ts +16 -0
  264. package/validation/rules/NoUndefinedVariables.js +6 -24
  265. package/validation/rules/NoUndefinedVariables.js.flow +2 -1
  266. package/validation/rules/NoUndefinedVariables.mjs +6 -24
  267. package/validation/rules/NoUnusedFragments.d.ts +12 -0
  268. package/validation/rules/NoUnusedFragments.js +7 -25
  269. package/validation/rules/NoUnusedFragments.js.flow +2 -1
  270. package/validation/rules/NoUnusedFragments.mjs +7 -25
  271. package/validation/rules/NoUnusedVariables.d.ts +16 -0
  272. package/validation/rules/NoUnusedVariables.js +6 -24
  273. package/validation/rules/NoUnusedVariables.js.flow +2 -1
  274. package/validation/rules/NoUnusedVariables.mjs +6 -24
  275. package/validation/rules/OverlappingFieldsCanBeMerged.d.ts +24 -0
  276. package/validation/rules/OverlappingFieldsCanBeMerged.js +27 -46
  277. package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +17 -8
  278. package/validation/rules/OverlappingFieldsCanBeMerged.mjs +25 -44
  279. package/validation/rules/PossibleFragmentSpreads.d.ts +22 -0
  280. package/validation/rules/PossibleFragmentSpreads.js +2 -2
  281. package/validation/rules/PossibleFragmentSpreads.js.flow +8 -3
  282. package/validation/rules/PossibleFragmentSpreads.mjs +2 -2
  283. package/validation/rules/PossibleTypeExtensions.d.ts +21 -0
  284. package/validation/rules/PossibleTypeExtensions.js +4 -22
  285. package/validation/rules/PossibleTypeExtensions.js.flow +6 -2
  286. package/validation/rules/PossibleTypeExtensions.mjs +4 -22
  287. package/validation/rules/ProvidedRequiredArguments.d.ts +29 -0
  288. package/validation/rules/ProvidedRequiredArguments.js +27 -79
  289. package/validation/rules/ProvidedRequiredArguments.js.flow +12 -8
  290. package/validation/rules/ProvidedRequiredArguments.mjs +25 -77
  291. package/validation/rules/ScalarLeafs.d.ts +20 -0
  292. package/validation/rules/ScalarLeafs.js.flow +6 -2
  293. package/validation/rules/SingleFieldSubscriptions.d.ts +14 -0
  294. package/validation/rules/SingleFieldSubscriptions.js.flow +4 -2
  295. package/validation/rules/UniqueArgumentNames.d.ts +12 -0
  296. package/validation/rules/UniqueArgumentNames.js.flow +2 -1
  297. package/validation/rules/UniqueDirectiveNames.d.ts +13 -0
  298. package/validation/rules/UniqueDirectiveNames.js.flow +2 -1
  299. package/validation/rules/UniqueDirectivesPerLocation.d.ts +14 -0
  300. package/validation/rules/UniqueDirectivesPerLocation.js +15 -69
  301. package/validation/rules/UniqueDirectivesPerLocation.js.flow +7 -4
  302. package/validation/rules/UniqueDirectivesPerLocation.mjs +15 -69
  303. package/validation/rules/UniqueEnumValueNames.d.ts +19 -0
  304. package/validation/rules/UniqueEnumValueNames.js +10 -28
  305. package/validation/rules/UniqueEnumValueNames.js.flow +2 -1
  306. package/validation/rules/UniqueEnumValueNames.mjs +10 -28
  307. package/validation/rules/UniqueFieldDefinitionNames.d.ts +21 -0
  308. package/validation/rules/UniqueFieldDefinitionNames.js +9 -27
  309. package/validation/rules/UniqueFieldDefinitionNames.js.flow +2 -1
  310. package/validation/rules/UniqueFieldDefinitionNames.mjs +9 -27
  311. package/validation/rules/UniqueFragmentNames.d.ts +11 -0
  312. package/validation/rules/UniqueFragmentNames.js.flow +2 -1
  313. package/validation/rules/UniqueInputFieldNames.d.ts +14 -0
  314. package/validation/rules/UniqueInputFieldNames.js.flow +2 -1
  315. package/validation/rules/UniqueOperationNames.d.ts +11 -0
  316. package/validation/rules/UniqueOperationNames.js.flow +2 -1
  317. package/validation/rules/UniqueOperationTypes.d.ts +13 -0
  318. package/validation/rules/UniqueOperationTypes.js +11 -30
  319. package/validation/rules/UniqueOperationTypes.js.flow +2 -1
  320. package/validation/rules/UniqueOperationTypes.mjs +10 -29
  321. package/validation/rules/UniqueTypeNames.d.ts +13 -0
  322. package/validation/rules/UniqueTypeNames.js.flow +3 -1
  323. package/validation/rules/UniqueVariableNames.d.ts +11 -0
  324. package/validation/rules/UniqueVariableNames.js.flow +4 -2
  325. package/validation/rules/ValuesOfCorrectType.d.ts +34 -0
  326. package/validation/rules/ValuesOfCorrectType.js +16 -34
  327. package/validation/rules/ValuesOfCorrectType.js.flow +11 -6
  328. package/validation/rules/ValuesOfCorrectType.mjs +12 -30
  329. package/validation/rules/VariablesAreInputTypes.d.ts +15 -0
  330. package/validation/rules/VariablesAreInputTypes.js.flow +6 -2
  331. package/validation/rules/VariablesInAllowedPosition.d.ts +15 -0
  332. package/validation/rules/VariablesInAllowedPosition.js +22 -40
  333. package/validation/rules/VariablesInAllowedPosition.js.flow +8 -3
  334. package/validation/rules/VariablesInAllowedPosition.mjs +18 -36
  335. package/validation/specifiedRules.d.ts +98 -0
  336. package/validation/validate.d.ts +56 -0
  337. package/validation/validate.js +35 -7
  338. package/validation/validate.js.flow +51 -9
  339. package/validation/validate.mjs +30 -7
  340. package/version.d.ts +14 -0
  341. package/version.js +3 -3
  342. package/version.js.flow +3 -3
  343. package/version.mjs +3 -3
@@ -0,0 +1,13 @@
1
+ import { GraphQLError } from '../error/GraphQLError';
2
+ import { DocumentNode } from '../language/ast';
3
+ import { GraphQLSchema } from '../type/schema';
4
+
5
+ /**
6
+ * A validation rule which reports deprecated usages.
7
+ *
8
+ * Returns a list of GraphQLError instances describing each deprecated use.
9
+ */
10
+ export function findDeprecatedUsages(
11
+ schema: GraphQLSchema,
12
+ ast: DocumentNode,
13
+ ): GraphQLError[];
@@ -1,10 +1,13 @@
1
1
  // @flow strict
2
2
 
3
3
  import { GraphQLError } from '../error/GraphQLError';
4
- import { visit, visitWithTypeInfo } from '../language/visitor';
4
+
5
5
  import { type DocumentNode } from '../language/ast';
6
+ import { visit, visitWithTypeInfo } from '../language/visitor';
7
+
6
8
  import { getNamedType } from '../type/definition';
7
9
  import { type GraphQLSchema } from '../type/schema';
10
+
8
11
  import { TypeInfo } from './TypeInfo';
9
12
 
10
13
  /**
@@ -0,0 +1,12 @@
1
+ import Maybe from '../tsutils/Maybe';
2
+ import { DocumentNode, OperationDefinitionNode } from '../language/ast';
3
+
4
+ /**
5
+ * Returns an operation AST given a document AST and optionally an operation
6
+ * name. If a name is not provided, an operation is only returned if only one is
7
+ * provided in the document.
8
+ */
9
+ export function getOperationAST(
10
+ documentAST: DocumentNode,
11
+ operationName: Maybe<string>,
12
+ ): Maybe<OperationDefinitionNode>;
@@ -14,40 +14,22 @@ var _kinds = require("../language/kinds");
14
14
  */
15
15
  function getOperationAST(documentAST, operationName) {
16
16
  var operation = null;
17
- var _iteratorNormalCompletion = true;
18
- var _didIteratorError = false;
19
- var _iteratorError = undefined;
20
17
 
21
- try {
22
- for (var _iterator = documentAST.definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
23
- var definition = _step.value;
18
+ for (var _i2 = 0, _documentAST$definiti2 = documentAST.definitions; _i2 < _documentAST$definiti2.length; _i2++) {
19
+ var definition = _documentAST$definiti2[_i2];
24
20
 
25
- if (definition.kind === _kinds.Kind.OPERATION_DEFINITION) {
26
- if (!operationName) {
27
- // If no operation name was provided, only return an Operation if there
28
- // is one defined in the document. Upon encountering the second, return
29
- // null.
30
- if (operation) {
31
- return null;
32
- }
33
-
34
- operation = definition;
35
- } else if (definition.name && definition.name.value === operationName) {
36
- return definition;
21
+ if (definition.kind === _kinds.Kind.OPERATION_DEFINITION) {
22
+ if (!operationName) {
23
+ // If no operation name was provided, only return an Operation if there
24
+ // is one defined in the document. Upon encountering the second, return
25
+ // null.
26
+ if (operation) {
27
+ return null;
37
28
  }
38
- }
39
- }
40
- } catch (err) {
41
- _didIteratorError = true;
42
- _iteratorError = err;
43
- } finally {
44
- try {
45
- if (!_iteratorNormalCompletion && _iterator.return != null) {
46
- _iterator.return();
47
- }
48
- } finally {
49
- if (_didIteratorError) {
50
- throw _iteratorError;
29
+
30
+ operation = definition;
31
+ } else if (definition.name && definition.name.value === operationName) {
32
+ return definition;
51
33
  }
52
34
  }
53
35
  }
@@ -7,40 +7,22 @@ import { Kind } from '../language/kinds';
7
7
  */
8
8
  export function getOperationAST(documentAST, operationName) {
9
9
  var operation = null;
10
- var _iteratorNormalCompletion = true;
11
- var _didIteratorError = false;
12
- var _iteratorError = undefined;
13
10
 
14
- try {
15
- for (var _iterator = documentAST.definitions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
16
- var definition = _step.value;
11
+ for (var _i2 = 0, _documentAST$definiti2 = documentAST.definitions; _i2 < _documentAST$definiti2.length; _i2++) {
12
+ var definition = _documentAST$definiti2[_i2];
17
13
 
18
- if (definition.kind === Kind.OPERATION_DEFINITION) {
19
- if (!operationName) {
20
- // If no operation name was provided, only return an Operation if there
21
- // is one defined in the document. Upon encountering the second, return
22
- // null.
23
- if (operation) {
24
- return null;
25
- }
26
-
27
- operation = definition;
28
- } else if (definition.name && definition.name.value === operationName) {
29
- return definition;
14
+ if (definition.kind === Kind.OPERATION_DEFINITION) {
15
+ if (!operationName) {
16
+ // If no operation name was provided, only return an Operation if there
17
+ // is one defined in the document. Upon encountering the second, return
18
+ // null.
19
+ if (operation) {
20
+ return null;
30
21
  }
31
- }
32
- }
33
- } catch (err) {
34
- _didIteratorError = true;
35
- _iteratorError = err;
36
- } finally {
37
- try {
38
- if (!_iteratorNormalCompletion && _iterator.return != null) {
39
- _iterator.return();
40
- }
41
- } finally {
42
- if (_didIteratorError) {
43
- throw _iteratorError;
22
+
23
+ operation = definition;
24
+ } else if (definition.name && definition.name.value === operationName) {
25
+ return definition;
44
26
  }
45
27
  }
46
28
  }
@@ -0,0 +1,14 @@
1
+ import {
2
+ OperationDefinitionNode,
3
+ OperationTypeDefinitionNode,
4
+ } from '../language/ast';
5
+ import { GraphQLSchema } from '../type/schema';
6
+ import { GraphQLObjectType } from '../type/definition';
7
+
8
+ /**
9
+ * Extracts the root type of the operation from the schema.
10
+ */
11
+ export function getOperationRootType(
12
+ schema: GraphQLSchema,
13
+ operation: OperationDefinitionNode | OperationTypeDefinitionNode,
14
+ ): GraphQLObjectType;
@@ -1,10 +1,12 @@
1
1
  // @flow strict
2
2
 
3
3
  import { GraphQLError } from '../error/GraphQLError';
4
+
4
5
  import {
5
6
  type OperationDefinitionNode,
6
7
  type OperationTypeDefinitionNode,
7
8
  } from '../language/ast';
9
+
8
10
  import { type GraphQLSchema } from '../type/schema';
9
11
  import { type GraphQLObjectType } from '../type/definition';
10
12
 
@@ -0,0 +1,127 @@
1
+ // The GraphQL query recommended for a full schema introspection.
2
+ export {
3
+ getIntrospectionQuery,
4
+ // @deprecated, use getIntrospectionQuery() - will be removed in v15
5
+ introspectionQuery,
6
+ } from './introspectionQuery';
7
+
8
+ export {
9
+ IntrospectionOptions,
10
+ IntrospectionQuery,
11
+ IntrospectionSchema,
12
+ IntrospectionType,
13
+ IntrospectionInputType,
14
+ IntrospectionOutputType,
15
+ IntrospectionScalarType,
16
+ IntrospectionObjectType,
17
+ IntrospectionInterfaceType,
18
+ IntrospectionUnionType,
19
+ IntrospectionEnumType,
20
+ IntrospectionInputObjectType,
21
+ IntrospectionTypeRef,
22
+ IntrospectionInputTypeRef,
23
+ IntrospectionOutputTypeRef,
24
+ IntrospectionNamedTypeRef,
25
+ IntrospectionListTypeRef,
26
+ IntrospectionNonNullTypeRef,
27
+ IntrospectionField,
28
+ IntrospectionInputValue,
29
+ IntrospectionEnumValue,
30
+ IntrospectionDirective,
31
+ } from './introspectionQuery';
32
+
33
+ // Gets the target Operation from a Document
34
+ export { getOperationAST } from './getOperationAST';
35
+
36
+ // Gets the Type for the target Operation AST.
37
+ export { getOperationRootType } from './getOperationRootType';
38
+
39
+ // Convert a GraphQLSchema to an IntrospectionQuery
40
+ export { introspectionFromSchema } from './introspectionFromSchema';
41
+
42
+ // Build a GraphQLSchema from an introspection result.
43
+ export { buildClientSchema } from './buildClientSchema';
44
+
45
+ // Build a GraphQLSchema from GraphQL Schema language.
46
+ export {
47
+ buildASTSchema,
48
+ buildSchema,
49
+ // @deprecated: Get the description from a schema AST node and supports legacy
50
+ // syntax for specifying descriptions - will be removed in v16
51
+ getDescription,
52
+ BuildSchemaOptions,
53
+ } from './buildASTSchema';
54
+
55
+ // Extends an existing GraphQLSchema from a parsed GraphQL Schema language AST.
56
+ export { extendSchema } from './extendSchema';
57
+
58
+ // Sort a GraphQLSchema.
59
+ export { lexicographicSortSchema } from './lexicographicSortSchema';
60
+
61
+ // Print a GraphQLSchema to GraphQL Schema language.
62
+ export {
63
+ printSchema,
64
+ printType,
65
+ printIntrospectionSchema,
66
+ } from './schemaPrinter';
67
+
68
+ // Create a GraphQLType from a GraphQL language AST.
69
+ export { typeFromAST } from './typeFromAST';
70
+
71
+ // Create a JavaScript value from a GraphQL language AST with a type.
72
+ export { valueFromAST } from './valueFromAST';
73
+
74
+ // Create a JavaScript value from a GraphQL language AST without a type.
75
+ export { valueFromASTUntyped } from './valueFromASTUntyped';
76
+
77
+ // Create a GraphQL language AST from a JavaScript value.
78
+ export { astFromValue } from './astFromValue';
79
+
80
+ // A helper to use within recursive-descent visitors which need to be aware of
81
+ // the GraphQL type system.
82
+ export { TypeInfo } from './TypeInfo';
83
+
84
+ // Coerces a JavaScript value to a GraphQL type, or produces errors.
85
+ export { coerceInputValue } from './coerceInputValue';
86
+
87
+ // Coerces a JavaScript value to a GraphQL type, or produces errors.
88
+ export { coerceValue } from './coerceValue';
89
+
90
+ // @deprecated use coerceValue - will be removed in v15
91
+ export { isValidJSValue } from './isValidJSValue';
92
+
93
+ // @deprecated use validation - will be removed in v15
94
+ export { isValidLiteralValue } from './isValidLiteralValue';
95
+
96
+ // Concatenates multiple AST together.
97
+ export { concatAST } from './concatAST';
98
+
99
+ // Separates an AST into an AST per Operation.
100
+ export { separateOperations } from './separateOperations';
101
+
102
+ // Strips characters that are not significant to the validity or execution
103
+ // of a GraphQL document.
104
+ export { stripIgnoredCharacters } from './stripIgnoredCharacters';
105
+
106
+ // Comparators for types
107
+ export {
108
+ isEqualType,
109
+ isTypeSubTypeOf,
110
+ doTypesOverlap,
111
+ } from './typeComparators';
112
+
113
+ // Asserts that a string is a valid GraphQL name
114
+ export { assertValidName, isValidNameError } from './assertValidName';
115
+
116
+ // Compares two GraphQLSchemas and detects breaking changes.
117
+ export {
118
+ BreakingChangeType,
119
+ DangerousChangeType,
120
+ findBreakingChanges,
121
+ findDangerousChanges,
122
+ BreakingChange,
123
+ DangerousChange,
124
+ } from './findBreakingChanges';
125
+
126
+ // Report all deprecated usage within a GraphQL document.
127
+ export { findDeprecatedUsages } from './findDeprecatedUsages';
@@ -117,6 +117,12 @@ Object.defineProperty(exports, "TypeInfo", {
117
117
  return _TypeInfo.TypeInfo;
118
118
  }
119
119
  });
120
+ Object.defineProperty(exports, "coerceInputValue", {
121
+ enumerable: true,
122
+ get: function get() {
123
+ return _coerceInputValue.coerceInputValue;
124
+ }
125
+ });
120
126
  Object.defineProperty(exports, "coerceValue", {
121
127
  enumerable: true,
122
128
  get: function get() {
@@ -242,6 +248,8 @@ var _astFromValue = require("./astFromValue");
242
248
 
243
249
  var _TypeInfo = require("./TypeInfo");
244
250
 
251
+ var _coerceInputValue = require("./coerceInputValue");
252
+
245
253
  var _coerceValue = require("./coerceValue");
246
254
 
247
255
  var _isValidJSValue = require("./isValidJSValue");
@@ -86,9 +86,12 @@ export { astFromValue } from './astFromValue';
86
86
  export { TypeInfo } from './TypeInfo';
87
87
 
88
88
  // Coerces a JavaScript value to a GraphQL type, or produces errors.
89
+ export { coerceInputValue } from './coerceInputValue';
90
+
91
+ // @deprecated use coerceInputValue - will be removed in v15.
89
92
  export { coerceValue } from './coerceValue';
90
93
 
91
- // @deprecated use coerceValue - will be removed in v15.
94
+ // @deprecated use coerceInputValue - will be removed in v15.
92
95
  export { isValidJSValue } from './isValidJSValue';
93
96
 
94
97
  // @deprecated use validation - will be removed in v15
@@ -33,7 +33,9 @@ export { astFromValue } from './astFromValue'; // A helper to use within recursi
33
33
 
34
34
  export { TypeInfo } from './TypeInfo'; // Coerces a JavaScript value to a GraphQL type, or produces errors.
35
35
 
36
- export { coerceValue } from './coerceValue'; // @deprecated use coerceValue - will be removed in v15.
36
+ export { coerceInputValue } from './coerceInputValue'; // @deprecated use coerceInputValue - will be removed in v15.
37
+
38
+ export { coerceValue } from './coerceValue'; // @deprecated use coerceInputValue - will be removed in v15.
37
39
 
38
40
  export { isValidJSValue } from './isValidJSValue'; // @deprecated use validation - will be removed in v15
39
41
 
@@ -0,0 +1,16 @@
1
+ import { GraphQLSchema } from '../type/schema';
2
+ import { IntrospectionQuery, IntrospectionOptions } from './introspectionQuery';
3
+
4
+ /**
5
+ * Build an IntrospectionQuery from a GraphQLSchema
6
+ *
7
+ * IntrospectionQuery is useful for utilities that care about type and field
8
+ * relationships, but do not need to traverse through those relationships.
9
+ *
10
+ * This is the inverse of buildClientSchema. The primary use case is outside
11
+ * of the server context, for instance when doing schema comparisons.
12
+ */
13
+ export function introspectionFromSchema(
14
+ schema: GraphQLSchema,
15
+ options?: IntrospectionOptions,
16
+ ): IntrospectionQuery;
@@ -9,10 +9,10 @@ var _invariant = _interopRequireDefault(require("../jsutils/invariant"));
9
9
 
10
10
  var _isPromise = _interopRequireDefault(require("../jsutils/isPromise"));
11
11
 
12
- var _execute = require("../execution/execute");
13
-
14
12
  var _parser = require("../language/parser");
15
13
 
14
+ var _execute = require("../execution/execute");
15
+
16
16
  var _introspectionQuery = require("./introspectionQuery");
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -29,6 +29,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
29
29
  function introspectionFromSchema(schema, options) {
30
30
  var queryAST = (0, _parser.parse)((0, _introspectionQuery.getIntrospectionQuery)(options));
31
31
  var result = (0, _execute.execute)(schema, queryAST);
32
- !(!(0, _isPromise.default)(result) && !result.errors && result.data) ? (0, _invariant.default)(0) : void 0;
32
+
33
+ /* istanbul ignore next */
34
+ !(0, _isPromise.default)(result) && !result.errors && result.data || (0, _invariant.default)(0);
33
35
  return result.data;
34
36
  }
@@ -2,9 +2,11 @@
2
2
 
3
3
  import invariant from '../jsutils/invariant';
4
4
  import isPromise from '../jsutils/isPromise';
5
- import { type GraphQLSchema } from '../type/schema';
6
- import { execute } from '../execution/execute';
5
+
7
6
  import { parse } from '../language/parser';
7
+ import { execute } from '../execution/execute';
8
+ import { type GraphQLSchema } from '../type/schema';
9
+
8
10
  import {
9
11
  type IntrospectionQuery,
10
12
  type IntrospectionOptions,
@@ -1,7 +1,7 @@
1
1
  import invariant from '../jsutils/invariant';
2
2
  import isPromise from '../jsutils/isPromise';
3
- import { execute } from '../execution/execute';
4
3
  import { parse } from '../language/parser';
4
+ import { execute } from '../execution/execute';
5
5
  import { getIntrospectionQuery } from './introspectionQuery';
6
6
  /**
7
7
  * Build an IntrospectionQuery from a GraphQLSchema
@@ -16,6 +16,8 @@ import { getIntrospectionQuery } from './introspectionQuery';
16
16
  export function introspectionFromSchema(schema, options) {
17
17
  var queryAST = parse(getIntrospectionQuery(options));
18
18
  var result = execute(schema, queryAST);
19
- !(!isPromise(result) && !result.errors && result.data) ? invariant(0) : void 0;
19
+
20
+ /* istanbul ignore next */
21
+ !isPromise(result) && !result.errors && result.data || invariant(0);
20
22
  return result.data;
21
23
  }
@@ -0,0 +1,177 @@
1
+ import Maybe from '../tsutils/Maybe';
2
+ import { DirectiveLocationEnum } from '../language/directiveLocation';
3
+
4
+ export interface IntrospectionOptions {
5
+ // Whether to include descriptions in the introspection result.
6
+ // Default: true
7
+ descriptions: boolean;
8
+ }
9
+
10
+ export function getIntrospectionQuery(options?: IntrospectionOptions): string;
11
+
12
+ /**
13
+ * Deprecated, call getIntrospectionQuery directly.
14
+ *
15
+ * This function will be removed in v15
16
+ */
17
+ export const introspectionQuery: string;
18
+
19
+ export interface IntrospectionQuery {
20
+ readonly __schema: IntrospectionSchema;
21
+ }
22
+
23
+ export interface IntrospectionSchema {
24
+ readonly queryType: IntrospectionNamedTypeRef<IntrospectionObjectType>;
25
+ readonly mutationType: Maybe<
26
+ IntrospectionNamedTypeRef<IntrospectionObjectType>
27
+ >;
28
+ readonly subscriptionType: Maybe<
29
+ IntrospectionNamedTypeRef<IntrospectionObjectType>
30
+ >;
31
+ readonly types: ReadonlyArray<IntrospectionType>;
32
+ readonly directives: ReadonlyArray<IntrospectionDirective>;
33
+ }
34
+
35
+ export type IntrospectionType =
36
+ | IntrospectionScalarType
37
+ | IntrospectionObjectType
38
+ | IntrospectionInterfaceType
39
+ | IntrospectionUnionType
40
+ | IntrospectionEnumType
41
+ | IntrospectionInputObjectType;
42
+
43
+ export type IntrospectionOutputType =
44
+ | IntrospectionScalarType
45
+ | IntrospectionObjectType
46
+ | IntrospectionInterfaceType
47
+ | IntrospectionUnionType
48
+ | IntrospectionEnumType;
49
+
50
+ export type IntrospectionInputType =
51
+ | IntrospectionScalarType
52
+ | IntrospectionEnumType
53
+ | IntrospectionInputObjectType;
54
+
55
+ export interface IntrospectionScalarType {
56
+ readonly kind: 'SCALAR';
57
+ readonly name: string;
58
+ readonly description?: Maybe<string>;
59
+ }
60
+
61
+ export interface IntrospectionObjectType {
62
+ readonly kind: 'OBJECT';
63
+ readonly name: string;
64
+ readonly description?: Maybe<string>;
65
+ readonly fields: ReadonlyArray<IntrospectionField>;
66
+ readonly interfaces: ReadonlyArray<
67
+ IntrospectionNamedTypeRef<IntrospectionInterfaceType>
68
+ >;
69
+ }
70
+
71
+ export interface IntrospectionInterfaceType {
72
+ readonly kind: 'INTERFACE';
73
+ readonly name: string;
74
+ readonly description?: Maybe<string>;
75
+ readonly fields: ReadonlyArray<IntrospectionField>;
76
+ readonly possibleTypes: ReadonlyArray<
77
+ IntrospectionNamedTypeRef<IntrospectionObjectType>
78
+ >;
79
+ }
80
+
81
+ export interface IntrospectionUnionType {
82
+ readonly kind: 'UNION';
83
+ readonly name: string;
84
+ readonly description?: Maybe<string>;
85
+ readonly possibleTypes: ReadonlyArray<
86
+ IntrospectionNamedTypeRef<IntrospectionObjectType>
87
+ >;
88
+ }
89
+
90
+ export interface IntrospectionEnumType {
91
+ readonly kind: 'ENUM';
92
+ readonly name: string;
93
+ readonly description?: Maybe<string>;
94
+ readonly enumValues: ReadonlyArray<IntrospectionEnumValue>;
95
+ }
96
+
97
+ export interface IntrospectionInputObjectType {
98
+ readonly kind: 'INPUT_OBJECT';
99
+ readonly name: string;
100
+ readonly description?: Maybe<string>;
101
+ readonly inputFields: ReadonlyArray<IntrospectionInputValue>;
102
+ }
103
+
104
+ export interface IntrospectionListTypeRef<
105
+ T extends IntrospectionTypeRef = IntrospectionTypeRef
106
+ > {
107
+ readonly kind: 'LIST';
108
+ readonly ofType: T;
109
+ }
110
+
111
+ export interface IntrospectionNonNullTypeRef<
112
+ T extends IntrospectionTypeRef = IntrospectionTypeRef
113
+ > {
114
+ readonly kind: 'NON_NULL';
115
+ readonly ofType: T;
116
+ }
117
+
118
+ export type IntrospectionTypeRef =
119
+ | IntrospectionNamedTypeRef<IntrospectionType>
120
+ | IntrospectionListTypeRef<any>
121
+ | IntrospectionNonNullTypeRef<
122
+ | IntrospectionNamedTypeRef<IntrospectionType>
123
+ | IntrospectionListTypeRef<any>
124
+ >;
125
+
126
+ export type IntrospectionOutputTypeRef =
127
+ | IntrospectionNamedTypeRef<IntrospectionOutputType>
128
+ | IntrospectionListTypeRef<any>
129
+ | IntrospectionNonNullTypeRef<
130
+ | IntrospectionNamedTypeRef<IntrospectionOutputType>
131
+ | IntrospectionListTypeRef<any>
132
+ >;
133
+
134
+ export type IntrospectionInputTypeRef =
135
+ | IntrospectionNamedTypeRef<IntrospectionInputType>
136
+ | IntrospectionListTypeRef<any>
137
+ | IntrospectionNonNullTypeRef<
138
+ | IntrospectionNamedTypeRef<IntrospectionInputType>
139
+ | IntrospectionListTypeRef<any>
140
+ >;
141
+
142
+ export interface IntrospectionNamedTypeRef<
143
+ T extends IntrospectionType = IntrospectionType
144
+ > {
145
+ readonly kind: T['kind'];
146
+ readonly name: string;
147
+ }
148
+
149
+ export interface IntrospectionField {
150
+ readonly name: string;
151
+ readonly description?: Maybe<string>;
152
+ readonly args: ReadonlyArray<IntrospectionInputValue>;
153
+ readonly type: IntrospectionOutputTypeRef;
154
+ readonly isDeprecated: boolean;
155
+ readonly deprecationReason?: Maybe<string>;
156
+ }
157
+
158
+ export interface IntrospectionInputValue {
159
+ readonly name: string;
160
+ readonly description?: Maybe<string>;
161
+ readonly type: IntrospectionInputTypeRef;
162
+ readonly defaultValue?: Maybe<string>;
163
+ }
164
+
165
+ export interface IntrospectionEnumValue {
166
+ readonly name: string;
167
+ readonly description?: Maybe<string>;
168
+ readonly isDeprecated: boolean;
169
+ readonly deprecationReason?: Maybe<string>;
170
+ }
171
+
172
+ export interface IntrospectionDirective {
173
+ readonly name: string;
174
+ readonly description?: Maybe<string>;
175
+ readonly locations: ReadonlyArray<DirectiveLocationEnum>;
176
+ readonly args: ReadonlyArray<IntrospectionInputValue>;
177
+ }
@@ -0,0 +1,8 @@
1
+ import { GraphQLInputType } from '../type/definition';
2
+
3
+ /**
4
+ * Deprecated. Use coerceValue() directly for richer information.
5
+ *
6
+ * This function will be removed in v15
7
+ */
8
+ export function isValidJSValue(value: any, type: GraphQLInputType): string[];
@@ -10,7 +10,7 @@ var _coerceValue = require("./coerceValue");
10
10
  /* istanbul ignore file */
11
11
 
12
12
  /**
13
- * Deprecated. Use coerceValue() directly for richer information.
13
+ * Deprecated. Use coerceInputValue() directly for richer information.
14
14
  *
15
15
  * This function will be removed in v15
16
16
  */
@@ -1,11 +1,12 @@
1
1
  // @flow strict
2
2
 
3
3
  /* istanbul ignore file */
4
- import { coerceValue } from './coerceValue';
5
4
  import { type GraphQLInputType } from '../type/definition';
6
5
 
6
+ import { coerceValue } from './coerceValue';
7
+
7
8
  /**
8
- * Deprecated. Use coerceValue() directly for richer information.
9
+ * Deprecated. Use coerceInputValue() directly for richer information.
9
10
  *
10
11
  * This function will be removed in v15
11
12
  */
@@ -1,11 +1,11 @@
1
1
  /* istanbul ignore file */
2
2
  import { coerceValue } from './coerceValue';
3
-
4
3
  /**
5
- * Deprecated. Use coerceValue() directly for richer information.
4
+ * Deprecated. Use coerceInputValue() directly for richer information.
6
5
  *
7
6
  * This function will be removed in v15
8
7
  */
8
+
9
9
  export function isValidJSValue(value, type) {
10
10
  var errors = coerceValue(value, type).errors;
11
11
  return errors ? errors.map(function (error) {