fix(codegen): add select param and JSON input parsing to custom command generator#734
Merged
pyramation merged 1 commit intomainfrom Feb 23, 2026
Merged
Conversation
…nd generator
Custom mutation/query commands generated by the CLI codegen were missing
the required 'select' parameter when calling ORM operations, causing
'Cannot read properties of undefined (reading select)' at runtime.
Changes:
- buildOrmCustomCall now passes { select: {...} } as second argument
- Extracts return type fields from CleanOperation to build select object
- Falls back to { clientMutationId: true } for mutations without known fields
- Detects INPUT_OBJECT args and adds parseMutationInput() for JSON parsing
- Imports parseMutationInput from utils when needed
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.
fix(codegen): add select param and JSON input parsing to custom command generator
Summary
Generated CLI commands for custom mutations/queries (e.g.
signUp,login,currentUser) were crashing at runtime withCannot read properties of undefined (reading 'select')because the ORM functions require(args, { select: {...} })but the codegen only passed a singleargsargument.This adds three things to
custom-command-generator.ts:selectparameter — All ORM calls now receive{ select: {...} }as the second argument, built from the operation's return type fields when available, falling back to{ clientMutationId: true }for mutations or{}for queries.INPUT_OBJECTargs (likeinput: SignUpInput) now import and callparseMutationInput()from utils to parse JSON string CLI input into proper objects.unwrapTypehelper — Recursively unwrapsNON_NULL/LISTwrappers to inspect the underlying type kind.Table CRUD commands (already fixed in #733) are unaffected — this only changes the custom operation command generator.
Review & Testing Checklist for Human
select: {}is valid for query operations — WhenreturnType.fieldsis not populated (common case in test fixtures), queries get an empty select{}. Confirm the ORM/QueryBuilder handles this correctly and doesn't produce an invalid empty GraphQL selection set. This is the highest-risk part of the change since the unit tests don't exercise this with a real schema that populates return type fields.parseMutationInputpath end-to-end — The unit tests only cover mutations with SCALAR args (email/password), not INPUT_OBJECT args. ThehasInputObjectArgdetection, conditionalparseMutationInputimport, andparsedAnswersvariable path are not exercised by existing codegen tests. Recommend testing with a real schema that hasinput: SomeInputstyle mutations (likesignUpin constructive-db via #510).utilsPathderivation — The import path forparseMutationInputis derived viaexecutorImportPath.replace(/\/executor$/, '/utils'). Confirm this produces correct paths for both single-target (../utils) and multi-target (../../utils) layouts.returnType.fieldspopulation in real codegen — The test fixtures usecreateTypeRef('OBJECT', 'LoginPayload')with nofields, so thebuildSelectObjectfallback paths are always taken in tests. Check whether the real introspection pipeline populatesfieldson custom operation return types, or if the fallbacks (clientMutationId/ empty{}) are always what gets generated in practice.Notes