feat(codegen): wire condition arg through ORM query builder for findMany/findFirst#795
Merged
pyramation merged 5 commits intomainfrom Mar 12, 2026
Merged
feat(codegen): wire condition arg through ORM query builder for findMany/findFirst#795pyramation merged 5 commits intomainfrom
pyramation merged 5 commits intomainfrom
Conversation
… types Previously, buildTableConditionProperties and buildOrderByValues only iterated table.fields (database columns), missing any fields injected by Graphile plugins (e.g., VectorSearchPlugin's embeddingNearby condition field and EMBEDDING_DISTANCE_ASC/DESC orderBy values). Changes: - Add Vector scalar type mapping (number[]) to SCALAR_TS_MAP - Modify buildTableConditionProperties to merge plugin-added fields from the TypeRegistry's condition type - Modify buildOrderByValues to merge plugin-added enum values from the TypeRegistry's orderBy type - Add collectConditionExtraInputTypes to discover and generate referenced input types (e.g., VectorNearbyInput, VectorMetric) - Pass typeRegistry through to condition/orderBy generators - Add comprehensive tests for plugin-injected condition and orderBy types Fixes: constructive-io/constructive-planning#663
Previously, generateCustomInputTypes only followed nested types whose names ended with 'Input'. This meant enum types like VectorMetric (referenced by VectorNearbyInput.metric) were silently dropped from generated output, producing TypeScript with undefined type references. Now follows all non-scalar types that exist in the typeRegistry, including enums and other type kinds. Added unit test verifying transitive enum resolution through VectorNearbyInput → VectorMetric.
Adds Vector → VectorFilter mapping in SCALAR_FILTER_MAP and VectorFilter config (equality + distinct operators) in SCALAR_FILTER_CONFIGS, so that vector embedding fields in Filter types use VectorFilter instead of falling back to StringFilter. Includes unit test and updated snapshots.
…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
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:
|
…lumns VectorFilter provides equality/distinct operators for vector columns on Filter types. While similarity search is done via condition types (embeddingNearby), connection-filter may still auto-generate a filter for vector columns. Without this mapping, those fields would be silently omitted from the generated SDK.
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): wire condition arg through ORM query builder + vector/pgvector support
Summary
Two layered changes:
1. Vector/pgvector codegen support (base):
Vectorscalar →number[]in TypeScript, addsVectorFilter(equality/distinct operators)embeddingNearbyfrom VectorSearchPlugin)EMBEDDING_DISTANCE_ASC/DESC)VectorMetricenum insideVectorNearbyInput)generateCustomInputTypesto follow all non-scalar types in the registry, not just*Inputtypes2. Condition arg wiring through ORM layer (new):
TConditiongeneric parameter toFindManyArgsandFindFirstArgsinterfaces (both template and ORM copies)conditionTypeNameparameter andaddVariable()call inbuildFindManyDocument/buildFindFirstDocument${TypeName}Conditioninto model-generator: imports, generic type params, body arg forwarding, and document builder callsVariableSpec.typeNameoptional with a!spec.typeNameguard so condition is cleanly skipped when not providedFiles changed:
scalars.ts,input-types-generator.ts,select-types.ts(×2),query-builder.ts,model-generator.ts, plus tests and snapshots.Updates since last revision
scalars.tsandinput-types-generator.tsdocumenting whyVectorFilterexists: similarity search uses condition types (embeddingNearby), not filters, butpostgraphile-plugin-connection-filtermay still auto-generate a filter for vector columns. Without theVector → VectorFiltermapping, those fields would be silently omitted from the generated SDK. The filter's equality/distinct operators are rarely useful for embeddings, but the mapping ensures type-correctness if the filter type is present in the schema.Review & Testing Checklist for Human
VariableSpec.typeNamemade optional (query-builder.ts:825): Changed fromtypeName: stringtotypeName?: string. TheaddVariableguard prevents runtime errors, but verify no other callers depend on the required type to enforce correctness at compile time.buildFindManyDocument,conditionis added beforewhere. InbuildFindFirstDocument,conditionis added afterwhere. GraphQL doesn't care about variable order, but confirm this inconsistency is intentional or harmless.${typeName}Conditionnaming convention is hardcoded inmodel-generator.ts:178. Verify this matches what PostGraphile actually generates for all table types in your schemas.generateCustomInputTypes: Now follows all non-scalar types in the registry (previously only*Inputtypes). Confirm this doesn't pull in unintended types.conditionargs and produces valid GraphQL queries with$conditionvariables. The unit tests verify generated code strings but not runtime behavior.Notes
codegen/vectors-v2, with consistent code style and comprehensive tests