Skip to content

fix(codegen): remove condition generation from ORM codegen#972

Merged
pyramation merged 1 commit intomainfrom
feat/remove-condition-from-codegen
Apr 10, 2026
Merged

fix(codegen): remove condition generation from ORM codegen#972
pyramation merged 1 commit intomainfrom
feat/remove-condition-from-codegen

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

Summary

ConstructivePreset disables PgConditionArgumentPlugin and PgConditionCustomFieldsPlugin, so *Condition input types (e.g. DocumentCondition, DiligenceRequestCondition) do not exist in the GraphQL schema. However, the ORM codegen was still emitting $condition variables in generated GraphQL queries, causing runtime errors:

Variable "$condition" expected value of type "DocumentCondition" which cannot be used as an input type.

This PR removes condition generation entirely from the codegen pipeline:

  • Type interfaces: Removed TCondition type parameter and condition property from FindManyArgs and FindFirstArgs (both template and ORM copies in select-types.ts)
  • Query builders: Removed $condition variable emission from buildFindManyDocument and buildFindFirstDocument in query-builder.ts
  • CLI utilities: Removed condition parsing from parseFindManyArgs and parseFindFirstArgs in cli-utils.ts
  • Model generator: Removed condition type args, imports, property forwarding, and conditionTypeName string literal from generated model classes
  • CLI/codegen generators: Removed conditionEnabled flags and condition option plumbing from cli/index.ts, cli/table-command-generator.ts, codegen/index.ts, codegen/queries.ts, and generate.ts
  • Input types generator: Removed dead buildTableConditionProperties, generateTableConditionTypes, and collectConditionExtraInputTypes functions
  • Tests: Removed condition-specific test cases, updated 10 snapshots

Review & Testing Checklist for Human

  • Verify no downstream consumers rely on condition: Any generated code or manually written code passing condition to FindManyArgs/FindFirstArgs will break at compile time. Check that SDK packages (constructive-sdk, constructive-react, constructive-node, constructive-cli) still build correctly after regeneration.
  • Test against diligence-room: Run orm-search.test.ts in pyramation-studio/diligence-room against this branch to confirm the $condition runtime error is resolved.
  • Dead code in utils.ts: getConditionTypeName() is still defined in utils.ts but no longer imported anywhere — consider whether to remove it or keep it for potential future use.
  • generateAllModelFiles signature: Third param options was effectively removed (always undefined now). Verify all callers in orm/index.ts and tests are compatible.

Notes

  • This is a breaking change for any code that was using the condition property on FindManyArgs/FindFirstArgs. This is intentional since the schema has no condition types.
  • All filtering should go through the where argument provided by graphile-connection-filter.

Link to Devin session: https://app.devin.ai/sessions/136ba9e7789e4cf28c757e6740c21808
Requested by: @pyramation

ConstructivePreset disables PgConditionArgumentPlugin, so *Condition
input types do not exist in the schema. The ORM codegen was still
emitting $condition variables in generated GraphQL queries, causing
runtime errors like 'Variable $condition expected value of type
DocumentCondition which cannot be used as an input type.'

This commit removes condition generation entirely:
- Remove TCondition type parameter from FindManyArgs/FindFirstArgs
- Remove condition variable from buildFindManyDocument/buildFindFirstDocument
- Remove conditionEnabled flags from ORM, CLI, and codegen generators
- Remove generateTableConditionTypes and collectConditionExtraInputTypes
- Remove condition from parseFindManyArgs/parseFindFirstArgs
- Update all tests and snapshots
@devin-ai-integration
Copy link
Copy Markdown
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 61fef36 into main Apr 10, 2026
50 checks passed
@pyramation pyramation deleted the feat/remove-condition-from-codegen branch April 10, 2026 05:54
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