refactor(cli): simplify arg parsing with generic transforms, remove --browser-compatible#693
Open
pyramation wants to merge 8 commits intomainfrom
Open
refactor(cli): simplify arg parsing with generic transforms, remove --browser-compatible#693pyramation wants to merge 8 commits intomainfrom
pyramation wants to merge 8 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)
…-browser-compatible - Add hyphenateKeys, flattenDbFields, buildDbConfig, seedArgvFromConfig, buildGenerateOptions to shared.ts as generic reusable utilities - Replace manual cliOverrides/hasNonInteractiveArgs with prompt->camelize->generate flow - Remove deprecated --browser-compatible flag from CLI, config types, and generate - Simplify both CLI entry points (graphql/codegen/src/cli, packages/cli) - Update test mocks to match new shared utility imports
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:
|
5 tasks
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.
refactor(cli): simplify arg parsing, remove --browser-compatible
Builds on PR #691 (
devin/1770496336-fix-ast-regression). The CLI cleanup is the final commit (13c06dfc8); the rest of the diff is from the parent branch's ORM-as-core refactor + AST regression fix.Summary
Replaces the manual field-by-field CLI argument parsing with a generic transform pipeline, and removes the deprecated
--browser-compatibleflag entirely.Before: Both CLI entry points had ~3 redundant layers duplicated across each file:
cliOverridesobject built with per-field if-statements checking bothargv['kebab-case']andargv.camelCasehasNonInteractiveArgsguard re-listing every flag a third timegenerate()optionsAfter: Generic utilities in
shared.ts:hyphenateKeys/camelizeArgv— bidirectional key transformsflattenDbFields/buildDbConfig— flatten/nest thedb.schemas/db.apiNamesstructureseedArgvFromConfig— merge config file values into argv (config as defaults, CLI flags override)buildGenerateOptions— camelize answers, nest db fields, merge with full configCore flow becomes:
packages/cli/src/commands/codegen.ts: 160 → 71 linesgraphql/codegen/src/cli/index.ts: 239 → 148 linesReview & Testing Checklist for Human
graphql-codegen --config ./config.ts --output ./override— verify CLI flags override config values while config-only fields (tables,hooks,queryKeys) pass through unchangedschemaFile→schema-file→schemaFileworks correctly through the transform chain. Edge cases:apiNames,reactQuery,dryRungraphql-codegenwith no config and no CLI flags — verify prompts appear and work--browser-compatibleis removed. Anyone passing this flag will get no error but the flag is silently ignoredNotes
packages/cli/__tests__/codegen.test.tsbypass the real transform logic — they mockseedArgvFromConfigas pass-through. Real integration testing is needed.devin/1770496336-fix-ast-regression(PR fix(codegen): convert string concatenation to Babel AST and template-copy patterns #691). The cumulative diff to main is large because it includes the ORM-as-core refactor. The CLI cleanup is the final commit.Link to Devin run: https://app.devin.ai/sessions/a93d427c49214dce877d1fedee950c04
Requested by: @pyramation