fix(codegen): convert string concatenation to Babel AST and template-copy patterns#691
Open
pyramation wants to merge 7 commits intomainfrom
Open
fix(codegen): convert string concatenation to Babel AST and template-copy patterns#691pyramation wants to merge 7 commits intomainfrom
pyramation wants to merge 7 commits intomainfrom
Conversation
…copy patterns - Convert queries.ts, mutations.ts, custom-queries.ts, custom-mutations.ts from lines.push() string concatenation to Babel AST generation - Convert client.ts and selection.ts from string template literals to template-copy pattern - Add hooks-ast.ts shared helper library for Babel AST node construction - Add template files: hooks-client.ts, hooks-selection.ts - Add AGENTS.md with codegen rules (AST-only, no string concat, templates as files) - Update test snapshots for Babel formatting changes (whitespace/formatting only)
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This was referenced Feb 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fix(codegen): convert string concatenation to Babel AST and template-copy patterns
Summary
This PR supersedes #689 and carries forward its ORM-as-core architecture while fixing an AST regression: 4 hook generator files (
queries.ts,mutations.ts,custom-queries.ts,custom-mutations.ts) usedlines.push()string concatenation instead of proper Babel AST generation. This PR converts them back.Changes:
Converted 4 files from
lines.push()→ Babel AST (@babel/types+@babel/generator):queries.ts(239lines.pushcalls removed) — list + single query hooks, fetch, prefetchmutations.ts(157 calls) — create, update, delete mutation hookscustom-queries.ts(195 calls) — custom query hooks with variable handlingcustom-mutations.ts(47 calls) — custom mutation hooksConverted 2 files from string template literals → template-copy pattern:
client.ts→ reads from newtemplates/hooks-client.tsselection.ts→ reads from newtemplates/hooks-selection.tsNew shared helper library (
hooks-ast.ts, ~875 lines) — Reusable Babel AST node builders for imports, type references, function declarations, query/mutation patterns, etc.Added
AGENTS.mdingraphql/codegen/documenting three codegen rules: AST-only generation, no string concatenation, static templates as real files.22 test snapshots updated — formatting-only changes (Babel's multi-line type literals, semicolons in type properties, double quotes). No logic changes.
Review & Testing Checklist for Human
buildFindManyCallExpr,returnUseQuery,buildMutationResultTypeproduce valid AST. Note: uses@ts-ignorefor Babel type parameter hacks.findTemplateFile()traverses up directories looking fortemplates/. Verify this works in production builds (dist/) not just source.lines.push()remains — Search the 4 converted files to ensure no string concatenation code generation remains.Recommended test plan:
pnpm buildingraphql/codegenpnpm testto verify all 204 tests passcnc codegen --react-query --endpoint <url> --output ./test-outputtsc --noEmitNotes
This PR includes all changes from the base branch
feat/graphql-codegen-orm-core(the ORM-as-core refactor from PR #689), plus the AST regression fixes. The workflow file changes and test-app additions are from that base branch.Link to Devin run: https://app.devin.ai/sessions/a93d427c49214dce877d1fedee950c04
Requested by: @pyramation