graphql 17.0.0-beta.0 → 17.0.0-beta.2

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 (1193) hide show
  1. package/__dev__/devMode.d.ts +1 -1
  2. package/__dev__/error/GraphQLError.d.ts +1 -1
  3. package/__dev__/error/ensureGraphQLError.d.ts +1 -1
  4. package/__dev__/error/index.d.ts +1 -1
  5. package/__dev__/error/locatedError.d.ts +1 -1
  6. package/__dev__/error/syntaxError.d.ts +1 -1
  7. package/__dev__/execution/AbortedGraphQLExecutionError.d.ts +1 -1
  8. package/__dev__/execution/AsyncWorkTracker.d.ts +1 -1
  9. package/__dev__/execution/ExecutionArgs.d.mts +1 -0
  10. package/__dev__/execution/ExecutionArgs.d.ts +1 -0
  11. package/__dev__/execution/ExecutionArgs.js +3 -0
  12. package/__dev__/execution/ExecutionArgs.mjs +3 -0
  13. package/__dev__/execution/Executor.d.ts +1 -1
  14. package/__dev__/execution/ExecutorThrowingOnIncremental.d.ts +1 -1
  15. package/__dev__/execution/buildResolveInfo.d.mts +1 -0
  16. package/__dev__/execution/buildResolveInfo.d.ts +1 -0
  17. package/__dev__/execution/buildResolveInfo.js +3 -0
  18. package/__dev__/execution/buildResolveInfo.mjs +3 -0
  19. package/__dev__/execution/cancellablePromise.d.ts +1 -1
  20. package/__dev__/execution/collectFields.d.ts +1 -1
  21. package/__dev__/execution/collectIteratorPromises.d.ts +1 -1
  22. package/__dev__/execution/createSharedExecutionContext.d.ts +1 -1
  23. package/__dev__/execution/execute.d.ts +1 -1
  24. package/__dev__/execution/getStreamUsage.d.ts +1 -1
  25. package/__dev__/execution/getVariableSignature.d.ts +1 -1
  26. package/__dev__/execution/hooks.d.ts +1 -1
  27. package/__dev__/execution/incremental/Computation.d.ts +1 -1
  28. package/__dev__/execution/incremental/IncrementalExecutor.d.ts +1 -1
  29. package/__dev__/execution/incremental/IncrementalPublisher.d.ts +1 -1
  30. package/__dev__/execution/incremental/Queue.d.ts +1 -1
  31. package/__dev__/execution/incremental/WorkQueue.d.ts +1 -1
  32. package/__dev__/execution/incremental/buildExecutionPlan.d.ts +1 -1
  33. package/__dev__/execution/index.d.ts +1 -1
  34. package/__dev__/execution/legacyIncremental/BranchingIncrementalExecutor.d.mts +1 -0
  35. package/__dev__/execution/legacyIncremental/BranchingIncrementalExecutor.d.ts +1 -0
  36. package/__dev__/execution/legacyIncremental/BranchingIncrementalExecutor.js +3 -0
  37. package/__dev__/execution/legacyIncremental/BranchingIncrementalExecutor.mjs +3 -0
  38. package/__dev__/execution/legacyIncremental/BranchingIncrementalPublisher.d.mts +1 -0
  39. package/__dev__/execution/legacyIncremental/BranchingIncrementalPublisher.d.ts +1 -0
  40. package/__dev__/execution/legacyIncremental/BranchingIncrementalPublisher.js +3 -0
  41. package/__dev__/execution/legacyIncremental/BranchingIncrementalPublisher.mjs +3 -0
  42. package/__dev__/execution/legacyIncremental/legacyExecuteIncrementally.d.mts +1 -0
  43. package/__dev__/execution/legacyIncremental/legacyExecuteIncrementally.d.ts +1 -0
  44. package/__dev__/execution/legacyIncremental/legacyExecuteIncrementally.js +3 -0
  45. package/__dev__/execution/legacyIncremental/legacyExecuteIncrementally.mjs +3 -0
  46. package/__dev__/execution/mapAsyncIterable.d.ts +1 -1
  47. package/__dev__/execution/returnIteratorCatchingErrors.d.ts +1 -1
  48. package/__dev__/execution/values.d.ts +1 -1
  49. package/__dev__/execution/withConcurrentAbruptClose.d.ts +1 -1
  50. package/__dev__/graphql.d.ts +1 -1
  51. package/__dev__/harness.d.ts +1 -1
  52. package/__dev__/index.d.ts +1 -1
  53. package/__dev__/jsutils/AccumulatorMap.d.ts +1 -1
  54. package/__dev__/jsutils/Maybe.d.ts +1 -1
  55. package/__dev__/jsutils/ObjMap.d.ts +1 -1
  56. package/__dev__/jsutils/Path.d.ts +1 -1
  57. package/__dev__/jsutils/PromiseOrValue.d.ts +1 -1
  58. package/__dev__/jsutils/capitalize.d.ts +1 -1
  59. package/__dev__/jsutils/devAssert.d.ts +1 -1
  60. package/__dev__/jsutils/didYouMean.d.ts +1 -1
  61. package/__dev__/jsutils/formatList.d.ts +1 -1
  62. package/__dev__/jsutils/getBySet.d.ts +1 -1
  63. package/__dev__/jsutils/groupBy.d.ts +1 -1
  64. package/__dev__/jsutils/identityFunc.d.ts +1 -1
  65. package/__dev__/jsutils/inspect.d.ts +1 -1
  66. package/__dev__/jsutils/instanceOf.d.ts +1 -1
  67. package/__dev__/jsutils/invariant.d.ts +1 -1
  68. package/__dev__/jsutils/isAsyncIterable.d.ts +1 -1
  69. package/__dev__/jsutils/isIterableObject.d.ts +1 -1
  70. package/__dev__/jsutils/isObjectLike.d.ts +1 -1
  71. package/__dev__/jsutils/isPromise.d.ts +1 -1
  72. package/__dev__/jsutils/isSameSet.d.ts +1 -1
  73. package/__dev__/jsutils/keyMap.d.ts +1 -1
  74. package/__dev__/jsutils/keyValMap.d.ts +1 -1
  75. package/__dev__/jsutils/mapValue.d.ts +1 -1
  76. package/__dev__/jsutils/memoize1.d.ts +1 -1
  77. package/__dev__/jsutils/memoize2.d.ts +1 -1
  78. package/__dev__/jsutils/memoize3.d.ts +1 -1
  79. package/__dev__/jsutils/naturalCompare.d.ts +1 -1
  80. package/__dev__/jsutils/printPathArray.d.ts +1 -1
  81. package/__dev__/jsutils/promiseForObject.d.ts +1 -1
  82. package/__dev__/jsutils/promiseReduce.d.ts +1 -1
  83. package/__dev__/jsutils/promiseWithResolvers.d.ts +1 -1
  84. package/__dev__/jsutils/suggestionList.d.ts +1 -1
  85. package/__dev__/jsutils/toError.d.ts +1 -1
  86. package/__dev__/jsutils/toObjMap.d.ts +1 -1
  87. package/__dev__/language/KindTypeMap.d.ts +1 -1
  88. package/__dev__/language/ast.d.ts +1 -1
  89. package/__dev__/language/blockString.d.ts +1 -1
  90. package/__dev__/language/characterClasses.d.ts +1 -1
  91. package/__dev__/language/directiveLocation.d.ts +1 -1
  92. package/__dev__/language/index.d.ts +1 -1
  93. package/__dev__/language/kinds.d.ts +1 -1
  94. package/__dev__/language/kinds_.d.ts +1 -1
  95. package/__dev__/language/lexer.d.ts +1 -1
  96. package/__dev__/language/location.d.ts +1 -1
  97. package/__dev__/language/parser.d.ts +1 -1
  98. package/__dev__/language/predicates.d.ts +1 -1
  99. package/__dev__/language/printLocation.d.ts +1 -1
  100. package/__dev__/language/printString.d.ts +1 -1
  101. package/__dev__/language/printer.d.ts +1 -1
  102. package/__dev__/language/schemaCoordinateLexer.d.ts +1 -1
  103. package/__dev__/language/source.d.ts +1 -1
  104. package/__dev__/language/tokenKind.d.ts +1 -1
  105. package/__dev__/language/visitor.d.ts +1 -1
  106. package/__dev__/type/assertName.d.ts +1 -1
  107. package/__dev__/type/definition.d.ts +1 -1
  108. package/__dev__/type/directives.d.ts +1 -1
  109. package/__dev__/type/index.d.ts +1 -1
  110. package/__dev__/type/introspection.d.ts +1 -1
  111. package/__dev__/type/scalars.d.ts +1 -1
  112. package/__dev__/type/schema.d.ts +1 -1
  113. package/__dev__/type/validate.d.ts +1 -1
  114. package/__dev__/utilities/TypeInfo.d.ts +1 -1
  115. package/__dev__/utilities/astFromValue.d.ts +1 -1
  116. package/__dev__/utilities/buildASTSchema.d.ts +1 -1
  117. package/__dev__/utilities/buildClientSchema.d.ts +1 -1
  118. package/__dev__/utilities/coerceInputValue.d.ts +1 -1
  119. package/__dev__/utilities/concatAST.d.ts +1 -1
  120. package/__dev__/utilities/extendSchema.d.ts +1 -1
  121. package/__dev__/utilities/findSchemaChanges.d.ts +1 -1
  122. package/__dev__/utilities/getDefaultValueAST.d.ts +1 -1
  123. package/__dev__/utilities/getIntrospectionQuery.d.ts +1 -1
  124. package/__dev__/utilities/getOperationAST.d.ts +1 -1
  125. package/__dev__/utilities/index.d.ts +1 -1
  126. package/__dev__/utilities/introspectionFromSchema.d.ts +1 -1
  127. package/__dev__/utilities/lexicographicSortSchema.d.ts +1 -1
  128. package/__dev__/utilities/mapSchemaConfig.d.ts +1 -1
  129. package/__dev__/utilities/printSchema.d.ts +1 -1
  130. package/__dev__/utilities/replaceVariables.d.ts +1 -1
  131. package/__dev__/utilities/resolveSchemaCoordinate.d.ts +1 -1
  132. package/__dev__/utilities/separateOperations.d.ts +1 -1
  133. package/__dev__/utilities/sortValueNode.d.ts +1 -1
  134. package/__dev__/utilities/stripIgnoredCharacters.d.ts +1 -1
  135. package/__dev__/utilities/typeComparators.d.ts +1 -1
  136. package/__dev__/utilities/typeFromAST.d.ts +1 -1
  137. package/__dev__/utilities/typedQueryDocumentNode.d.ts +1 -1
  138. package/__dev__/utilities/validateInputValue.d.ts +1 -1
  139. package/__dev__/utilities/valueFromAST.d.ts +1 -1
  140. package/__dev__/utilities/valueFromASTUntyped.d.ts +1 -1
  141. package/__dev__/utilities/valueToLiteral.d.ts +1 -1
  142. package/__dev__/validation/ValidationContext.d.ts +1 -1
  143. package/__dev__/validation/index.d.ts +1 -1
  144. package/__dev__/validation/rules/DeferStreamDirectiveLabelRule.d.ts +1 -1
  145. package/__dev__/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.ts +1 -1
  146. package/__dev__/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.ts +1 -1
  147. package/__dev__/validation/rules/ExecutableDefinitionsRule.d.ts +1 -1
  148. package/__dev__/validation/rules/FieldsOnCorrectTypeRule.d.ts +1 -1
  149. package/__dev__/validation/rules/FragmentsOnCompositeTypesRule.d.ts +1 -1
  150. package/__dev__/validation/rules/KnownArgumentNamesRule.d.ts +1 -1
  151. package/__dev__/validation/rules/KnownDirectivesRule.d.ts +1 -1
  152. package/__dev__/validation/rules/KnownFragmentNamesRule.d.ts +1 -1
  153. package/__dev__/validation/rules/KnownOperationTypesRule.d.ts +1 -1
  154. package/__dev__/validation/rules/KnownTypeNamesRule.d.ts +1 -1
  155. package/__dev__/validation/rules/LoneAnonymousOperationRule.d.ts +1 -1
  156. package/__dev__/validation/rules/LoneSchemaDefinitionRule.d.ts +1 -1
  157. package/__dev__/validation/rules/MaxIntrospectionDepthRule.d.ts +1 -1
  158. package/__dev__/validation/rules/NoFragmentCyclesRule.d.ts +1 -1
  159. package/__dev__/validation/rules/NoUndefinedVariablesRule.d.ts +1 -1
  160. package/__dev__/validation/rules/NoUnusedFragmentsRule.d.ts +1 -1
  161. package/__dev__/validation/rules/NoUnusedVariablesRule.d.ts +1 -1
  162. package/__dev__/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +1 -1
  163. package/__dev__/validation/rules/PossibleFragmentSpreadsRule.d.ts +1 -1
  164. package/__dev__/validation/rules/PossibleTypeExtensionsRule.d.ts +1 -1
  165. package/__dev__/validation/rules/ProvidedRequiredArgumentsRule.d.ts +1 -1
  166. package/__dev__/validation/rules/ScalarLeafsRule.d.ts +1 -1
  167. package/__dev__/validation/rules/SingleFieldSubscriptionsRule.d.ts +1 -1
  168. package/__dev__/validation/rules/StreamDirectiveOnListFieldRule.d.ts +1 -1
  169. package/__dev__/validation/rules/UniqueArgumentDefinitionNamesRule.d.ts +1 -1
  170. package/__dev__/validation/rules/UniqueArgumentNamesRule.d.ts +1 -1
  171. package/__dev__/validation/rules/UniqueDirectiveNamesRule.d.ts +1 -1
  172. package/__dev__/validation/rules/UniqueDirectivesPerLocationRule.d.ts +1 -1
  173. package/__dev__/validation/rules/UniqueEnumValueNamesRule.d.ts +1 -1
  174. package/__dev__/validation/rules/UniqueFieldDefinitionNamesRule.d.ts +1 -1
  175. package/__dev__/validation/rules/UniqueFragmentNamesRule.d.ts +1 -1
  176. package/__dev__/validation/rules/UniqueInputFieldNamesRule.d.ts +1 -1
  177. package/__dev__/validation/rules/UniqueOperationNamesRule.d.ts +1 -1
  178. package/__dev__/validation/rules/UniqueOperationTypesRule.d.ts +1 -1
  179. package/__dev__/validation/rules/UniqueTypeNamesRule.d.ts +1 -1
  180. package/__dev__/validation/rules/UniqueVariableNamesRule.d.ts +1 -1
  181. package/__dev__/validation/rules/ValuesOfCorrectTypeRule.d.ts +1 -1
  182. package/__dev__/validation/rules/VariablesAreInputTypesRule.d.ts +1 -1
  183. package/__dev__/validation/rules/VariablesInAllowedPositionRule.d.ts +1 -1
  184. package/__dev__/validation/rules/custom/NoDeprecatedCustomRule.d.ts +1 -1
  185. package/__dev__/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +1 -1
  186. package/__dev__/validation/specifiedRules.d.ts +1 -1
  187. package/__dev__/validation/validate.d.ts +1 -1
  188. package/__dev__/version.d.ts +1 -1
  189. package/devMode.d.mts +29 -0
  190. package/devMode.d.ts +29 -0
  191. package/devMode.js +2 -2
  192. package/devMode.js.map +1 -1
  193. package/devMode.mjs.map +1 -1
  194. package/error/GraphQLError.d.mts +98 -14
  195. package/error/GraphQLError.d.ts +98 -14
  196. package/error/GraphQLError.js +18 -28
  197. package/error/GraphQLError.js.map +1 -1
  198. package/error/GraphQLError.mjs +11 -21
  199. package/error/GraphQLError.mjs.map +1 -1
  200. package/error/ensureGraphQLError.d.mts +3 -1
  201. package/error/ensureGraphQLError.d.ts +3 -1
  202. package/error/ensureGraphQLError.js +5 -8
  203. package/error/ensureGraphQLError.js.map +1 -1
  204. package/error/ensureGraphQLError.mjs +0 -3
  205. package/error/ensureGraphQLError.mjs.map +1 -1
  206. package/error/index.d.mts +10 -4
  207. package/error/index.d.ts +10 -4
  208. package/error/index.js +6 -6
  209. package/error/index.js.map +1 -1
  210. package/error/index.mjs.map +1 -1
  211. package/error/locatedError.d.mts +23 -3
  212. package/error/locatedError.d.ts +23 -3
  213. package/error/locatedError.js +4 -10
  214. package/error/locatedError.js.map +1 -1
  215. package/error/locatedError.mjs +0 -6
  216. package/error/locatedError.mjs.map +1 -1
  217. package/error/syntaxError.d.mts +17 -2
  218. package/error/syntaxError.d.ts +17 -2
  219. package/error/syntaxError.js +2 -6
  220. package/error/syntaxError.js.map +1 -1
  221. package/error/syntaxError.mjs +0 -4
  222. package/error/syntaxError.mjs.map +1 -1
  223. package/execution/AbortedGraphQLExecutionError.d.mts +28 -1
  224. package/execution/AbortedGraphQLExecutionError.d.ts +28 -1
  225. package/execution/AbortedGraphQLExecutionError.js.map +1 -1
  226. package/execution/AbortedGraphQLExecutionError.mjs.map +1 -1
  227. package/execution/AsyncWorkTracker.d.mts +1 -1
  228. package/execution/AsyncWorkTracker.d.ts +1 -1
  229. package/execution/AsyncWorkTracker.js +3 -7
  230. package/execution/AsyncWorkTracker.js.map +1 -1
  231. package/execution/AsyncWorkTracker.mjs +1 -5
  232. package/execution/AsyncWorkTracker.mjs.map +1 -1
  233. package/execution/ExecutionArgs.d.mts +101 -0
  234. package/execution/ExecutionArgs.d.ts +101 -0
  235. package/execution/ExecutionArgs.js +3 -0
  236. package/execution/ExecutionArgs.js.map +1 -0
  237. package/execution/ExecutionArgs.mjs +2 -0
  238. package/execution/ExecutionArgs.mjs.map +1 -0
  239. package/execution/Executor.d.mts +55 -52
  240. package/execution/Executor.d.ts +55 -52
  241. package/execution/Executor.js +84 -206
  242. package/execution/Executor.js.map +1 -1
  243. package/execution/Executor.mjs +3 -125
  244. package/execution/Executor.mjs.map +1 -1
  245. package/execution/ExecutorThrowingOnIncremental.d.mts +6 -6
  246. package/execution/ExecutorThrowingOnIncremental.d.ts +6 -6
  247. package/execution/ExecutorThrowingOnIncremental.js +11 -13
  248. package/execution/ExecutorThrowingOnIncremental.js.map +1 -1
  249. package/execution/ExecutorThrowingOnIncremental.mjs +0 -2
  250. package/execution/ExecutorThrowingOnIncremental.mjs.map +1 -1
  251. package/execution/buildResolveInfo.d.mts +16 -0
  252. package/execution/buildResolveInfo.d.ts +16 -0
  253. package/execution/buildResolveInfo.js +21 -0
  254. package/execution/buildResolveInfo.js.map +1 -0
  255. package/execution/buildResolveInfo.mjs +18 -0
  256. package/execution/buildResolveInfo.mjs.map +1 -0
  257. package/execution/cancellablePromise.d.mts +3 -0
  258. package/execution/cancellablePromise.d.ts +3 -0
  259. package/execution/cancellablePromise.js +2 -2
  260. package/execution/cancellablePromise.js.map +1 -1
  261. package/execution/cancellablePromise.mjs.map +1 -1
  262. package/execution/collectFields.d.mts +15 -9
  263. package/execution/collectFields.d.ts +15 -9
  264. package/execution/collectFields.js +19 -60
  265. package/execution/collectFields.js.map +1 -1
  266. package/execution/collectFields.mjs +0 -41
  267. package/execution/collectFields.mjs.map +1 -1
  268. package/execution/collectIteratorPromises.d.mts +2 -0
  269. package/execution/collectIteratorPromises.d.ts +2 -0
  270. package/execution/collectIteratorPromises.js +2 -7
  271. package/execution/collectIteratorPromises.js.map +1 -1
  272. package/execution/collectIteratorPromises.mjs +0 -5
  273. package/execution/collectIteratorPromises.mjs.map +1 -1
  274. package/execution/createSharedExecutionContext.d.mts +3 -2
  275. package/execution/createSharedExecutionContext.d.ts +3 -2
  276. package/execution/createSharedExecutionContext.js +2 -2
  277. package/execution/createSharedExecutionContext.js.map +1 -1
  278. package/execution/createSharedExecutionContext.mjs.map +1 -1
  279. package/execution/execute.d.mts +412 -47
  280. package/execution/execute.d.ts +412 -47
  281. package/execution/execute.js +73 -254
  282. package/execution/execute.js.map +1 -1
  283. package/execution/execute.mjs +12 -193
  284. package/execution/execute.mjs.map +1 -1
  285. package/execution/getStreamUsage.d.mts +5 -2
  286. package/execution/getStreamUsage.d.ts +5 -2
  287. package/execution/getStreamUsage.js +9 -16
  288. package/execution/getStreamUsage.js.map +1 -1
  289. package/execution/getStreamUsage.mjs +0 -7
  290. package/execution/getStreamUsage.mjs.map +1 -1
  291. package/execution/getVariableSignature.d.mts +7 -4
  292. package/execution/getVariableSignature.d.ts +7 -4
  293. package/execution/getVariableSignature.js +8 -10
  294. package/execution/getVariableSignature.js.map +1 -1
  295. package/execution/getVariableSignature.mjs +0 -2
  296. package/execution/getVariableSignature.mjs.map +1 -1
  297. package/execution/hooks.d.mts +4 -8
  298. package/execution/hooks.d.ts +4 -8
  299. package/execution/hooks.js +0 -1
  300. package/execution/hooks.js.map +1 -1
  301. package/execution/hooks.mjs +0 -1
  302. package/execution/hooks.mjs.map +1 -1
  303. package/execution/incremental/Computation.d.mts +2 -2
  304. package/execution/incremental/Computation.d.ts +2 -2
  305. package/execution/incremental/Computation.js +2 -3
  306. package/execution/incremental/Computation.js.map +1 -1
  307. package/execution/incremental/Computation.mjs +0 -1
  308. package/execution/incremental/Computation.mjs.map +1 -1
  309. package/execution/incremental/IncrementalExecutor.d.mts +137 -22
  310. package/execution/incremental/IncrementalExecutor.d.ts +137 -22
  311. package/execution/incremental/IncrementalExecutor.js +47 -77
  312. package/execution/incremental/IncrementalExecutor.js.map +1 -1
  313. package/execution/incremental/IncrementalExecutor.mjs +2 -32
  314. package/execution/incremental/IncrementalExecutor.mjs.map +1 -1
  315. package/execution/incremental/IncrementalPublisher.d.mts +4 -6
  316. package/execution/incremental/IncrementalPublisher.d.ts +4 -6
  317. package/execution/incremental/IncrementalPublisher.js +12 -18
  318. package/execution/incremental/IncrementalPublisher.js.map +1 -1
  319. package/execution/incremental/IncrementalPublisher.mjs +0 -6
  320. package/execution/incremental/IncrementalPublisher.mjs.map +1 -1
  321. package/execution/incremental/Queue.d.mts +1 -1
  322. package/execution/incremental/Queue.d.ts +1 -1
  323. package/execution/incremental/Queue.js +22 -79
  324. package/execution/incremental/Queue.js.map +1 -1
  325. package/execution/incremental/Queue.mjs +8 -64
  326. package/execution/incremental/Queue.mjs.map +1 -1
  327. package/execution/incremental/WorkQueue.d.mts +10 -2
  328. package/execution/incremental/WorkQueue.d.ts +10 -2
  329. package/execution/incremental/WorkQueue.js +7 -22
  330. package/execution/incremental/WorkQueue.js.map +1 -1
  331. package/execution/incremental/WorkQueue.mjs +0 -15
  332. package/execution/incremental/WorkQueue.mjs.map +1 -1
  333. package/execution/incremental/buildExecutionPlan.d.mts +4 -1
  334. package/execution/incremental/buildExecutionPlan.d.ts +4 -1
  335. package/execution/incremental/buildExecutionPlan.js +4 -4
  336. package/execution/incremental/buildExecutionPlan.js.map +1 -1
  337. package/execution/incremental/buildExecutionPlan.mjs.map +1 -1
  338. package/execution/index.d.mts +17 -8
  339. package/execution/index.d.ts +17 -8
  340. package/execution/index.js +26 -22
  341. package/execution/index.js.map +1 -1
  342. package/execution/index.mjs +2 -1
  343. package/execution/index.mjs.map +1 -1
  344. package/execution/legacyIncremental/BranchingIncrementalExecutor.d.mts +175 -0
  345. package/execution/legacyIncremental/BranchingIncrementalExecutor.d.ts +175 -0
  346. package/execution/legacyIncremental/BranchingIncrementalExecutor.js +69 -0
  347. package/execution/legacyIncremental/BranchingIncrementalExecutor.js.map +1 -0
  348. package/execution/legacyIncremental/BranchingIncrementalExecutor.mjs +65 -0
  349. package/execution/legacyIncremental/BranchingIncrementalExecutor.mjs.map +1 -0
  350. package/execution/legacyIncremental/BranchingIncrementalPublisher.d.mts +12 -0
  351. package/execution/legacyIncremental/BranchingIncrementalPublisher.d.ts +12 -0
  352. package/execution/legacyIncremental/BranchingIncrementalPublisher.js +131 -0
  353. package/execution/legacyIncremental/BranchingIncrementalPublisher.js.map +1 -0
  354. package/execution/legacyIncremental/BranchingIncrementalPublisher.mjs +127 -0
  355. package/execution/legacyIncremental/BranchingIncrementalPublisher.mjs.map +1 -0
  356. package/execution/legacyIncremental/legacyExecuteIncrementally.d.mts +165 -0
  357. package/execution/legacyIncremental/legacyExecuteIncrementally.d.ts +165 -0
  358. package/execution/legacyIncremental/legacyExecuteIncrementally.js +17 -0
  359. package/execution/legacyIncremental/legacyExecuteIncrementally.js.map +1 -0
  360. package/execution/legacyIncremental/legacyExecuteIncrementally.mjs +13 -0
  361. package/execution/legacyIncremental/legacyExecuteIncrementally.mjs.map +1 -0
  362. package/execution/mapAsyncIterable.d.mts +3 -1
  363. package/execution/mapAsyncIterable.d.ts +3 -1
  364. package/execution/mapAsyncIterable.js +4 -9
  365. package/execution/mapAsyncIterable.js.map +1 -1
  366. package/execution/mapAsyncIterable.mjs +0 -5
  367. package/execution/mapAsyncIterable.mjs.map +1 -1
  368. package/execution/returnIteratorCatchingErrors.d.mts +1 -0
  369. package/execution/returnIteratorCatchingErrors.d.ts +1 -0
  370. package/execution/returnIteratorCatchingErrors.js +1 -2
  371. package/execution/returnIteratorCatchingErrors.js.map +1 -1
  372. package/execution/returnIteratorCatchingErrors.mjs +1 -2
  373. package/execution/returnIteratorCatchingErrors.mjs.map +1 -1
  374. package/execution/values.d.mts +196 -14
  375. package/execution/values.d.ts +196 -14
  376. package/execution/values.js +45 -86
  377. package/execution/values.js.map +1 -1
  378. package/execution/values.mjs +14 -55
  379. package/execution/values.mjs.map +1 -1
  380. package/execution/withConcurrentAbruptClose.d.mts +3 -1
  381. package/execution/withConcurrentAbruptClose.d.ts +3 -1
  382. package/execution/withConcurrentAbruptClose.js +3 -17
  383. package/execution/withConcurrentAbruptClose.js.map +1 -1
  384. package/execution/withConcurrentAbruptClose.mjs +1 -15
  385. package/execution/withConcurrentAbruptClose.mjs.map +1 -1
  386. package/graphql.d.mts +198 -50
  387. package/graphql.d.ts +198 -50
  388. package/graphql.js +11 -23
  389. package/graphql.js.map +1 -1
  390. package/graphql.mjs +0 -12
  391. package/graphql.mjs.map +1 -1
  392. package/harness.d.mts +21 -4
  393. package/harness.d.ts +21 -4
  394. package/harness.js +7 -7
  395. package/harness.js.map +1 -1
  396. package/harness.mjs.map +1 -1
  397. package/index.d.mts +41 -39
  398. package/index.d.ts +41 -39
  399. package/index.js +260 -346
  400. package/index.js.map +1 -1
  401. package/index.mjs +5 -149
  402. package/index.mjs.map +1 -1
  403. package/jsutils/AccumulatorMap.d.mts +2 -0
  404. package/jsutils/AccumulatorMap.d.ts +2 -0
  405. package/jsutils/AccumulatorMap.js +0 -4
  406. package/jsutils/AccumulatorMap.js.map +1 -1
  407. package/jsutils/AccumulatorMap.mjs +0 -4
  408. package/jsutils/AccumulatorMap.mjs.map +1 -1
  409. package/jsutils/Maybe.d.mts +5 -1
  410. package/jsutils/Maybe.d.ts +5 -1
  411. package/jsutils/Maybe.js.map +1 -1
  412. package/jsutils/Maybe.mjs.map +1 -1
  413. package/jsutils/ObjMap.d.mts +6 -0
  414. package/jsutils/ObjMap.d.ts +6 -0
  415. package/jsutils/ObjMap.js.map +1 -1
  416. package/jsutils/ObjMap.mjs.map +1 -1
  417. package/jsutils/Path.d.mts +31 -1
  418. package/jsutils/Path.d.ts +31 -1
  419. package/jsutils/Path.js +0 -6
  420. package/jsutils/Path.js.map +1 -1
  421. package/jsutils/Path.mjs +0 -6
  422. package/jsutils/Path.mjs.map +1 -1
  423. package/jsutils/PromiseOrValue.d.mts +1 -0
  424. package/jsutils/PromiseOrValue.d.ts +1 -0
  425. package/jsutils/PromiseOrValue.js.map +1 -1
  426. package/jsutils/PromiseOrValue.mjs.map +1 -1
  427. package/jsutils/capitalize.d.mts +2 -0
  428. package/jsutils/capitalize.d.ts +2 -0
  429. package/jsutils/capitalize.js +0 -3
  430. package/jsutils/capitalize.js.map +1 -1
  431. package/jsutils/capitalize.mjs +0 -3
  432. package/jsutils/capitalize.mjs.map +1 -1
  433. package/jsutils/devAssert.d.mts +1 -0
  434. package/jsutils/devAssert.d.ts +1 -0
  435. package/jsutils/devAssert.js.map +1 -1
  436. package/jsutils/devAssert.mjs.map +1 -1
  437. package/jsutils/didYouMean.d.mts +4 -1
  438. package/jsutils/didYouMean.d.ts +4 -1
  439. package/jsutils/didYouMean.js +2 -2
  440. package/jsutils/didYouMean.js.map +1 -1
  441. package/jsutils/didYouMean.mjs.map +1 -1
  442. package/jsutils/formatList.d.mts +6 -2
  443. package/jsutils/formatList.d.ts +6 -2
  444. package/jsutils/formatList.js +2 -8
  445. package/jsutils/formatList.js.map +1 -1
  446. package/jsutils/formatList.mjs +0 -6
  447. package/jsutils/formatList.mjs.map +1 -1
  448. package/jsutils/getBySet.d.mts +1 -0
  449. package/jsutils/getBySet.d.ts +1 -0
  450. package/jsutils/getBySet.js +2 -2
  451. package/jsutils/getBySet.js.map +1 -1
  452. package/jsutils/getBySet.mjs.map +1 -1
  453. package/jsutils/groupBy.d.mts +2 -0
  454. package/jsutils/groupBy.d.ts +2 -0
  455. package/jsutils/groupBy.js +2 -5
  456. package/jsutils/groupBy.js.map +1 -1
  457. package/jsutils/groupBy.mjs +0 -3
  458. package/jsutils/groupBy.mjs.map +1 -1
  459. package/jsutils/identityFunc.d.mts +2 -0
  460. package/jsutils/identityFunc.d.ts +2 -0
  461. package/jsutils/identityFunc.js +0 -3
  462. package/jsutils/identityFunc.js.map +1 -1
  463. package/jsutils/identityFunc.mjs +0 -3
  464. package/jsutils/identityFunc.mjs.map +1 -1
  465. package/jsutils/inspect.d.mts +2 -0
  466. package/jsutils/inspect.d.ts +2 -0
  467. package/jsutils/inspect.js +0 -4
  468. package/jsutils/inspect.js.map +1 -1
  469. package/jsutils/inspect.mjs +0 -4
  470. package/jsutils/inspect.mjs.map +1 -1
  471. package/jsutils/instanceOf.d.mts +2 -0
  472. package/jsutils/instanceOf.d.ts +2 -0
  473. package/jsutils/instanceOf.js +3 -14
  474. package/jsutils/instanceOf.js.map +1 -1
  475. package/jsutils/instanceOf.mjs +1 -12
  476. package/jsutils/instanceOf.mjs.map +1 -1
  477. package/jsutils/invariant.d.mts +1 -0
  478. package/jsutils/invariant.d.ts +1 -0
  479. package/jsutils/invariant.js.map +1 -1
  480. package/jsutils/invariant.mjs.map +1 -1
  481. package/jsutils/isAsyncIterable.d.mts +2 -0
  482. package/jsutils/isAsyncIterable.d.ts +2 -0
  483. package/jsutils/isAsyncIterable.js +0 -4
  484. package/jsutils/isAsyncIterable.js.map +1 -1
  485. package/jsutils/isAsyncIterable.mjs +0 -4
  486. package/jsutils/isAsyncIterable.mjs.map +1 -1
  487. package/jsutils/isIterableObject.d.mts +6 -5
  488. package/jsutils/isIterableObject.d.ts +6 -5
  489. package/jsutils/isIterableObject.js +0 -17
  490. package/jsutils/isIterableObject.js.map +1 -1
  491. package/jsutils/isIterableObject.mjs +0 -17
  492. package/jsutils/isIterableObject.mjs.map +1 -1
  493. package/jsutils/isObjectLike.d.mts +2 -0
  494. package/jsutils/isObjectLike.d.ts +2 -0
  495. package/jsutils/isObjectLike.js +0 -4
  496. package/jsutils/isObjectLike.js.map +1 -1
  497. package/jsutils/isObjectLike.mjs +0 -4
  498. package/jsutils/isObjectLike.mjs.map +1 -1
  499. package/jsutils/isPromise.d.mts +3 -0
  500. package/jsutils/isPromise.d.ts +3 -0
  501. package/jsutils/isPromise.js +0 -4
  502. package/jsutils/isPromise.js.map +1 -1
  503. package/jsutils/isPromise.mjs +0 -4
  504. package/jsutils/isPromise.mjs.map +1 -1
  505. package/jsutils/isSameSet.d.mts +1 -0
  506. package/jsutils/isSameSet.d.ts +1 -0
  507. package/jsutils/isSameSet.js.map +1 -1
  508. package/jsutils/isSameSet.mjs.map +1 -1
  509. package/jsutils/keyMap.d.mts +8 -15
  510. package/jsutils/keyMap.d.ts +8 -15
  511. package/jsutils/keyMap.js +0 -27
  512. package/jsutils/keyMap.js.map +1 -1
  513. package/jsutils/keyMap.mjs +0 -27
  514. package/jsutils/keyMap.mjs.map +1 -1
  515. package/jsutils/keyValMap.d.mts +10 -7
  516. package/jsutils/keyValMap.d.ts +10 -7
  517. package/jsutils/keyValMap.js +0 -17
  518. package/jsutils/keyValMap.js.map +1 -1
  519. package/jsutils/keyValMap.mjs +0 -17
  520. package/jsutils/keyValMap.mjs.map +1 -1
  521. package/jsutils/mapValue.d.mts +3 -1
  522. package/jsutils/mapValue.d.ts +3 -1
  523. package/jsutils/mapValue.js +0 -4
  524. package/jsutils/mapValue.js.map +1 -1
  525. package/jsutils/mapValue.mjs +0 -4
  526. package/jsutils/mapValue.mjs.map +1 -1
  527. package/jsutils/memoize1.d.mts +2 -0
  528. package/jsutils/memoize1.d.ts +2 -0
  529. package/jsutils/memoize1.js +0 -3
  530. package/jsutils/memoize1.js.map +1 -1
  531. package/jsutils/memoize1.mjs +0 -3
  532. package/jsutils/memoize1.mjs.map +1 -1
  533. package/jsutils/memoize2.d.mts +2 -0
  534. package/jsutils/memoize2.d.ts +2 -0
  535. package/jsutils/memoize2.js +0 -3
  536. package/jsutils/memoize2.js.map +1 -1
  537. package/jsutils/memoize2.mjs +0 -3
  538. package/jsutils/memoize2.mjs.map +1 -1
  539. package/jsutils/memoize3.d.mts +2 -0
  540. package/jsutils/memoize3.d.ts +2 -0
  541. package/jsutils/memoize3.js +0 -3
  542. package/jsutils/memoize3.js.map +1 -1
  543. package/jsutils/memoize3.mjs +0 -3
  544. package/jsutils/memoize3.mjs.map +1 -1
  545. package/jsutils/naturalCompare.d.mts +1 -0
  546. package/jsutils/naturalCompare.d.ts +1 -0
  547. package/jsutils/naturalCompare.js +0 -7
  548. package/jsutils/naturalCompare.js.map +1 -1
  549. package/jsutils/naturalCompare.mjs +0 -7
  550. package/jsutils/naturalCompare.mjs.map +1 -1
  551. package/jsutils/printPathArray.d.mts +2 -0
  552. package/jsutils/printPathArray.d.ts +2 -0
  553. package/jsutils/printPathArray.js +0 -3
  554. package/jsutils/printPathArray.js.map +1 -1
  555. package/jsutils/printPathArray.mjs +0 -3
  556. package/jsutils/printPathArray.mjs.map +1 -1
  557. package/jsutils/promiseForObject.d.mts +4 -2
  558. package/jsutils/promiseForObject.d.ts +4 -2
  559. package/jsutils/promiseForObject.js +0 -7
  560. package/jsutils/promiseForObject.js.map +1 -1
  561. package/jsutils/promiseForObject.mjs +0 -7
  562. package/jsutils/promiseForObject.mjs.map +1 -1
  563. package/jsutils/promiseReduce.d.mts +3 -1
  564. package/jsutils/promiseReduce.d.ts +3 -1
  565. package/jsutils/promiseReduce.js +2 -9
  566. package/jsutils/promiseReduce.js.map +1 -1
  567. package/jsutils/promiseReduce.mjs +0 -7
  568. package/jsutils/promiseReduce.mjs.map +1 -1
  569. package/jsutils/promiseWithResolvers.d.mts +3 -1
  570. package/jsutils/promiseWithResolvers.d.ts +3 -1
  571. package/jsutils/promiseWithResolvers.js +0 -5
  572. package/jsutils/promiseWithResolvers.js.map +1 -1
  573. package/jsutils/promiseWithResolvers.mjs +0 -5
  574. package/jsutils/promiseWithResolvers.mjs.map +1 -1
  575. package/jsutils/suggestionList.d.mts +2 -0
  576. package/jsutils/suggestionList.d.ts +2 -0
  577. package/jsutils/suggestionList.js +3 -26
  578. package/jsutils/suggestionList.js.map +1 -1
  579. package/jsutils/suggestionList.mjs +1 -24
  580. package/jsutils/suggestionList.mjs.map +1 -1
  581. package/jsutils/toError.d.mts +2 -0
  582. package/jsutils/toError.d.ts +2 -0
  583. package/jsutils/toError.js +2 -5
  584. package/jsutils/toError.js.map +1 -1
  585. package/jsutils/toError.mjs +0 -3
  586. package/jsutils/toError.mjs.map +1 -1
  587. package/jsutils/toObjMap.d.mts +4 -2
  588. package/jsutils/toObjMap.d.ts +4 -2
  589. package/jsutils/toObjMap.js.map +1 -1
  590. package/jsutils/toObjMap.mjs.map +1 -1
  591. package/language/KindTypeMap.d.mts +2 -1
  592. package/language/KindTypeMap.d.ts +2 -1
  593. package/language/KindTypeMap.js.map +1 -1
  594. package/language/KindTypeMap.mjs.map +1 -1
  595. package/language/ast.d.mts +425 -58
  596. package/language/ast.d.ts +425 -58
  597. package/language/ast.js +8 -21
  598. package/language/ast.js.map +1 -1
  599. package/language/ast.mjs +8 -21
  600. package/language/ast.mjs.map +1 -1
  601. package/language/blockString.d.mts +1 -3
  602. package/language/blockString.d.ts +1 -3
  603. package/language/blockString.js +15 -41
  604. package/language/blockString.js.map +1 -1
  605. package/language/blockString.mjs +11 -37
  606. package/language/blockString.mjs.map +1 -1
  607. package/language/characterClasses.js +2 -45
  608. package/language/characterClasses.js.map +1 -1
  609. package/language/characterClasses.mjs +2 -45
  610. package/language/characterClasses.mjs.map +1 -1
  611. package/language/directiveLocation.d.mts +26 -6
  612. package/language/directiveLocation.d.ts +26 -6
  613. package/language/directiveLocation.js +2 -6
  614. package/language/directiveLocation.js.map +1 -1
  615. package/language/directiveLocation.mjs +2 -6
  616. package/language/directiveLocation.mjs.map +1 -1
  617. package/language/index.d.mts +22 -16
  618. package/language/index.d.ts +22 -16
  619. package/language/index.js +45 -49
  620. package/language/index.js.map +1 -1
  621. package/language/index.mjs +0 -4
  622. package/language/index.mjs.map +1 -1
  623. package/language/kinds.d.mts +5 -2
  624. package/language/kinds.d.ts +5 -2
  625. package/language/kinds.js.map +1 -1
  626. package/language/kinds.mjs.map +1 -1
  627. package/language/kinds_.d.mts +102 -12
  628. package/language/kinds_.d.ts +102 -12
  629. package/language/kinds_.js +2 -14
  630. package/language/kinds_.js.map +1 -1
  631. package/language/kinds_.mjs +1 -13
  632. package/language/kinds_.mjs.map +1 -1
  633. package/language/lexer.d.mts +51 -18
  634. package/language/lexer.d.ts +51 -18
  635. package/language/lexer.js +102 -343
  636. package/language/lexer.js.map +1 -1
  637. package/language/lexer.mjs +37 -278
  638. package/language/lexer.mjs.map +1 -1
  639. package/language/location.d.mts +17 -4
  640. package/language/location.d.ts +17 -4
  641. package/language/location.js +2 -6
  642. package/language/location.js.map +1 -1
  643. package/language/location.mjs +0 -4
  644. package/language/location.mjs.map +1 -1
  645. package/language/parser.d.mts +243 -15
  646. package/language/parser.d.ts +243 -15
  647. package/language/parser.js +183 -528
  648. package/language/parser.js.map +1 -1
  649. package/language/parser.mjs +26 -371
  650. package/language/parser.mjs.map +1 -1
  651. package/language/predicates.d.mts +182 -1
  652. package/language/predicates.d.ts +182 -1
  653. package/language/predicates.js +45 -49
  654. package/language/predicates.js.map +1 -1
  655. package/language/predicates.mjs +3 -7
  656. package/language/predicates.mjs.map +1 -1
  657. package/language/printLocation.d.mts +31 -3
  658. package/language/printLocation.d.ts +31 -3
  659. package/language/printLocation.js +2 -10
  660. package/language/printLocation.js.map +1 -1
  661. package/language/printLocation.mjs +0 -8
  662. package/language/printLocation.mjs.map +1 -1
  663. package/language/printString.d.mts +2 -0
  664. package/language/printString.d.ts +2 -0
  665. package/language/printString.js +5 -11
  666. package/language/printString.js.map +1 -1
  667. package/language/printString.mjs +5 -11
  668. package/language/printString.mjs.map +1 -1
  669. package/language/printer.d.mts +13 -1
  670. package/language/printer.d.ts +13 -1
  671. package/language/printer.js +10 -31
  672. package/language/printer.js.map +1 -1
  673. package/language/printer.mjs +5 -26
  674. package/language/printer.mjs.map +1 -1
  675. package/language/schemaCoordinateLexer.d.mts +17 -3
  676. package/language/schemaCoordinateLexer.d.ts +17 -3
  677. package/language/schemaCoordinateLexer.js +21 -51
  678. package/language/schemaCoordinateLexer.js.map +1 -1
  679. package/language/schemaCoordinateLexer.mjs +5 -35
  680. package/language/schemaCoordinateLexer.mjs.map +1 -1
  681. package/language/source.d.mts +28 -1
  682. package/language/source.d.ts +28 -1
  683. package/language/source.js +5 -17
  684. package/language/source.js.map +1 -1
  685. package/language/source.mjs +0 -12
  686. package/language/source.mjs.map +1 -1
  687. package/language/tokenKind.d.mts +5 -0
  688. package/language/tokenKind.d.ts +5 -0
  689. package/language/tokenKind.js +0 -4
  690. package/language/tokenKind.js.map +1 -1
  691. package/language/tokenKind.mjs +0 -4
  692. package/language/tokenKind.mjs.map +1 -1
  693. package/language/visitor.d.mts +184 -74
  694. package/language/visitor.d.ts +184 -74
  695. package/language/visitor.js +10 -25
  696. package/language/visitor.js.map +1 -1
  697. package/language/visitor.mjs +0 -15
  698. package/language/visitor.mjs.map +1 -1
  699. package/package.json +2 -2
  700. package/type/assertName.d.mts +18 -1
  701. package/type/assertName.d.ts +18 -1
  702. package/type/assertName.js +8 -16
  703. package/type/assertName.js.map +1 -1
  704. package/type/assertName.mjs +0 -8
  705. package/type/assertName.mjs.map +1 -1
  706. package/type/definition.d.mts +3268 -138
  707. package/type/definition.d.ts +3268 -138
  708. package/type/definition.js +99 -346
  709. package/type/definition.js.map +1 -1
  710. package/type/definition.mjs +5 -252
  711. package/type/definition.mjs.map +1 -1
  712. package/type/directives.d.mts +220 -26
  713. package/type/directives.d.ts +220 -26
  714. package/type/directives.js +51 -83
  715. package/type/directives.js.map +1 -1
  716. package/type/directives.mjs +5 -37
  717. package/type/directives.mjs.map +1 -1
  718. package/type/index.d.mts +18 -12
  719. package/type/index.d.ts +18 -12
  720. package/type/index.js +106 -129
  721. package/type/index.js.map +1 -1
  722. package/type/index.mjs +5 -48
  723. package/type/index.mjs.map +1 -1
  724. package/type/introspection.d.mts +38 -2
  725. package/type/introspection.d.ts +38 -2
  726. package/type/introspection.js +122 -107
  727. package/type/introspection.js.map +1 -1
  728. package/type/introspection.mjs +24 -9
  729. package/type/introspection.mjs.map +1 -1
  730. package/type/scalars.d.mts +31 -4
  731. package/type/scalars.d.ts +31 -4
  732. package/type/scalars.js +61 -76
  733. package/type/scalars.js.map +1 -1
  734. package/type/scalars.mjs +0 -15
  735. package/type/scalars.mjs.map +1 -1
  736. package/type/schema.d.mts +514 -38
  737. package/type/schema.d.ts +514 -38
  738. package/type/schema.js +32 -129
  739. package/type/schema.js.map +1 -1
  740. package/type/schema.mjs +0 -97
  741. package/type/schema.mjs.map +1 -1
  742. package/type/validate.d.mts +36 -7
  743. package/type/validate.d.ts +36 -7
  744. package/type/validate.js +83 -195
  745. package/type/validate.js.map +1 -1
  746. package/type/validate.mjs +1 -113
  747. package/type/validate.mjs.map +1 -1
  748. package/utilities/TypeInfo.d.mts +570 -7
  749. package/utilities/TypeInfo.d.ts +570 -7
  750. package/utilities/TypeInfo.js +62 -85
  751. package/utilities/TypeInfo.js.map +1 -1
  752. package/utilities/TypeInfo.mjs +2 -25
  753. package/utilities/TypeInfo.mjs.map +1 -1
  754. package/utilities/astFromValue.d.mts +39 -6
  755. package/utilities/astFromValue.d.ts +39 -6
  756. package/utilities/astFromValue.js +30 -74
  757. package/utilities/astFromValue.js.map +1 -1
  758. package/utilities/astFromValue.mjs +0 -44
  759. package/utilities/astFromValue.mjs.map +1 -1
  760. package/utilities/buildASTSchema.d.mts +71 -11
  761. package/utilities/buildASTSchema.d.ts +71 -11
  762. package/utilities/buildASTSchema.js +11 -31
  763. package/utilities/buildASTSchema.js.map +1 -1
  764. package/utilities/buildASTSchema.mjs +1 -21
  765. package/utilities/buildASTSchema.mjs.map +1 -1
  766. package/utilities/buildClientSchema.d.mts +20 -5
  767. package/utilities/buildClientSchema.d.ts +20 -5
  768. package/utilities/buildClientSchema.js +53 -83
  769. package/utilities/buildClientSchema.js.map +1 -1
  770. package/utilities/buildClientSchema.mjs +1 -30
  771. package/utilities/buildClientSchema.mjs.map +1 -1
  772. package/utilities/coerceInputValue.d.mts +88 -6
  773. package/utilities/coerceInputValue.d.ts +88 -6
  774. package/utilities/coerceInputValue.js +52 -81
  775. package/utilities/coerceInputValue.js.map +1 -1
  776. package/utilities/coerceInputValue.mjs +21 -50
  777. package/utilities/coerceInputValue.mjs.map +1 -1
  778. package/utilities/concatAST.d.mts +13 -1
  779. package/utilities/concatAST.d.ts +13 -1
  780. package/utilities/concatAST.js +2 -7
  781. package/utilities/concatAST.js.map +1 -1
  782. package/utilities/concatAST.mjs +0 -5
  783. package/utilities/concatAST.mjs.map +1 -1
  784. package/utilities/extendSchema.d.mts +61 -6
  785. package/utilities/extendSchema.d.ts +61 -6
  786. package/utilities/extendSchema.js +92 -126
  787. package/utilities/extendSchema.js.map +1 -1
  788. package/utilities/extendSchema.mjs +27 -61
  789. package/utilities/extendSchema.mjs.map +1 -1
  790. package/utilities/findSchemaChanges.d.mts +100 -2
  791. package/utilities/findSchemaChanges.d.ts +100 -2
  792. package/utilities/findSchemaChanges.js +41 -75
  793. package/utilities/findSchemaChanges.js.map +1 -1
  794. package/utilities/findSchemaChanges.mjs +3 -37
  795. package/utilities/findSchemaChanges.mjs.map +1 -1
  796. package/utilities/getDefaultValueAST.d.mts +3 -2
  797. package/utilities/getDefaultValueAST.d.ts +3 -2
  798. package/utilities/getDefaultValueAST.js +7 -7
  799. package/utilities/getDefaultValueAST.js.map +1 -1
  800. package/utilities/getDefaultValueAST.mjs.map +1 -1
  801. package/utilities/getIntrospectionQuery.d.mts +151 -3
  802. package/utilities/getIntrospectionQuery.d.ts +151 -3
  803. package/utilities/getIntrospectionQuery.js +22 -42
  804. package/utilities/getIntrospectionQuery.js.map +1 -1
  805. package/utilities/getIntrospectionQuery.mjs +22 -42
  806. package/utilities/getIntrospectionQuery.mjs.map +1 -1
  807. package/utilities/getOperationAST.d.mts +17 -2
  808. package/utilities/getOperationAST.d.ts +17 -2
  809. package/utilities/getOperationAST.js +2 -10
  810. package/utilities/getOperationAST.js.map +1 -1
  811. package/utilities/getOperationAST.mjs +0 -8
  812. package/utilities/getOperationAST.mjs.map +1 -1
  813. package/utilities/index.d.mts +45 -30
  814. package/utilities/index.d.ts +45 -30
  815. package/utilities/index.js +61 -88
  816. package/utilities/index.js.map +1 -1
  817. package/utilities/index.mjs +4 -37
  818. package/utilities/index.mjs.map +1 -1
  819. package/utilities/introspectionFromSchema.d.mts +56 -2
  820. package/utilities/introspectionFromSchema.d.ts +56 -2
  821. package/utilities/introspectionFromSchema.js +8 -16
  822. package/utilities/introspectionFromSchema.js.map +1 -1
  823. package/utilities/introspectionFromSchema.mjs +1 -9
  824. package/utilities/introspectionFromSchema.mjs.map +1 -1
  825. package/utilities/lexicographicSortSchema.d.mts +36 -1
  826. package/utilities/lexicographicSortSchema.d.ts +36 -1
  827. package/utilities/lexicographicSortSchema.js +14 -19
  828. package/utilities/lexicographicSortSchema.js.map +1 -1
  829. package/utilities/lexicographicSortSchema.mjs +0 -5
  830. package/utilities/lexicographicSortSchema.mjs.map +1 -1
  831. package/utilities/mapSchemaConfig.d.mts +9 -6
  832. package/utilities/mapSchemaConfig.d.ts +9 -6
  833. package/utilities/mapSchemaConfig.js +28 -40
  834. package/utilities/mapSchemaConfig.js.map +1 -1
  835. package/utilities/mapSchemaConfig.mjs +0 -12
  836. package/utilities/mapSchemaConfig.mjs.map +1 -1
  837. package/utilities/printSchema.d.mts +87 -3
  838. package/utilities/printSchema.d.ts +87 -3
  839. package/utilities/printSchema.js +30 -59
  840. package/utilities/printSchema.js.map +1 -1
  841. package/utilities/printSchema.mjs +1 -30
  842. package/utilities/printSchema.mjs.map +1 -1
  843. package/utilities/replaceVariables.d.mts +40 -4
  844. package/utilities/replaceVariables.d.ts +40 -4
  845. package/utilities/replaceVariables.js +9 -17
  846. package/utilities/replaceVariables.js.map +1 -1
  847. package/utilities/replaceVariables.mjs +0 -8
  848. package/utilities/replaceVariables.mjs.map +1 -1
  849. package/utilities/resolveSchemaCoordinate.d.mts +67 -5
  850. package/utilities/resolveSchemaCoordinate.d.ts +67 -5
  851. package/utilities/resolveSchemaCoordinate.js +23 -79
  852. package/utilities/resolveSchemaCoordinate.js.map +1 -1
  853. package/utilities/resolveSchemaCoordinate.mjs +0 -56
  854. package/utilities/resolveSchemaCoordinate.mjs.map +1 -1
  855. package/utilities/separateOperations.d.mts +32 -2
  856. package/utilities/separateOperations.d.ts +32 -2
  857. package/utilities/separateOperations.js +7 -22
  858. package/utilities/separateOperations.js.map +1 -1
  859. package/utilities/separateOperations.mjs +0 -15
  860. package/utilities/separateOperations.mjs.map +1 -1
  861. package/utilities/sortValueNode.d.mts +1 -1
  862. package/utilities/sortValueNode.d.ts +1 -1
  863. package/utilities/sortValueNode.js +12 -19
  864. package/utilities/sortValueNode.js.map +1 -1
  865. package/utilities/sortValueNode.mjs +0 -7
  866. package/utilities/sortValueNode.mjs.map +1 -1
  867. package/utilities/stripIgnoredCharacters.d.mts +14 -7
  868. package/utilities/stripIgnoredCharacters.d.ts +14 -7
  869. package/utilities/stripIgnoredCharacters.js +11 -76
  870. package/utilities/stripIgnoredCharacters.js.map +1 -1
  871. package/utilities/stripIgnoredCharacters.mjs +0 -65
  872. package/utilities/stripIgnoredCharacters.mjs.map +1 -1
  873. package/utilities/typeComparators.d.mts +86 -2
  874. package/utilities/typeComparators.d.ts +86 -2
  875. package/utilities/typeComparators.js +14 -47
  876. package/utilities/typeComparators.js.map +1 -1
  877. package/utilities/typeComparators.mjs +0 -33
  878. package/utilities/typeComparators.mjs.map +1 -1
  879. package/utilities/typeFromAST.d.mts +90 -4
  880. package/utilities/typeFromAST.d.ts +90 -4
  881. package/utilities/typeFromAST.js +7 -7
  882. package/utilities/typeFromAST.js.map +1 -1
  883. package/utilities/typeFromAST.mjs.map +1 -1
  884. package/utilities/typedQueryDocumentNode.d.mts +5 -1
  885. package/utilities/typedQueryDocumentNode.d.ts +5 -1
  886. package/utilities/typedQueryDocumentNode.js.map +1 -1
  887. package/utilities/typedQueryDocumentNode.mjs.map +1 -1
  888. package/utilities/validateInputValue.d.mts +129 -6
  889. package/utilities/validateInputValue.d.ts +129 -6
  890. package/utilities/validateInputValue.js +60 -80
  891. package/utilities/validateInputValue.js.map +1 -1
  892. package/utilities/validateInputValue.mjs +0 -20
  893. package/utilities/validateInputValue.mjs.map +1 -1
  894. package/utilities/valueFromAST.d.mts +45 -4
  895. package/utilities/valueFromAST.d.ts +45 -4
  896. package/utilities/valueFromAST.js +32 -72
  897. package/utilities/valueFromAST.js.map +1 -1
  898. package/utilities/valueFromAST.mjs +13 -53
  899. package/utilities/valueFromAST.mjs.map +1 -1
  900. package/utilities/valueFromASTUntyped.d.mts +18 -5
  901. package/utilities/valueFromASTUntyped.d.ts +18 -5
  902. package/utilities/valueFromASTUntyped.js +12 -28
  903. package/utilities/valueFromASTUntyped.js.map +1 -1
  904. package/utilities/valueFromASTUntyped.mjs +0 -16
  905. package/utilities/valueFromASTUntyped.mjs.map +1 -1
  906. package/utilities/valueToLiteral.d.mts +32 -3
  907. package/utilities/valueToLiteral.d.ts +32 -3
  908. package/utilities/valueToLiteral.js +37 -70
  909. package/utilities/valueToLiteral.js.map +1 -1
  910. package/utilities/valueToLiteral.mjs +7 -40
  911. package/utilities/valueToLiteral.mjs.map +1 -1
  912. package/validation/ValidationContext.d.mts +499 -9
  913. package/validation/ValidationContext.d.ts +499 -9
  914. package/validation/ValidationContext.js +9 -16
  915. package/validation/ValidationContext.js.map +1 -1
  916. package/validation/ValidationContext.mjs +1 -8
  917. package/validation/ValidationContext.mjs.map +1 -1
  918. package/validation/index.d.mts +53 -46
  919. package/validation/index.d.ts +53 -46
  920. package/validation/index.js +91 -125
  921. package/validation/index.js.map +1 -1
  922. package/validation/index.mjs +0 -34
  923. package/validation/index.mjs.map +1 -1
  924. package/validation/rules/DeferStreamDirectiveLabelRule.d.mts +32 -2
  925. package/validation/rules/DeferStreamDirectiveLabelRule.d.ts +32 -2
  926. package/validation/rules/DeferStreamDirectiveLabelRule.js +9 -14
  927. package/validation/rules/DeferStreamDirectiveLabelRule.js.map +1 -1
  928. package/validation/rules/DeferStreamDirectiveLabelRule.mjs +0 -5
  929. package/validation/rules/DeferStreamDirectiveLabelRule.mjs.map +1 -1
  930. package/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.mts +30 -2
  931. package/validation/rules/DeferStreamDirectiveOnRootFieldRule.d.ts +30 -2
  932. package/validation/rules/DeferStreamDirectiveOnRootFieldRule.js +8 -13
  933. package/validation/rules/DeferStreamDirectiveOnRootFieldRule.js.map +1 -1
  934. package/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs +0 -5
  935. package/validation/rules/DeferStreamDirectiveOnRootFieldRule.mjs.map +1 -1
  936. package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.mts +54 -2
  937. package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.d.ts +54 -2
  938. package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js +14 -19
  939. package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.js.map +1 -1
  940. package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs +0 -5
  941. package/validation/rules/DeferStreamDirectiveOnValidOperationsRule.mjs.map +1 -1
  942. package/validation/rules/ExecutableDefinitionsRule.d.mts +30 -2
  943. package/validation/rules/ExecutableDefinitionsRule.d.ts +30 -2
  944. package/validation/rules/ExecutableDefinitionsRule.js +7 -15
  945. package/validation/rules/ExecutableDefinitionsRule.js.map +1 -1
  946. package/validation/rules/ExecutableDefinitionsRule.mjs +0 -8
  947. package/validation/rules/ExecutableDefinitionsRule.mjs.map +1 -1
  948. package/validation/rules/FieldsOnCorrectTypeRule.d.mts +30 -2
  949. package/validation/rules/FieldsOnCorrectTypeRule.d.ts +30 -2
  950. package/validation/rules/FieldsOnCorrectTypeRule.js +14 -41
  951. package/validation/rules/FieldsOnCorrectTypeRule.js.map +1 -1
  952. package/validation/rules/FieldsOnCorrectTypeRule.mjs +0 -27
  953. package/validation/rules/FieldsOnCorrectTypeRule.mjs.map +1 -1
  954. package/validation/rules/FragmentsOnCompositeTypesRule.d.mts +30 -2
  955. package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +30 -2
  956. package/validation/rules/FragmentsOnCompositeTypesRule.js +12 -21
  957. package/validation/rules/FragmentsOnCompositeTypesRule.js.map +1 -1
  958. package/validation/rules/FragmentsOnCompositeTypesRule.mjs +0 -9
  959. package/validation/rules/FragmentsOnCompositeTypesRule.mjs.map +1 -1
  960. package/validation/rules/KnownArgumentNamesRule.d.mts +31 -5
  961. package/validation/rules/KnownArgumentNamesRule.d.ts +31 -5
  962. package/validation/rules/KnownArgumentNamesRule.js +16 -29
  963. package/validation/rules/KnownArgumentNamesRule.js.map +1 -1
  964. package/validation/rules/KnownArgumentNamesRule.mjs +0 -13
  965. package/validation/rules/KnownArgumentNamesRule.mjs.map +1 -1
  966. package/validation/rules/KnownDirectivesRule.d.mts +30 -2
  967. package/validation/rules/KnownDirectivesRule.d.ts +30 -2
  968. package/validation/rules/KnownDirectivesRule.js +66 -73
  969. package/validation/rules/KnownDirectivesRule.js.map +1 -1
  970. package/validation/rules/KnownDirectivesRule.mjs +3 -10
  971. package/validation/rules/KnownDirectivesRule.mjs.map +1 -1
  972. package/validation/rules/KnownFragmentNamesRule.d.mts +30 -2
  973. package/validation/rules/KnownFragmentNamesRule.d.ts +30 -2
  974. package/validation/rules/KnownFragmentNamesRule.js +2 -10
  975. package/validation/rules/KnownFragmentNamesRule.js.map +1 -1
  976. package/validation/rules/KnownFragmentNamesRule.mjs +0 -8
  977. package/validation/rules/KnownFragmentNamesRule.mjs.map +1 -1
  978. package/validation/rules/KnownOperationTypesRule.d.mts +22 -2
  979. package/validation/rules/KnownOperationTypesRule.d.ts +22 -2
  980. package/validation/rules/KnownOperationTypesRule.js +2 -10
  981. package/validation/rules/KnownOperationTypesRule.js.map +1 -1
  982. package/validation/rules/KnownOperationTypesRule.mjs +0 -8
  983. package/validation/rules/KnownOperationTypesRule.mjs.map +1 -1
  984. package/validation/rules/KnownTypeNamesRule.d.mts +30 -2
  985. package/validation/rules/KnownTypeNamesRule.d.ts +30 -2
  986. package/validation/rules/KnownTypeNamesRule.js +11 -19
  987. package/validation/rules/KnownTypeNamesRule.js.map +1 -1
  988. package/validation/rules/KnownTypeNamesRule.mjs +0 -8
  989. package/validation/rules/KnownTypeNamesRule.mjs.map +1 -1
  990. package/validation/rules/LoneAnonymousOperationRule.d.mts +30 -2
  991. package/validation/rules/LoneAnonymousOperationRule.d.ts +30 -2
  992. package/validation/rules/LoneAnonymousOperationRule.js +4 -12
  993. package/validation/rules/LoneAnonymousOperationRule.js.map +1 -1
  994. package/validation/rules/LoneAnonymousOperationRule.mjs +0 -8
  995. package/validation/rules/LoneAnonymousOperationRule.mjs.map +1 -1
  996. package/validation/rules/LoneSchemaDefinitionRule.d.mts +23 -2
  997. package/validation/rules/LoneSchemaDefinitionRule.d.ts +23 -2
  998. package/validation/rules/LoneSchemaDefinitionRule.js +3 -8
  999. package/validation/rules/LoneSchemaDefinitionRule.js.map +1 -1
  1000. package/validation/rules/LoneSchemaDefinitionRule.mjs +0 -5
  1001. package/validation/rules/LoneSchemaDefinitionRule.mjs.map +1 -1
  1002. package/validation/rules/MaxIntrospectionDepthRule.d.mts +33 -2
  1003. package/validation/rules/MaxIntrospectionDepthRule.d.ts +33 -2
  1004. package/validation/rules/MaxIntrospectionDepthRule.js +5 -19
  1005. package/validation/rules/MaxIntrospectionDepthRule.js.map +1 -1
  1006. package/validation/rules/MaxIntrospectionDepthRule.mjs +0 -14
  1007. package/validation/rules/MaxIntrospectionDepthRule.mjs.map +1 -1
  1008. package/validation/rules/NoFragmentCyclesRule.d.mts +30 -2
  1009. package/validation/rules/NoFragmentCyclesRule.d.ts +30 -2
  1010. package/validation/rules/NoFragmentCyclesRule.js +2 -17
  1011. package/validation/rules/NoFragmentCyclesRule.js.map +1 -1
  1012. package/validation/rules/NoFragmentCyclesRule.mjs +0 -15
  1013. package/validation/rules/NoFragmentCyclesRule.mjs.map +1 -1
  1014. package/validation/rules/NoUndefinedVariablesRule.d.mts +30 -2
  1015. package/validation/rules/NoUndefinedVariablesRule.d.ts +30 -2
  1016. package/validation/rules/NoUndefinedVariablesRule.js +2 -10
  1017. package/validation/rules/NoUndefinedVariablesRule.js.map +1 -1
  1018. package/validation/rules/NoUndefinedVariablesRule.mjs +0 -8
  1019. package/validation/rules/NoUndefinedVariablesRule.mjs.map +1 -1
  1020. package/validation/rules/NoUnusedFragmentsRule.d.mts +30 -2
  1021. package/validation/rules/NoUnusedFragmentsRule.d.ts +30 -2
  1022. package/validation/rules/NoUnusedFragmentsRule.js +2 -10
  1023. package/validation/rules/NoUnusedFragmentsRule.js.map +1 -1
  1024. package/validation/rules/NoUnusedFragmentsRule.mjs +0 -8
  1025. package/validation/rules/NoUnusedFragmentsRule.mjs.map +1 -1
  1026. package/validation/rules/NoUnusedVariablesRule.d.mts +31 -2
  1027. package/validation/rules/NoUnusedVariablesRule.d.ts +31 -2
  1028. package/validation/rules/NoUnusedVariablesRule.js +3 -11
  1029. package/validation/rules/NoUnusedVariablesRule.js.map +1 -1
  1030. package/validation/rules/NoUnusedVariablesRule.mjs +0 -8
  1031. package/validation/rules/NoUnusedVariablesRule.mjs.map +1 -1
  1032. package/validation/rules/OverlappingFieldsCanBeMergedRule.d.mts +35 -2
  1033. package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +35 -2
  1034. package/validation/rules/OverlappingFieldsCanBeMergedRule.js +32 -206
  1035. package/validation/rules/OverlappingFieldsCanBeMergedRule.js.map +1 -1
  1036. package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +1 -175
  1037. package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs.map +1 -1
  1038. package/validation/rules/PossibleFragmentSpreadsRule.d.mts +38 -2
  1039. package/validation/rules/PossibleFragmentSpreadsRule.d.ts +38 -2
  1040. package/validation/rules/PossibleFragmentSpreadsRule.js +17 -24
  1041. package/validation/rules/PossibleFragmentSpreadsRule.js.map +1 -1
  1042. package/validation/rules/PossibleFragmentSpreadsRule.mjs +0 -7
  1043. package/validation/rules/PossibleFragmentSpreadsRule.mjs.map +1 -1
  1044. package/validation/rules/PossibleTypeExtensionsRule.d.mts +23 -2
  1045. package/validation/rules/PossibleTypeExtensionsRule.d.ts +23 -2
  1046. package/validation/rules/PossibleTypeExtensionsRule.js +38 -49
  1047. package/validation/rules/PossibleTypeExtensionsRule.js.map +1 -1
  1048. package/validation/rules/PossibleTypeExtensionsRule.mjs +0 -11
  1049. package/validation/rules/PossibleTypeExtensionsRule.mjs.map +1 -1
  1050. package/validation/rules/ProvidedRequiredArgumentsRule.d.mts +31 -5
  1051. package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +31 -5
  1052. package/validation/rules/ProvidedRequiredArgumentsRule.js +20 -33
  1053. package/validation/rules/ProvidedRequiredArgumentsRule.js.map +1 -1
  1054. package/validation/rules/ProvidedRequiredArgumentsRule.mjs +0 -13
  1055. package/validation/rules/ProvidedRequiredArgumentsRule.mjs.map +1 -1
  1056. package/validation/rules/ScalarLeafsRule.d.mts +30 -2
  1057. package/validation/rules/ScalarLeafsRule.d.ts +30 -2
  1058. package/validation/rules/ScalarLeafsRule.js +10 -16
  1059. package/validation/rules/ScalarLeafsRule.js.map +1 -1
  1060. package/validation/rules/ScalarLeafsRule.mjs +0 -6
  1061. package/validation/rules/ScalarLeafsRule.mjs.map +1 -1
  1062. package/validation/rules/SingleFieldSubscriptionsRule.d.mts +36 -4
  1063. package/validation/rules/SingleFieldSubscriptionsRule.d.ts +36 -4
  1064. package/validation/rules/SingleFieldSubscriptionsRule.js +8 -17
  1065. package/validation/rules/SingleFieldSubscriptionsRule.js.map +1 -1
  1066. package/validation/rules/SingleFieldSubscriptionsRule.mjs +0 -9
  1067. package/validation/rules/SingleFieldSubscriptionsRule.mjs.map +1 -1
  1068. package/validation/rules/StreamDirectiveOnListFieldRule.d.mts +23 -2
  1069. package/validation/rules/StreamDirectiveOnListFieldRule.d.ts +23 -2
  1070. package/validation/rules/StreamDirectiveOnListFieldRule.js +7 -12
  1071. package/validation/rules/StreamDirectiveOnListFieldRule.js.map +1 -1
  1072. package/validation/rules/StreamDirectiveOnListFieldRule.mjs +0 -5
  1073. package/validation/rules/StreamDirectiveOnListFieldRule.mjs.map +1 -1
  1074. package/validation/rules/UniqueArgumentDefinitionNamesRule.d.mts +23 -2
  1075. package/validation/rules/UniqueArgumentDefinitionNamesRule.d.ts +23 -2
  1076. package/validation/rules/UniqueArgumentDefinitionNamesRule.js +4 -10
  1077. package/validation/rules/UniqueArgumentDefinitionNamesRule.js.map +1 -1
  1078. package/validation/rules/UniqueArgumentDefinitionNamesRule.mjs +0 -6
  1079. package/validation/rules/UniqueArgumentDefinitionNamesRule.mjs.map +1 -1
  1080. package/validation/rules/UniqueArgumentNamesRule.d.mts +30 -2
  1081. package/validation/rules/UniqueArgumentNamesRule.d.ts +30 -2
  1082. package/validation/rules/UniqueArgumentNamesRule.js +4 -12
  1083. package/validation/rules/UniqueArgumentNamesRule.js.map +1 -1
  1084. package/validation/rules/UniqueArgumentNamesRule.mjs +0 -8
  1085. package/validation/rules/UniqueArgumentNamesRule.mjs.map +1 -1
  1086. package/validation/rules/UniqueDirectiveNamesRule.d.mts +23 -2
  1087. package/validation/rules/UniqueDirectiveNamesRule.d.ts +23 -2
  1088. package/validation/rules/UniqueDirectiveNamesRule.js +3 -8
  1089. package/validation/rules/UniqueDirectiveNamesRule.js.map +1 -1
  1090. package/validation/rules/UniqueDirectiveNamesRule.mjs +0 -5
  1091. package/validation/rules/UniqueDirectiveNamesRule.mjs.map +1 -1
  1092. package/validation/rules/UniqueDirectivesPerLocationRule.d.mts +30 -2
  1093. package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +30 -2
  1094. package/validation/rules/UniqueDirectivesPerLocationRule.js +20 -21
  1095. package/validation/rules/UniqueDirectivesPerLocationRule.js.map +1 -1
  1096. package/validation/rules/UniqueDirectivesPerLocationRule.mjs +10 -11
  1097. package/validation/rules/UniqueDirectivesPerLocationRule.mjs.map +1 -1
  1098. package/validation/rules/UniqueEnumValueNamesRule.d.mts +23 -2
  1099. package/validation/rules/UniqueEnumValueNamesRule.d.ts +23 -2
  1100. package/validation/rules/UniqueEnumValueNamesRule.js +5 -10
  1101. package/validation/rules/UniqueEnumValueNamesRule.js.map +1 -1
  1102. package/validation/rules/UniqueEnumValueNamesRule.mjs +0 -5
  1103. package/validation/rules/UniqueEnumValueNamesRule.mjs.map +1 -1
  1104. package/validation/rules/UniqueFieldDefinitionNamesRule.d.mts +23 -2
  1105. package/validation/rules/UniqueFieldDefinitionNamesRule.d.ts +23 -2
  1106. package/validation/rules/UniqueFieldDefinitionNamesRule.js +5 -10
  1107. package/validation/rules/UniqueFieldDefinitionNamesRule.js.map +1 -1
  1108. package/validation/rules/UniqueFieldDefinitionNamesRule.mjs +0 -5
  1109. package/validation/rules/UniqueFieldDefinitionNamesRule.mjs.map +1 -1
  1110. package/validation/rules/UniqueFragmentNamesRule.d.mts +30 -2
  1111. package/validation/rules/UniqueFragmentNamesRule.d.ts +30 -2
  1112. package/validation/rules/UniqueFragmentNamesRule.js +2 -9
  1113. package/validation/rules/UniqueFragmentNamesRule.js.map +1 -1
  1114. package/validation/rules/UniqueFragmentNamesRule.mjs +0 -7
  1115. package/validation/rules/UniqueFragmentNamesRule.mjs.map +1 -1
  1116. package/validation/rules/UniqueInputFieldNamesRule.d.mts +34 -2
  1117. package/validation/rules/UniqueInputFieldNamesRule.d.ts +34 -2
  1118. package/validation/rules/UniqueInputFieldNamesRule.js +4 -12
  1119. package/validation/rules/UniqueInputFieldNamesRule.js.map +1 -1
  1120. package/validation/rules/UniqueInputFieldNamesRule.mjs +0 -8
  1121. package/validation/rules/UniqueInputFieldNamesRule.mjs.map +1 -1
  1122. package/validation/rules/UniqueOperationNamesRule.d.mts +30 -2
  1123. package/validation/rules/UniqueOperationNamesRule.d.ts +30 -2
  1124. package/validation/rules/UniqueOperationNamesRule.js +2 -9
  1125. package/validation/rules/UniqueOperationNamesRule.js.map +1 -1
  1126. package/validation/rules/UniqueOperationNamesRule.mjs +0 -7
  1127. package/validation/rules/UniqueOperationNamesRule.mjs.map +1 -1
  1128. package/validation/rules/UniqueOperationTypesRule.d.mts +23 -2
  1129. package/validation/rules/UniqueOperationTypesRule.d.ts +23 -2
  1130. package/validation/rules/UniqueOperationTypesRule.js +3 -8
  1131. package/validation/rules/UniqueOperationTypesRule.js.map +1 -1
  1132. package/validation/rules/UniqueOperationTypesRule.mjs +0 -5
  1133. package/validation/rules/UniqueOperationTypesRule.mjs.map +1 -1
  1134. package/validation/rules/UniqueTypeNamesRule.d.mts +23 -2
  1135. package/validation/rules/UniqueTypeNamesRule.d.ts +23 -2
  1136. package/validation/rules/UniqueTypeNamesRule.js +3 -8
  1137. package/validation/rules/UniqueTypeNamesRule.js.map +1 -1
  1138. package/validation/rules/UniqueTypeNamesRule.mjs +0 -5
  1139. package/validation/rules/UniqueTypeNamesRule.mjs.map +1 -1
  1140. package/validation/rules/UniqueVariableNamesRule.d.mts +30 -2
  1141. package/validation/rules/UniqueVariableNamesRule.d.ts +30 -2
  1142. package/validation/rules/UniqueVariableNamesRule.js +4 -9
  1143. package/validation/rules/UniqueVariableNamesRule.js.map +1 -1
  1144. package/validation/rules/UniqueVariableNamesRule.mjs +0 -5
  1145. package/validation/rules/UniqueVariableNamesRule.mjs.map +1 -1
  1146. package/validation/rules/ValuesOfCorrectTypeRule.d.mts +30 -2
  1147. package/validation/rules/ValuesOfCorrectTypeRule.d.ts +30 -2
  1148. package/validation/rules/ValuesOfCorrectTypeRule.js +3 -23
  1149. package/validation/rules/ValuesOfCorrectTypeRule.js.map +1 -1
  1150. package/validation/rules/ValuesOfCorrectTypeRule.mjs +1 -21
  1151. package/validation/rules/ValuesOfCorrectTypeRule.mjs.map +1 -1
  1152. package/validation/rules/VariablesAreInputTypesRule.d.mts +34 -2
  1153. package/validation/rules/VariablesAreInputTypesRule.d.ts +34 -2
  1154. package/validation/rules/VariablesAreInputTypesRule.js +8 -16
  1155. package/validation/rules/VariablesAreInputTypesRule.js.map +1 -1
  1156. package/validation/rules/VariablesAreInputTypesRule.mjs +0 -8
  1157. package/validation/rules/VariablesAreInputTypesRule.mjs.map +1 -1
  1158. package/validation/rules/VariablesInAllowedPositionRule.d.mts +30 -2
  1159. package/validation/rules/VariablesInAllowedPositionRule.d.ts +30 -2
  1160. package/validation/rules/VariablesInAllowedPositionRule.js +14 -34
  1161. package/validation/rules/VariablesInAllowedPositionRule.js.map +1 -1
  1162. package/validation/rules/VariablesInAllowedPositionRule.mjs +0 -20
  1163. package/validation/rules/VariablesInAllowedPositionRule.mjs.map +1 -1
  1164. package/validation/rules/custom/NoDeprecatedCustomRule.d.mts +43 -2
  1165. package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +43 -2
  1166. package/validation/rules/custom/NoDeprecatedCustomRule.js +8 -18
  1167. package/validation/rules/custom/NoDeprecatedCustomRule.js.map +1 -1
  1168. package/validation/rules/custom/NoDeprecatedCustomRule.mjs +0 -10
  1169. package/validation/rules/custom/NoDeprecatedCustomRule.mjs.map +1 -1
  1170. package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.mts +30 -2
  1171. package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +30 -2
  1172. package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +6 -16
  1173. package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js.map +1 -1
  1174. package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +0 -10
  1175. package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs.map +1 -1
  1176. package/validation/specifiedRules.d.mts +3 -4
  1177. package/validation/specifiedRules.d.ts +3 -4
  1178. package/validation/specifiedRules.js +87 -133
  1179. package/validation/specifiedRules.js.map +1 -1
  1180. package/validation/specifiedRules.mjs +0 -46
  1181. package/validation/specifiedRules.mjs.map +1 -1
  1182. package/validation/validate.d.mts +70 -12
  1183. package/validation/validate.d.ts +70 -12
  1184. package/validation/validate.js +19 -60
  1185. package/validation/validate.js.map +1 -1
  1186. package/validation/validate.mjs +0 -41
  1187. package/validation/validate.mjs.map +1 -1
  1188. package/version.d.mts +3 -6
  1189. package/version.d.ts +3 -6
  1190. package/version.js +2 -10
  1191. package/version.js.map +1 -1
  1192. package/version.mjs +2 -10
  1193. package/version.mjs.map +1 -1
