Skip to content

feat(codegen): wire condition arg through ORM query builder for findMany/findFirst#794

Merged
pyramation merged 1 commit intomainfrom
devin/1773284776-condition-arg-support
Mar 12, 2026
Merged

feat(codegen): wire condition arg through ORM query builder for findMany/findFirst#794
pyramation merged 1 commit intomainfrom
devin/1773284776-condition-arg-support

Conversation

@pyramation
Copy link
Contributor

feat(codegen): wire condition arg through ORM query builder for findMany/findFirst

Summary

Adds TCondition generic parameter support to the ORM layer so that generated model classes can accept and forward condition arguments (e.g., embeddingNearby for vector search, bm25Body for BM25) through findMany and findFirst operations.

Changes across 4 source files:

  • select-types.ts (template + ORM): Added TCondition generic and condition?: TCondition field to FindManyArgs and FindFirstArgs
  • query-builder.ts: Added conditionTypeName parameter and addVariable() call for condition in both buildFindManyDocument and buildFindFirstDocument. Made VariableSpec.typeName optional with a guard so condition is cleanly skipped when not provided.
  • model-generator.ts: Wires ${TypeName}Condition into imports, generic type params, body arg forwarding, and document builder calls for both findMany and findFirst

3 new tests + 4 updated snapshots:

  • Model-generator test verifying condition type import, generic params, arg forwarding, and conditionTypeName string literal
  • Query-builder tests verifying condition variable appears in generated GraphQL when provided, and is omitted when absent

Review & Testing Checklist for Human

  • Verify VariableSpec.typeName change is safe: Changed from typeName: string to typeName?: string in query-builder.ts (line 825). The addVariable guard (!spec.typeName) prevents runtime errors, but confirm no other callers depend on typeName being required at the type level.
  • Verify condition variable ordering: In buildFindManyDocument, condition is added before where/filter. In buildFindFirstDocument, condition is added after where/filter. GraphQL doesn't care about variable order, but confirm this inconsistency is acceptable.
  • Verify ${typeName}Condition naming convention: The condition type name is hardcoded as ${typeName}Condition in model-generator (line 178). Confirm this matches what PostGraphile actually generates for all table types.
  • End-to-end verification: Run the codegen against an actual schema with vector/BM25 condition types and verify the generated ORM client accepts condition args and produces valid GraphQL queries.

Notes

…any/findFirst

- Add TCondition generic and condition?: TCondition to FindManyArgs and FindFirstArgs
- Add conditionTypeName parameter and addVariable() call in buildFindManyDocument/buildFindFirstDocument
- Wire ${TypeName}Condition into model-generator for findMany/findFirst methods
- Add unit tests for condition wiring in model-generator and query-builder
- Update snapshots
@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

Base automatically changed from devin/1773279354-fix-vector-codegen-v2 to main March 12, 2026 04:32
@pyramation pyramation merged commit 1588296 into main Mar 12, 2026
43 of 44 checks passed
@pyramation pyramation deleted the devin/1773284776-condition-arg-support branch March 12, 2026 04:32
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