refactor(codegen): replace string concatenation with Babel AST generation #611
+11,864
−8,891
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Replaces string concatenation (
lines.push(),props.push()) and ts-morph usage with pure Babel AST generation using@babel/typesand@babel/generatoracross all React Query hook generators.Files Converted to Babel AST
query-keys.tsmutation-keys.tsinvalidation.tsqueries.tsmutations.tscustom-queries.tscustom-mutations.tsschema-types-generator.tsbarrel.tsA new
babel-ast.tshelper file provides reusable AST builders for common patterns (JSDoc comments, etc.).Note: The
ts-morphdependency andts-ast.tsfile remain because ORM generators (orm/directory) still use them. This PR only migrates the React Query codegen files.Updates Since Last Revision
Added comprehensive snapshot tests for all React Query hook generators:
Review & Testing Checklist for Human
react-query-hooks.test.ts.snapto ensure the semantic output is correctRecommended Test Plan
pnpm buildingraphql/codegento verify compilationpnpm testto verify all 135 tests passNotes
commentBlock,commentLine) are used for JSDoc commentsreact-query-hooks.test.tsvalidates generated output for all hook typesLink to Devin run: https://app.devin.ai/sessions/4d5df52ad251452da815b8cb06618596
Requested by: Dan Lynch (@pyramation)