@@ -1,9 +1,7 @@
1
- import type { ASTNode } from './ast.js';
2
- import { Kind } from './kinds.js';
3
- /**
4
- * A visitor is provided to visit, it contains the collection of
5
- * relevant functions to be called during the visitor's traversal.
6
- */
1
+ /** @category Visiting */
2
+ import type { ASTNode } from "./ast.js";
3
+ import { Kind } from "./kinds.js";
4
+ /** A visitor defines the callbacks called during AST traversal. */
7
5
  export type ASTVisitor = EnterLeaveVisitor<ASTNode> | KindVisitor;
8
6
  type KindVisitor = {
9
7
  readonly [NodeT in ASTNode as NodeT['kind']]?: ASTVisitFn<NodeT> | EnterLeaveVisitor<NodeT>;
@@ -13,27 +11,28 @@ interface EnterLeaveVisitor<TVisitedNode extends ASTNode> {
13
11
  readonly leave?: ASTVisitFn<TVisitedNode> | undefined;
14
12
  }
15
13
  /**
16
- * A visitor is comprised of visit functions, which are called on each node
17
- * during the visitor's traversal.
14
+ * A visitor is composed of visit functions called for each node during traversal.
15
+ * @typeParam TVisitedNode - AST node type handled by this visitor function.
18
16
  */
19
17
  export type ASTVisitFn<TVisitedNode extends ASTNode> = (
20
- /** The current node being visiting. */
18
+ /** Current node being visited. */
21
19
  node: TVisitedNode,
22
- /** The index or key to this node from the parent node or Array. */
20
+ /** Index or key for this node within the parent node or array. */
23
21
  key: string | number | undefined,
24
- /** The parent immediately above this node, which may be an Array. */
22
+ /** Parent immediately above this node, which may be an array. */
25
23
  parent: ASTNode | ReadonlyArray<ASTNode> | undefined,
26
- /** The key path to get to this node from the root node. */
24
+ /** Key path from the root node to this node. */
27
25
  path: ReadonlyArray<string | number>,
28
26
  /**
29
- * All nodes and Arrays visited before reaching parent of this node.
27
+ * All nodes and arrays visited before reaching this node's parent.
30
28
  * These correspond to array indices in `path`.
31
- * Note: ancestors includes arrays which contain the parent of visited node.
29
+ * Note: ancestors includes arrays that contain the visited node's parent.
32
30
  */
33
31
  ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>) => any;
34
32
  /**
35
- * A reducer is comprised of reducer functions which convert AST nodes into
36
- * another form.
33
+ * A reducer is composed of reducer functions that convert AST nodes into another form.
34
+ *
35
+ * @internal
37
36
  */
38
37
  export type ASTReducer<R> = {
39
38
  readonly [NodeT in ASTNode as NodeT['kind']]?: {
@@ -42,29 +41,41 @@ export type ASTReducer<R> = {
42
41
  };
43
42
  };
44
43
  type ASTReducerFn<TReducedNode extends ASTNode, R> = (
45
- /** The current node being visiting. */
44
+ /**
45
+ * Current node being visited.
46
+ * @internal
47
+ */
46
48
  node: {
47
49
  [K in keyof TReducedNode]: ReducedField<TReducedNode[K], R>;
48
50
  },
49
- /** The index or key to this node from the parent node or Array. */
51
+ /**
52
+ * Index or key for this node within the parent node or array.
53
+ * @internal
54
+ */
50
55
  key: string | number | undefined,
51
- /** The parent immediately above this node, which may be an Array. */
56
+ /**
57
+ * Parent immediately above this node, which may be an array.
58
+ * @internal
59
+ */
52
60
  parent: ASTNode | ReadonlyArray<ASTNode> | undefined,
53
- /** The key path to get to this node from the root node. */
61
+ /**
62
+ * Key path from the root node to this node.
63
+ * @internal
64
+ */
54
65
  path: ReadonlyArray<string | number>,
55
66
  /**
56
- * All nodes and Arrays visited before reaching parent of this node.
67
+ * All nodes and arrays visited before reaching this node's parent.
57
68
  * These correspond to array indices in `path`.
58
- * Note: ancestors includes arrays which contain the parent of visited node.
69
+ * Note: ancestors includes arrays that contain the visited node's parent.
70
+ * @internal
59
71
  */
60
72
  ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>) => R;
61
73
  type ReducedField<T, R> = T extends ASTNode ? R : T extends ReadonlyArray<ASTNode> ? ReadonlyArray<R> : T;
62
- /**
63
- * A KeyMap describes each the traversable properties of each kind of node.
64
- */
74
+ /** A visitor key map describes the traversable child properties for each node kind. */
65
75
  export type ASTVisitorKeyMap = {
66
76
  [NodeT in ASTNode as NodeT['kind']]?: ReadonlyArray<keyof NodeT>;
67
77
  };
78
+ /** A value that can be returned from a visitor function to stop traversal. */
68
79
  export declare const BREAK: unknown;
69
80
  /**
70
81
  * visit() will walk through an AST using a depth-first traversal, calling
@@ -79,82 +90,181 @@ export declare const BREAK: unknown;
79
90
  * When using visit() to edit an AST, the original AST will not be modified, and
80
91
  * a new version of the AST with the changes applied will be returned from the
81
92
  * visit function.
82
- *
93
+ * @param root - The AST node at which to start traversal.
94
+ * @param visitor - The visitor or reducer functions to call while traversing.
95
+ * @param visitorKeys - Optional map of child keys to visit for each AST node kind.
96
+ * @returns The original AST, an edited AST, or a reduced value depending on the visitor.
97
+ * @typeParam N - The root AST node type returned when visiting without reducing.
98
+ * @example
83
99
  * ```ts
84
- * const editedAST = visit(ast, {
85
- * enter(node, key, parent, path, ancestors) {
86
- * // @return
87
- * // undefined: no action
88
- * // false: skip visiting this node
89
- * // visitor.BREAK: stop visiting altogether
90
- * // null: delete this node
91
- * // any value: replace this node with the returned value
100
+ * // Return values control traversal: undefined makes no change, false skips
101
+ * // a subtree, BREAK stops traversal, null removes a node, and any other
102
+ * // value replaces the current node.
103
+ * import { Kind, parse, print, visit } from 'graphql/language';
104
+ *
105
+ * const document = parse('{ hero { name } }');
106
+ * const editedAST = visit(document, {
107
+ * Field: (node) => {
108
+ * if (node.name.value === 'hero') {
109
+ * return {
110
+ * ...node,
111
+ * name: { kind: Kind.NAME, value: 'human' },
112
+ * };
113
+ * }
92
114
  * },
93
- * leave(node, key, parent, path, ancestors) {
94
- * // @return
95
- * // undefined: no action
96
- * // false: no action
97
- * // visitor.BREAK: stop visiting altogether
98
- * // null: delete this node
99
- * // any value: replace this node with the returned value
100
- * }
101
115
  * });
116
+ *
117
+ * print(editedAST); // => '{\n human {\n name\n }\n}'
102
118
  * ```
119
+ * @example
120
+ * ```ts
121
+ * // A named visitor function runs when entering nodes of that kind.
122
+ * import { parse, visit } from 'graphql/language';
103
123
  *
104
- * Alternatively to providing enter() and leave() functions, a visitor can
105
- * instead provide functions named the same as the kinds of AST nodes, or
106
- * enter/leave visitors at a named key, leading to three permutations of the
107
- * visitor API:
124
+ * const document = parse('{ hero { name } }');
125
+ * const fieldNames = [];
108
126
  *
109
- * 1) Named visitors triggered when entering a node of a specific kind.
127
+ * visit(document, {
128
+ * Field: (node) => {
129
+ * fieldNames.push(node.name.value);
130
+ * },
131
+ * });
110
132
  *
111
- * ```ts
112
- * visit(ast, {
113
- * Kind(node) {
114
- * // enter the "Kind" node
115
- * }
116
- * })
133
+ * fieldNames; // => ['hero', 'name']
117
134
  * ```
135
+ * @example
136
+ * ```ts
137
+ * // A named visitor object can provide separate enter and leave handlers for
138
+ * // nodes of that kind.
139
+ * import { parse, visit } from 'graphql/language';
118
140
  *
119
- * 2) Named visitors that trigger upon entering and leaving a node of a specific kind.
141
+ * const document = parse('{ hero { name } }');
142
+ * const events = [];
120
143
  *
121
- * ```ts
122
- * visit(ast, {
123
- * Kind: {
124
- * enter(node) {
125
- * // enter the "Kind" node
126
- * }
127
- * leave(node) {
128
- * // leave the "Kind" node
129
- * }
130
- * }
131
- * })
144
+ * visit(document, {
145
+ * Field: {
146
+ * enter: (node) => {
147
+ * events.push(`enter:${node.name.value}`);
148
+ * },
149
+ * leave: (node) => {
150
+ * events.push(`leave:${node.name.value}`);
151
+ * },
152
+ * },
153
+ * });
154
+ *
155
+ * events; // => ['enter:hero', 'enter:name', 'leave:name', 'leave:hero']
132
156
  * ```
157
+ * @example
158
+ * ```ts
159
+ * // Generic enter and leave handlers run for every node.
160
+ * import { parse, visit } from 'graphql/language';
133
161
  *
134
- * 3) Generic visitors that trigger upon entering and leaving any node.
162
+ * const document = parse('{ hero { name } }');
163
+ * let enterCount = 0;
164
+ * let leaveCount = 0;
135
165
  *
136
- * ```ts
137
- * visit(ast, {
138
- * enter(node) {
139
- * // enter any node
166
+ * visit(document, {
167
+ * enter: (node) => {
168
+ * enterCount += 1;
169
+ * },
170
+ * leave: (node) => {
171
+ * leaveCount += 1;
140
172
  * },
141
- * leave(node) {
142
- * // leave any node
143
- * }
144
- * })
173
+ * });
174
+ *
175
+ * enterCount; // => leaveCount
176
+ * enterCount > 0; // => true
145
177
  * ```
146
178
  */
147
179
  export declare function visit<N extends ASTNode>(root: N, visitor: ASTVisitor, visitorKeys?: ASTVisitorKeyMap): N;
180
+ /**
181
+ * Traverses an AST with reducer callbacks and returns the reduced value.
182
+ * @param root - The AST node where traversal starts.
183
+ * @param visitor - Reducer callbacks to invoke during traversal.
184
+ * @param visitorKeys - Optional mapping of child keys for each AST node kind.
185
+ * @returns The value produced by the reducer visitor.
186
+ * @typeParam R - The value produced by reducer visitor callbacks.
187
+ * @example
188
+ * ```ts
189
+ * // A reducer visitor returns values from leave handlers to build a reduced
190
+ * // result instead of returning an edited AST.
191
+ * import { parse, visit } from 'graphql/language';
192
+ *
193
+ * const document = parse('{ hero { name } }');
194
+ * const printed = visit(document, {
195
+ * Name: {
196
+ * leave: (node) => {
197
+ * return node.value;
198
+ * },
199
+ * },
200
+ * Field: {
201
+ * leave: (node) => {
202
+ * return node.selectionSet == null
203
+ * ? node.name
204
+ * : `${node.name} { ${node.selectionSet} }`;
205
+ * },
206
+ * },
207
+ * SelectionSet: {
208
+ * leave: (node) => {
209
+ * return node.selections.join(' ');
210
+ * },
211
+ * },
212
+ * OperationDefinition: {
213
+ * leave: (node) => {
214
+ * return node.selectionSet;
215
+ * },
216
+ * },
217
+ * Document: {
218
+ * leave: (node) => {
219
+ * return node.definitions.join('\n');
220
+ * },
221
+ * },
222
+ * });
223
+ *
224
+ * printed; // => 'hero { name }'
225
+ * ```
226
+ */
148
227
  export declare function visit<R>(root: ASTNode, visitor: ASTReducer<R>, visitorKeys?: ASTVisitorKeyMap): R;
149
228
  /**
150
229
  * Creates a new visitor instance which delegates to many visitors to run in
151
230
  * parallel. Each visitor will be visited for each node before moving on.
152
231
  *
153
232
  * If a prior visitor edits a node, no following visitors will see that node.
233
+ * @param visitors - The visitors to merge into one parallel visitor.
234
+ * @returns A visitor that delegates traversal to each provided visitor.
235
+ * @example
236
+ * ```ts
237
+ * import { parse, visit, visitInParallel } from 'graphql/language';
238
+ *
239
+ * const document = parse('{ hero { name } }');
240
+ * const events = [];
241
+ *
242
+ * visit(
243
+ * document,
244
+ * visitInParallel([
245
+ * { Field: (node) => { events.push(`field:${node.name.value}`); } },
246
+ * { Name: (node) => { events.push(`name:${node.value}`); } },
247
+ * ]),
248
+ * );
249
+ *
250
+ * events; // => ['field:hero', 'name:hero', 'field:name', 'name:name']
251
+ * ```
154
252
  */
155
253
  export declare function visitInParallel(visitors: ReadonlyArray<ASTVisitor>): ASTVisitor;
156
254
  /**
157
255
  * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind.
256
+ * @param visitor - The visitor object to inspect.
257
+ * @param kind - The AST node kind to resolve handlers for.
258
+ * @returns The enter and leave handlers that apply for the given node kind.
259
+ * @example
260
+ * ```ts
261
+ * import { Kind, getEnterLeaveForKind } from 'graphql/language';
262
+ *
263
+ * const handlers = getEnterLeaveForKind({ Field: () => {} }, Kind.FIELD);
264
+ *
265
+ * typeof handlers.enter; // => 'function'
266
+ * handlers.leave; // => undefined
267
+ * ```
158
268
  */
159
269
  export declare function getEnterLeaveForKind(visitor: ASTVisitor, kind: Kind): EnterLeaveVisitor<ASTNode>;
160
270
  export {};
@@ -4,17 +4,16 @@ exports.BREAK = void 0;
4
4
  exports.visit = visit;
5
5
  exports.visitInParallel = visitInParallel;
6
6
  exports.getEnterLeaveForKind = getEnterLeaveForKind;
7
- const devAssert_js_1 = require("../jsutils/devAssert.js");
8
- const inspect_js_1 = require("../jsutils/inspect.js");
9
- const ast_js_1 = require("./ast.js");
10
- const kinds_js_1 = require("./kinds.js");
7
+ const devAssert_ts_1 = require("../jsutils/devAssert.js");
8
+ const inspect_ts_1 = require("../jsutils/inspect.js");
9
+ const ast_ts_1 = require("./ast.js");
10
+ const kinds_ts_1 = require("./kinds.js");
11
11
  exports.BREAK = Object.freeze({});
12
- function visit(root, visitor, visitorKeys = ast_js_1.QueryDocumentKeys) {
12
+ function visit(root, visitor, visitorKeys = ast_ts_1.QueryDocumentKeys) {
13
13
  const enterLeaveMap = new Map();
14
- for (const kind of Object.values(kinds_js_1.Kind)) {
14
+ for (const kind of Object.values(kinds_ts_1.Kind)) {
15
15
  enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind));
16
16
  }
17
- /* eslint-disable no-undef-init */
18
17
  let stack = undefined;
19
18
  let inArray = Array.isArray(root);
20
19
  let keys = [root];
@@ -25,7 +24,6 @@ function visit(root, visitor, visitorKeys = ast_js_1.QueryDocumentKeys) {
25
24
  let parent = undefined;
26
25
  const path = [];
27
26
  const ancestors = [];
28
- /* eslint-enable no-undef-init */
29
27
  do {
30
28
  index++;
31
29
  const isLeaving = index === keys.length;
@@ -72,8 +70,8 @@ function visit(root, visitor, visitorKeys = ast_js_1.QueryDocumentKeys) {
72
70
  }
73
71
  let result;
74
72
  if (!Array.isArray(node)) {
75
- if (!((0, ast_js_1.isNode)(node)))
76
- (0, devAssert_js_1.devAssert)(false, `Invalid AST Node: ${(0, inspect_js_1.inspect)(node)}.`);
73
+ if (!((0, ast_ts_1.isNode)(node)))
74
+ (0, devAssert_ts_1.devAssert)(false, `Invalid AST Node: ${(0, inspect_ts_1.inspect)(node)}.`);
77
75
  const visitFn = isLeaving
78
76
  ? enterLeaveMap.get(node.kind)?.leave
79
77
  : enterLeaveMap.get(node.kind)?.enter;
@@ -90,7 +88,7 @@ function visit(root, visitor, visitorKeys = ast_js_1.QueryDocumentKeys) {
90
88
  else if (result !== undefined) {
91
89
  edits.push([key, result]);
92
90
  if (!isLeaving) {
93
- if ((0, ast_js_1.isNode)(result)) {
91
+ if ((0, ast_ts_1.isNode)(result)) {
94
92
  node = result;
95
93
  }
96
94
  else {
@@ -119,21 +117,14 @@ function visit(root, visitor, visitorKeys = ast_js_1.QueryDocumentKeys) {
119
117
  }
120
118
  } while (stack !== undefined);
121
119
  if (edits.length !== 0) {
122
- // New root
123
120
  return edits.at(-1)[1];
124
121
  }
125
122
  return root;
126
123
  }
127
- /**
128
- * Creates a new visitor instance which delegates to many visitors to run in
129
- * parallel. Each visitor will be visited for each node before moving on.
130
- *
131
- * If a prior visitor edits a node, no following visitors will see that node.
132
- */
133
124
  function visitInParallel(visitors) {
134
125
  const skipping = new Array(visitors.length).fill(null);
135
126
  const mergedVisitor = Object.create(null);
136
- for (const kind of Object.values(kinds_js_1.Kind)) {
127
+ for (const kind of Object.values(kinds_ts_1.Kind)) {
137
128
  let hasVisitor = false;
138
129
  const enterList = new Array(visitors.length).fill(undefined);
139
130
  const leaveList = new Array(visitors.length).fill(undefined);
@@ -186,20 +177,14 @@ function visitInParallel(visitors) {
186
177
  }
187
178
  return mergedVisitor;
188
179
  }
189
- /**
190
- * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind.
191
- */
192
180
  function getEnterLeaveForKind(visitor, kind) {
193
181
  const kindVisitor = visitor[kind];
194
182
  if (typeof kindVisitor === 'object') {
195
- // { Kind: { enter() {}, leave() {} } }
196
183
  return kindVisitor;
197
184
  }
198
185
  else if (typeof kindVisitor === 'function') {
199
- // { Kind() {} }
200
186
  return { enter: kindVisitor, leave: undefined };
201
187
  }
202
- // { enter() {}, leave() {} }
203
188
  return { enter: visitor.enter, leave: visitor.leave };
204
189
  }
205
190
  //# sourceMappingURL=visitor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"visitor.js","sourceRoot":"","sources":["../../src/language/visitor.ts"],"names":[],"mappings":";;;AAgLA,sBA2HC;AAQD,0CA2DC;AAKD,oDAmBC;AAtYD,0DAAoD;AACpD,sDAAgD;AAGhD,qCAAqD;AACrD,yCAAkC;AAiFr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AAU,EAAE,CAAC;QAC7C,gBAAgB;QAChB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAClD,CAAC;IAED,6BAA6B;IAC7B,OAAO,EAAE,KAAK,EAAG,OAAe,CAAC,KAAK,EAAE,KAAK,EAAG,OAAe,CAAC,KAAK,EAAE,CAAC;AAC1E,CAAC","sourcesContent":["import { devAssert } from '../jsutils/devAssert.js';\nimport { inspect } from '../jsutils/inspect.js';\n\nimport type { ASTNode } from './ast.js';\nimport { isNode, QueryDocumentKeys } from './ast.js';\nimport { Kind } from './kinds.js';\n\n/**\n * A visitor is provided to visit, it contains the collection of\n * relevant functions to be called during the visitor's traversal.\n */\nexport type ASTVisitor = EnterLeaveVisitor<ASTNode> | KindVisitor;\n\ntype KindVisitor = {\n readonly [NodeT in ASTNode as NodeT['kind']]?:\n | ASTVisitFn<NodeT>\n | EnterLeaveVisitor<NodeT>;\n};\n\ninterface EnterLeaveVisitor<TVisitedNode extends ASTNode> {\n readonly enter?: ASTVisitFn<TVisitedNode> | undefined;\n readonly leave?: ASTVisitFn<TVisitedNode> | undefined;\n}\n\n/**\n * A visitor is comprised of visit functions, which are called on each node\n * during the visitor's traversal.\n */\nexport type ASTVisitFn<TVisitedNode extends ASTNode> = (\n /** The current node being visiting. */\n node: TVisitedNode,\n /** The index or key to this node from the parent node or Array. */\n key: string | number | undefined,\n /** The parent immediately above this node, which may be an Array. */\n parent: ASTNode | ReadonlyArray<ASTNode> | undefined,\n /** The key path to get to this node from the root node. */\n path: ReadonlyArray<string | number>,\n /**\n * All nodes and Arrays visited before reaching parent of this node.\n * These correspond to array indices in `path`.\n * Note: ancestors includes arrays which contain the parent of visited node.\n */\n ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>,\n) => any;\n\n/**\n * A reducer is comprised of reducer functions which convert AST nodes into\n * another form.\n */\nexport type ASTReducer<R> = {\n readonly [NodeT in ASTNode as NodeT['kind']]?: {\n readonly enter?: ASTVisitFn<NodeT>;\n readonly leave: ASTReducerFn<NodeT, R>;\n };\n};\n\ntype ASTReducerFn<TReducedNode extends ASTNode, R> = (\n /** The current node being visiting. */\n node: { [K in keyof TReducedNode]: ReducedField<TReducedNode[K], R> },\n /** The index or key to this node from the parent node or Array. */\n key: string | number | undefined,\n /** The parent immediately above this node, which may be an Array. */\n parent: ASTNode | ReadonlyArray<ASTNode> | undefined,\n /** The key path to get to this node from the root node. */\n path: ReadonlyArray<string | number>,\n /**\n * All nodes and Arrays visited before reaching parent of this node.\n * These correspond to array indices in `path`.\n * Note: ancestors includes arrays which contain the parent of visited node.\n */\n ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>,\n) => R;\n\ntype ReducedField<T, R> = T extends ASTNode\n ? R\n : T extends ReadonlyArray<ASTNode>\n ? ReadonlyArray<R>\n : T;\n\n/**\n * A KeyMap describes each the traversable properties of each kind of node.\n */\nexport type ASTVisitorKeyMap = {\n [NodeT in ASTNode as NodeT['kind']]?: ReadonlyArray<keyof NodeT>;\n};\n\nexport const BREAK: unknown = Object.freeze({});\n\n/**\n * visit() will walk through an AST using a depth-first traversal, calling\n * the visitor's enter function at each node in the traversal, and calling the\n * leave function after visiting that node and all of its child nodes.\n *\n * By returning different values from the enter and leave functions, the\n * behavior of the visitor can be altered, including skipping over a sub-tree of\n * the AST (by returning false), editing the AST by returning a value or null\n * to remove the value, or to stop the whole traversal by returning BREAK.\n *\n * When using visit() to edit an AST, the original AST will not be modified, and\n * a new version of the AST with the changes applied will be returned from the\n * visit function.\n *\n * ```ts\n * const editedAST = visit(ast, {\n * enter(node, key, parent, path, ancestors) {\n * // @return\n * // undefined: no action\n * // false: skip visiting this node\n * // visitor.BREAK: stop visiting altogether\n * // null: delete this node\n * // any value: replace this node with the returned value\n * },\n * leave(node, key, parent, path, ancestors) {\n * // @return\n * // undefined: no action\n * // false: no action\n * // visitor.BREAK: stop visiting altogether\n * // null: delete this node\n * // any value: replace this node with the returned value\n * }\n * });\n * ```\n *\n * Alternatively to providing enter() and leave() functions, a visitor can\n * instead provide functions named the same as the kinds of AST nodes, or\n * enter/leave visitors at a named key, leading to three permutations of the\n * visitor API:\n *\n * 1) Named visitors triggered when entering a node of a specific kind.\n *\n * ```ts\n * visit(ast, {\n * Kind(node) {\n * // enter the \"Kind\" node\n * }\n * })\n * ```\n *\n * 2) Named visitors that trigger upon entering and leaving a node of a specific kind.\n *\n * ```ts\n * visit(ast, {\n * Kind: {\n * enter(node) {\n * // enter the \"Kind\" node\n * }\n * leave(node) {\n * // leave the \"Kind\" node\n * }\n * }\n * })\n * ```\n *\n * 3) Generic visitors that trigger upon entering and leaving any node.\n *\n * ```ts\n * visit(ast, {\n * enter(node) {\n * // enter any node\n * },\n * leave(node) {\n * // leave any node\n * }\n * })\n * ```\n */\nexport function visit<N extends ASTNode>(\n root: N,\n visitor: ASTVisitor,\n visitorKeys?: ASTVisitorKeyMap,\n): N;\nexport function visit<R>(\n root: ASTNode,\n visitor: ASTReducer<R>,\n visitorKeys?: ASTVisitorKeyMap,\n): R;\nexport function visit(\n root: ASTNode,\n visitor: ASTVisitor | ASTReducer<any>,\n visitorKeys: ASTVisitorKeyMap = QueryDocumentKeys,\n): any {\n const enterLeaveMap = new Map<Kind, EnterLeaveVisitor<ASTNode>>();\n for (const kind of Object.values(Kind)) {\n enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind));\n }\n\n /* eslint-disable no-undef-init */\n let stack: any = undefined;\n let inArray = Array.isArray(root);\n let keys: any = [root];\n let index = -1;\n let edits = [];\n let node: any = root;\n let key: any = undefined;\n let parent: any = undefined;\n const path: any = [];\n const ancestors = [];\n /* eslint-enable no-undef-init */\n\n do {\n index++;\n const isLeaving = index === keys.length;\n const isEdited = isLeaving && edits.length !== 0;\n if (isLeaving) {\n key = ancestors.length === 0 ? undefined : path[path.length - 1];\n node = parent;\n parent = ancestors.pop();\n if (isEdited) {\n if (inArray) {\n node = node.slice();\n\n let editOffset = 0;\n for (const [editKey, editValue] of edits) {\n const arrayKey = editKey - editOffset;\n if (editValue === null) {\n node.splice(arrayKey, 1);\n editOffset++;\n } else {\n node[arrayKey] = editValue;\n }\n }\n } else {\n node = { ...node };\n for (const [editKey, editValue] of edits) {\n node[editKey] = editValue;\n }\n }\n }\n index = stack.index;\n keys = stack.keys;\n edits = stack.edits;\n inArray = stack.inArray;\n stack = stack.prev;\n } else if (parent != null) {\n key = inArray ? index : keys[index];\n node = parent[key];\n if (node === null || node === undefined) {\n continue;\n }\n path.push(key);\n }\n\n let result;\n if (!Array.isArray(node)) {\n devAssert(isNode(node), `Invalid AST Node: ${inspect(node)}.`);\n\n const visitFn = isLeaving\n ? enterLeaveMap.get(node.kind)?.leave\n : enterLeaveMap.get(node.kind)?.enter;\n\n result = visitFn?.call(visitor, node, key, parent, path, ancestors);\n\n if (result === BREAK) {\n break;\n }\n\n if (result === false) {\n if (!isLeaving) {\n path.pop();\n continue;\n }\n } else if (result !== undefined) {\n edits.push([key, result]);\n if (!isLeaving) {\n if (isNode(result)) {\n node = result;\n } else {\n path.pop();\n continue;\n }\n }\n }\n }\n\n if (result === undefined && isEdited) {\n edits.push([key, node]);\n }\n\n if (isLeaving) {\n path.pop();\n } else {\n stack = { inArray, index, keys, edits, prev: stack };\n inArray = Array.isArray(node);\n keys = inArray ? node : ((visitorKeys as any)[node.kind] ?? []);\n index = -1;\n edits = [];\n if (parent != null) {\n ancestors.push(parent);\n }\n parent = node;\n }\n } while (stack !== undefined);\n\n if (edits.length !== 0) {\n // New root\n return edits.at(-1)[1];\n }\n\n return root;\n}\n\n/**\n * Creates a new visitor instance which delegates to many visitors to run in\n * parallel. Each visitor will be visited for each node before moving on.\n *\n * If a prior visitor edits a node, no following visitors will see that node.\n */\nexport function visitInParallel(\n visitors: ReadonlyArray<ASTVisitor>,\n): ASTVisitor {\n const skipping = new Array(visitors.length).fill(null);\n const mergedVisitor = Object.create(null);\n\n for (const kind of Object.values(Kind)) {\n let hasVisitor = false;\n const enterList = new Array(visitors.length).fill(undefined);\n const leaveList = new Array(visitors.length).fill(undefined);\n\n for (let i = 0; i < visitors.length; ++i) {\n const { enter, leave } = getEnterLeaveForKind(visitors[i], kind);\n hasVisitor ||= enter != null || leave != null;\n enterList[i] = enter;\n leaveList[i] = leave;\n }\n\n if (!hasVisitor) {\n continue;\n }\n\n const mergedEnterLeave: EnterLeaveVisitor<ASTNode> = {\n enter(...args) {\n const node = args[0];\n for (let i = 0; i < visitors.length; i++) {\n if (skipping[i] === null) {\n const result = enterList[i]?.apply(visitors[i], args);\n if (result === false) {\n skipping[i] = node;\n } else if (result === BREAK) {\n skipping[i] = BREAK;\n } else if (result !== undefined) {\n return result;\n }\n }\n }\n },\n leave(...args) {\n const node = args[0];\n for (let i = 0; i < visitors.length; i++) {\n if (skipping[i] === null) {\n const result = leaveList[i]?.apply(visitors[i], args);\n if (result === BREAK) {\n skipping[i] = BREAK;\n } else if (result !== undefined && result !== false) {\n return result;\n }\n } else if (skipping[i] === node) {\n skipping[i] = null;\n }\n }\n },\n };\n\n mergedVisitor[kind] = mergedEnterLeave;\n }\n\n return mergedVisitor;\n}\n\n/**\n * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind.\n */\nexport function getEnterLeaveForKind(\n visitor: ASTVisitor,\n kind: Kind,\n): EnterLeaveVisitor<ASTNode> {\n const kindVisitor:\n | ASTVisitFn<ASTNode>\n | EnterLeaveVisitor<ASTNode>\n | undefined = (visitor as any)[kind];\n\n if (typeof kindVisitor === 'object') {\n // { Kind: { enter() {}, leave() {} } }\n return kindVisitor;\n } else if (typeof kindVisitor === 'function') {\n // { Kind() {} }\n return { enter: kindVisitor, leave: undefined };\n }\n\n // { enter() {}, leave() {} }\n return { enter: (visitor as any).enter, leave: (visitor as any).leave };\n}\n"]}
1
+ {"version":3,"file":"visitor.js","sourceRoot":"","sources":["../../src/language/visitor.ts"],"names":[],"mappings":";;;AAoQA,sBA2HC;AA2BD,0CA2DC;AAiBD,oDAmBC;AAvfD,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C;QAE7C,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAClD,CAAC;IAGD,OAAO,EAAE,KAAK,EAAG,OAAe,CAAC,KAAK,EAAE,KAAK,EAAG,OAAe,CAAC,KAAK,EAAE,CAAC;AAC1E,CAAC","sourcesContent":["/** @category Visiting */\n\nimport { devAssert } from '../jsutils/devAssert.ts';\nimport { inspect } from '../jsutils/inspect.ts';\n\nimport type { ASTNode } from './ast.ts';\nimport { isNode, QueryDocumentKeys } from './ast.ts';\nimport { Kind } from './kinds.ts';\n\n/** A visitor defines the callbacks called during AST traversal. */\nexport type ASTVisitor = EnterLeaveVisitor<ASTNode> | KindVisitor;\n\ntype KindVisitor = {\n readonly [NodeT in ASTNode as NodeT['kind']]?:\n | ASTVisitFn<NodeT>\n | EnterLeaveVisitor<NodeT>;\n};\n\ninterface EnterLeaveVisitor<TVisitedNode extends ASTNode> {\n readonly enter?: ASTVisitFn<TVisitedNode> | undefined;\n readonly leave?: ASTVisitFn<TVisitedNode> | undefined;\n}\n\n/**\n * A visitor is composed of visit functions called for each node during traversal.\n * @typeParam TVisitedNode - AST node type handled by this visitor function.\n */\nexport type ASTVisitFn<TVisitedNode extends ASTNode> = (\n /** Current node being visited. */\n node: TVisitedNode,\n /** Index or key for this node within the parent node or array. */\n key: string | number | undefined,\n /** Parent immediately above this node, which may be an array. */\n parent: ASTNode | ReadonlyArray<ASTNode> | undefined,\n /** Key path from the root node to this node. */\n path: ReadonlyArray<string | number>,\n /**\n * All nodes and arrays visited before reaching this node's parent.\n * These correspond to array indices in `path`.\n * Note: ancestors includes arrays that contain the visited node's parent.\n */\n ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>,\n) => any;\n\n/**\n * A reducer is composed of reducer functions that convert AST nodes into another form.\n *\n * @internal\n */\nexport type ASTReducer<R> = {\n readonly [NodeT in ASTNode as NodeT['kind']]?: {\n readonly enter?: ASTVisitFn<NodeT>;\n readonly leave: ASTReducerFn<NodeT, R>;\n };\n};\n\ntype ASTReducerFn<TReducedNode extends ASTNode, R> = (\n /**\n * Current node being visited.\n * @internal\n */\n node: { [K in keyof TReducedNode]: ReducedField<TReducedNode[K], R> },\n /**\n * Index or key for this node within the parent node or array.\n * @internal\n */\n key: string | number | undefined,\n /**\n * Parent immediately above this node, which may be an array.\n * @internal\n */\n parent: ASTNode | ReadonlyArray<ASTNode> | undefined,\n /**\n * Key path from the root node to this node.\n * @internal\n */\n path: ReadonlyArray<string | number>,\n /**\n * All nodes and arrays visited before reaching this node's parent.\n * These correspond to array indices in `path`.\n * Note: ancestors includes arrays that contain the visited node's parent.\n * @internal\n */\n ancestors: ReadonlyArray<ASTNode | ReadonlyArray<ASTNode>>,\n) => R;\n\ntype ReducedField<T, R> = T extends ASTNode\n ? R\n : T extends ReadonlyArray<ASTNode>\n ? ReadonlyArray<R>\n : T;\n\n/** A visitor key map describes the traversable child properties for each node kind. */\nexport type ASTVisitorKeyMap = {\n [NodeT in ASTNode as NodeT['kind']]?: ReadonlyArray<keyof NodeT>;\n};\n\n/** A value that can be returned from a visitor function to stop traversal. */\nexport const BREAK: unknown = Object.freeze({});\n\n/**\n * visit() will walk through an AST using a depth-first traversal, calling\n * the visitor's enter function at each node in the traversal, and calling the\n * leave function after visiting that node and all of its child nodes.\n *\n * By returning different values from the enter and leave functions, the\n * behavior of the visitor can be altered, including skipping over a sub-tree of\n * the AST (by returning false), editing the AST by returning a value or null\n * to remove the value, or to stop the whole traversal by returning BREAK.\n *\n * When using visit() to edit an AST, the original AST will not be modified, and\n * a new version of the AST with the changes applied will be returned from the\n * visit function.\n * @param root - The AST node at which to start traversal.\n * @param visitor - The visitor or reducer functions to call while traversing.\n * @param visitorKeys - Optional map of child keys to visit for each AST node kind.\n * @returns The original AST, an edited AST, or a reduced value depending on the visitor.\n * @typeParam N - The root AST node type returned when visiting without reducing.\n * @example\n * ```ts\n * // Return values control traversal: undefined makes no change, false skips\n * // a subtree, BREAK stops traversal, null removes a node, and any other\n * // value replaces the current node.\n * import { Kind, parse, print, visit } from 'graphql/language';\n *\n * const document = parse('{ hero { name } }');\n * const editedAST = visit(document, {\n * Field: (node) => {\n * if (node.name.value === 'hero') {\n * return {\n * ...node,\n * name: { kind: Kind.NAME, value: 'human' },\n * };\n * }\n * },\n * });\n *\n * print(editedAST); // => '{\\n human {\\n name\\n }\\n}'\n * ```\n * @example\n * ```ts\n * // A named visitor function runs when entering nodes of that kind.\n * import { parse, visit } from 'graphql/language';\n *\n * const document = parse('{ hero { name } }');\n * const fieldNames = [];\n *\n * visit(document, {\n * Field: (node) => {\n * fieldNames.push(node.name.value);\n * },\n * });\n *\n * fieldNames; // => ['hero', 'name']\n * ```\n * @example\n * ```ts\n * // A named visitor object can provide separate enter and leave handlers for\n * // nodes of that kind.\n * import { parse, visit } from 'graphql/language';\n *\n * const document = parse('{ hero { name } }');\n * const events = [];\n *\n * visit(document, {\n * Field: {\n * enter: (node) => {\n * events.push(`enter:${node.name.value}`);\n * },\n * leave: (node) => {\n * events.push(`leave:${node.name.value}`);\n * },\n * },\n * });\n *\n * events; // => ['enter:hero', 'enter:name', 'leave:name', 'leave:hero']\n * ```\n * @example\n * ```ts\n * // Generic enter and leave handlers run for every node.\n * import { parse, visit } from 'graphql/language';\n *\n * const document = parse('{ hero { name } }');\n * let enterCount = 0;\n * let leaveCount = 0;\n *\n * visit(document, {\n * enter: (node) => {\n * enterCount += 1;\n * },\n * leave: (node) => {\n * leaveCount += 1;\n * },\n * });\n *\n * enterCount; // => leaveCount\n * enterCount > 0; // => true\n * ```\n */\nexport function visit<N extends ASTNode>(\n root: N,\n visitor: ASTVisitor,\n visitorKeys?: ASTVisitorKeyMap,\n): N;\n/**\n * Traverses an AST with reducer callbacks and returns the reduced value.\n * @param root - The AST node where traversal starts.\n * @param visitor - Reducer callbacks to invoke during traversal.\n * @param visitorKeys - Optional mapping of child keys for each AST node kind.\n * @returns The value produced by the reducer visitor.\n * @typeParam R - The value produced by reducer visitor callbacks.\n * @example\n * ```ts\n * // A reducer visitor returns values from leave handlers to build a reduced\n * // result instead of returning an edited AST.\n * import { parse, visit } from 'graphql/language';\n *\n * const document = parse('{ hero { name } }');\n * const printed = visit(document, {\n * Name: {\n * leave: (node) => {\n * return node.value;\n * },\n * },\n * Field: {\n * leave: (node) => {\n * return node.selectionSet == null\n * ? node.name\n * : `${node.name} { ${node.selectionSet} }`;\n * },\n * },\n * SelectionSet: {\n * leave: (node) => {\n * return node.selections.join(' ');\n * },\n * },\n * OperationDefinition: {\n * leave: (node) => {\n * return node.selectionSet;\n * },\n * },\n * Document: {\n * leave: (node) => {\n * return node.definitions.join('\\n');\n * },\n * },\n * });\n *\n * printed; // => 'hero { name }'\n * ```\n */\nexport function visit<R>(\n root: ASTNode,\n visitor: ASTReducer<R>,\n visitorKeys?: ASTVisitorKeyMap,\n): R;\n/**\n * Traverses an AST with visitor or reducer callbacks.\n * @internal\n */\nexport function visit(\n root: ASTNode,\n visitor: ASTVisitor | ASTReducer<any>,\n visitorKeys: ASTVisitorKeyMap = QueryDocumentKeys,\n): any {\n const enterLeaveMap = new Map<Kind, EnterLeaveVisitor<ASTNode>>();\n for (const kind of Object.values(Kind)) {\n enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind));\n }\n\n /* eslint-disable no-undef-init */\n let stack: any = undefined;\n let inArray = Array.isArray(root);\n let keys: any = [root];\n let index = -1;\n let edits = [];\n let node: any = root;\n let key: any = undefined;\n let parent: any = undefined;\n const path: any = [];\n const ancestors = [];\n /* eslint-enable no-undef-init */\n\n do {\n index++;\n const isLeaving = index === keys.length;\n const isEdited = isLeaving && edits.length !== 0;\n if (isLeaving) {\n key = ancestors.length === 0 ? undefined : path[path.length - 1];\n node = parent;\n parent = ancestors.pop();\n if (isEdited) {\n if (inArray) {\n node = node.slice();\n\n let editOffset = 0;\n for (const [editKey, editValue] of edits) {\n const arrayKey = editKey - editOffset;\n if (editValue === null) {\n node.splice(arrayKey, 1);\n editOffset++;\n } else {\n node[arrayKey] = editValue;\n }\n }\n } else {\n node = { ...node };\n for (const [editKey, editValue] of edits) {\n node[editKey] = editValue;\n }\n }\n }\n index = stack.index;\n keys = stack.keys;\n edits = stack.edits;\n inArray = stack.inArray;\n stack = stack.prev;\n } else if (parent != null) {\n key = inArray ? index : keys[index];\n node = parent[key];\n if (node === null || node === undefined) {\n continue;\n }\n path.push(key);\n }\n\n let result;\n if (!Array.isArray(node)) {\n devAssert(isNode(node), `Invalid AST Node: ${inspect(node)}.`);\n\n const visitFn = isLeaving\n ? enterLeaveMap.get(node.kind)?.leave\n : enterLeaveMap.get(node.kind)?.enter;\n\n result = visitFn?.call(visitor, node, key, parent, path, ancestors);\n\n if (result === BREAK) {\n break;\n }\n\n if (result === false) {\n if (!isLeaving) {\n path.pop();\n continue;\n }\n } else if (result !== undefined) {\n edits.push([key, result]);\n if (!isLeaving) {\n if (isNode(result)) {\n node = result;\n } else {\n path.pop();\n continue;\n }\n }\n }\n }\n\n if (result === undefined && isEdited) {\n edits.push([key, node]);\n }\n\n if (isLeaving) {\n path.pop();\n } else {\n stack = { inArray, index, keys, edits, prev: stack };\n inArray = Array.isArray(node);\n keys = inArray ? node : ((visitorKeys as any)[node.kind] ?? []);\n index = -1;\n edits = [];\n if (parent != null) {\n ancestors.push(parent);\n }\n parent = node;\n }\n } while (stack !== undefined);\n\n if (edits.length !== 0) {\n // New root\n return edits.at(-1)[1];\n }\n\n return root;\n}\n\n/**\n * Creates a new visitor instance which delegates to many visitors to run in\n * parallel. Each visitor will be visited for each node before moving on.\n *\n * If a prior visitor edits a node, no following visitors will see that node.\n * @param visitors - The visitors to merge into one parallel visitor.\n * @returns A visitor that delegates traversal to each provided visitor.\n * @example\n * ```ts\n * import { parse, visit, visitInParallel } from 'graphql/language';\n *\n * const document = parse('{ hero { name } }');\n * const events = [];\n *\n * visit(\n * document,\n * visitInParallel([\n * { Field: (node) => { events.push(`field:${node.name.value}`); } },\n * { Name: (node) => { events.push(`name:${node.value}`); } },\n * ]),\n * );\n *\n * events; // => ['field:hero', 'name:hero', 'field:name', 'name:name']\n * ```\n */\nexport function visitInParallel(\n visitors: ReadonlyArray<ASTVisitor>,\n): ASTVisitor {\n const skipping = new Array(visitors.length).fill(null);\n const mergedVisitor = Object.create(null);\n\n for (const kind of Object.values(Kind)) {\n let hasVisitor = false;\n const enterList = new Array(visitors.length).fill(undefined);\n const leaveList = new Array(visitors.length).fill(undefined);\n\n for (let i = 0; i < visitors.length; ++i) {\n const { enter, leave } = getEnterLeaveForKind(visitors[i], kind);\n hasVisitor ||= enter != null || leave != null;\n enterList[i] = enter;\n leaveList[i] = leave;\n }\n\n if (!hasVisitor) {\n continue;\n }\n\n const mergedEnterLeave: EnterLeaveVisitor<ASTNode> = {\n enter(...args) {\n const node = args[0];\n for (let i = 0; i < visitors.length; i++) {\n if (skipping[i] === null) {\n const result = enterList[i]?.apply(visitors[i], args);\n if (result === false) {\n skipping[i] = node;\n } else if (result === BREAK) {\n skipping[i] = BREAK;\n } else if (result !== undefined) {\n return result;\n }\n }\n }\n },\n leave(...args) {\n const node = args[0];\n for (let i = 0; i < visitors.length; i++) {\n if (skipping[i] === null) {\n const result = leaveList[i]?.apply(visitors[i], args);\n if (result === BREAK) {\n skipping[i] = BREAK;\n } else if (result !== undefined && result !== false) {\n return result;\n }\n } else if (skipping[i] === node) {\n skipping[i] = null;\n }\n }\n },\n };\n\n mergedVisitor[kind] = mergedEnterLeave;\n }\n\n return mergedVisitor;\n}\n\n/**\n * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind.\n * @param visitor - The visitor object to inspect.\n * @param kind - The AST node kind to resolve handlers for.\n * @returns The enter and leave handlers that apply for the given node kind.\n * @example\n * ```ts\n * import { Kind, getEnterLeaveForKind } from 'graphql/language';\n *\n * const handlers = getEnterLeaveForKind({ Field: () => {} }, Kind.FIELD);\n *\n * typeof handlers.enter; // => 'function'\n * handlers.leave; // => undefined\n * ```\n */\nexport function getEnterLeaveForKind(\n visitor: ASTVisitor,\n kind: Kind,\n): EnterLeaveVisitor<ASTNode> {\n const kindVisitor:\n | ASTVisitFn<ASTNode>\n | EnterLeaveVisitor<ASTNode>\n | undefined = (visitor as any)[kind];\n\n if (typeof kindVisitor === 'object') {\n // { Kind: { enter() {}, leave() {} } }\n return kindVisitor;\n } else if (typeof kindVisitor === 'function') {\n // { Kind() {} }\n return { enter: kindVisitor, leave: undefined };\n }\n\n // { enter() {}, leave() {} }\n return { enter: (visitor as any).enter, leave: (visitor as any).leave };\n}\n"]}
@@ -8,7 +8,6 @@ export function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
8
8
  for (const kind of Object.values(Kind)) {
9
9
  enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind));
10
10
  }
11
- /* eslint-disable no-undef-init */
12
11
  let stack = undefined;
13
12
  let inArray = Array.isArray(root);
14
13
  let keys = [root];
@@ -19,7 +18,6 @@ export function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
19
18
  let parent = undefined;
20
19
  const path = [];
21
20
  const ancestors = [];
22
- /* eslint-enable no-undef-init */
23
21
  do {
24
22
  index++;
25
23
  const isLeaving = index === keys.length;
@@ -113,17 +111,10 @@ export function visit(root, visitor, visitorKeys = QueryDocumentKeys) {
113
111
  }
114
112
  } while (stack !== undefined);
115
113
  if (edits.length !== 0) {
116
- // New root
117
114
  return edits.at(-1)[1];
118
115
  }
119
116
  return root;
120
117
  }
121
- /**
122
- * Creates a new visitor instance which delegates to many visitors to run in
123
- * parallel. Each visitor will be visited for each node before moving on.
124
- *
125
- * If a prior visitor edits a node, no following visitors will see that node.
126
- */
127
118
  export function visitInParallel(visitors) {
128
119
  const skipping = new Array(visitors.length).fill(null);
129
120
  const mergedVisitor = Object.create(null);
@@ -180,20 +171,14 @@ export function visitInParallel(visitors) {
180
171
  }
181
172
  return mergedVisitor;
182
173
  }
183
- /**
184
- * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind.
185
- */
186
174
  export function getEnterLeaveForKind(visitor, kind) {
187
175
  const kindVisitor = visitor[kind];
188
176
  if (typeof kindVisitor === 'object') {
189
- // { Kind: { enter() {}, leave() {} } }
190
177
  return kindVisitor;
191
178
  }
192
179
  else if (typeof kindVisitor === 'function') {
193
- // { Kind() {} }
194
180
  return { enter: kindVisitor, leave: undefined };
195
181
  }
196
- // { enter() {}, leave() {} }
197
182
  return { enter: visitor.enter, leave: visitor.leave };
198
183
  }
199
184
  //# sourceMappingURL=visitor.js.map