refactor(cli): simplify arg parsing with generic transforms, remove --browser-compatible #693
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