Skip to content

Comments

fix(codegen): add select param and JSON input parsing to custom command generator#734

Merged
pyramation merged 1 commit intomainfrom
devin/1771827273-fix-custom-command-select
Feb 23, 2026
Merged

fix(codegen): add select param and JSON input parsing to custom command generator#734
pyramation merged 1 commit intomainfrom
devin/1771827273-fix-custom-command-select

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Feb 23, 2026

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 with Cannot read properties of undefined (reading 'select') because the ORM functions require (args, { select: {...} }) but the codegen only passed a single args argument.

This adds three things to custom-command-generator.ts:

  1. select parameter — 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.
  2. JSON input parsing — Mutations with INPUT_OBJECT args (like input: SignUpInput) now import and call parseMutationInput() from utils to parse JSON string CLI input into proper objects.
  3. unwrapType helper — Recursively unwraps NON_NULL/LIST wrappers 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

  • Verify select: {} is valid for query operations — When returnType.fields is 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.
  • Test the parseMutationInput path end-to-end — The unit tests only cover mutations with SCALAR args (email/password), not INPUT_OBJECT args. The hasInputObjectArg detection, conditional parseMutationInput import, and parsedAnswers variable path are not exercised by existing codegen tests. Recommend testing with a real schema that has input: SomeInput style mutations (like signUp in constructive-db via #510).
  • Verify utilsPath derivation — The import path for parseMutationInput is derived via executorImportPath.replace(/\/executor$/, '/utils'). Confirm this produces correct paths for both single-target (../utils) and multi-target (../../utils) layouts.
  • Verify returnType.fields population in real codegen — The test fixtures use createTypeRef('OBJECT', 'LoginPayload') with no fields, so the buildSelectObject fallback paths are always taken in tests. Check whether the real introspection pipeline populates fields on custom operation return types, or if the fallbacks (clientMutationId / empty {}) are always what gets generated in practice.

Notes

…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
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit 4e525f2 into main Feb 23, 2026
44 checks passed
@pyramation pyramation deleted the devin/1771827273-fix-custom-command-select branch February 23, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant