feat(codegen): add --select flag to custom CLI commands using nested-obj#735
Merged
pyramation merged 1 commit intomainfrom Feb 23, 2026
Merged
Conversation
Replace hardcoded buildSelectObject() with runtime --select flag for
custom mutation/query commands. When return type is OBJECT, generated
commands now accept --select 'field1,field2.nested' which uses
buildSelectFromPaths() (powered by nested-obj) to build the proper
nested { select: { ... } } structure at runtime.
- Add buildSelectFromPaths() to cli-utils.ts template
- Import nested-obj for dot-notation path parsing
- Remove hardcoded buildSelectObject() from custom-command-generator
- Add hasObjectReturnType() and buildDefaultSelectString() helpers
- For OBJECT return types: generate runtime select via --select flag
- For scalar return types: skip select entirely (no change needed)
- Default select falls back to all top-level fields when --select omitted
- Update 3 snapshots to reflect new generated code pattern
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 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.
feat(codegen): add --select flag to custom CLI commands using nested-obj
Summary
Replaces the hardcoded
buildSelectObject()incustom-command-generator.ts— which baked field selections into generated code at codegen time (and only selectedclientMutationIdfor mutations) — with a runtime--selectflag.Generated commands now accept:
The
buildSelectFromPaths()runtime helper (added tocli-utils.tstemplate) parses the comma-separated dot-notation string into the nested{ select: { ... } }structure the ORM expects:Key changes:
cli-utils.tstemplate: NewbuildSelectFromPaths()function usingnested-objfor dot-notation parsingcustom-command-generator.ts: RemovedbuildSelectObject(), addedhasObjectReturnType()andbuildDefaultSelectString(). For OBJECT return types, generatesbuildSelectFromPaths(argv.select ?? 'defaultFields'). For scalar return types, skips select entirely.Review & Testing Checklist for Human
nested-objdependency gap: Thecli-utils.tstemplate now importsnested-obj, but there is no mechanism to auto-add it to the generated CLI'spackage.json. Consumers will need to manuallypnpm add nested-objafter regenerating. Verify this is acceptable or ifinfra-generator.ts/ docs should be updated to surface this requirement.currentUser(a query with no known fields) defaults tobuildSelectFromPaths("")which produces{}. Verify the ORM handles{ select: {} }gracefully — or should queries without known return fields skipselectentirely (like scalar return types)?buildSelectFromPathscorrectness: No dedicated unit tests for the function. Manually verify nested path handling (e.g.'a.b.c,a.b.d'should merge correctly into{ a: { select: { b: { select: { c: true, d: true } } } } }). TheobjectPath.set()usage is only for leaf assignment — intermediate nesting is manual.signUp.Notes