fix(codegen): include plugin-injected fields in condition/orderBy types + VectorFilter#791
Merged
pyramation merged 3 commits intomainfrom Mar 12, 2026
Merged
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.
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:
|
3 tasks
This was referenced Mar 12, 2026
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): support pgvector types and plugin-injected condition/orderBy fields
Summary
The codegen only iterated over
table.fields(database columns) when building condition and orderBy types, so any fields/values injected by Graphile plugins (e.g.,embeddingNearbyfrom VectorSearchPlugin,EMBEDDING_DISTANCE_ASC/DESCorderBy values) were silently dropped from generated TypeScript.This PR fixes four things:
scalars.ts— AddsVector: 'number[]'toSCALAR_TS_MAPandVector: 'VectorFilter'toSCALAR_FILTER_MAPso pgvector'sVectorscalar resolves correctly.buildTableConditionPropertiesnow accepts an optionalTypeRegistryand merges extra fields present in the schema's condition type that aren't derived from table columns. A newcollectConditionExtraInputTypeshelper ensures referenced types (e.g.,VectorNearbyInput) get generated.buildOrderByValuessimilarly merges extra enum values from the schema's orderBy type.generateCustomInputTypespreviously only followed nested types ending with"Input", so enum types likeVectorMetric(referenced byVectorNearbyInput.metric) were silently dropped. Now follows all non-scalar types present in the typeRegistry.All changes are backwards-compatible — the
typeRegistryparameter is optional throughout.Tests added: 7 new test cases covering VectorFilter generation, plugin-injected condition fields, transitive enum resolution, field deduplication, plugin-injected orderBy values, and backwards compatibility. 14 snapshots updated (mechanical — VectorFilter added to always-generated scalar filter types).
Review & Testing Checklist for Human
generateCustomInputTypes(line ~1619) now follows any non-scalar type that exists in the registry (not just*Input). ThegeneratedTypesset prevents double-emission within this function, but types already emitted by earlier codegen stages (e.g.,generateEnumTypesfor table-column enums) could theoretically be duplicated in the output. Verify this doesn't cause issues with real schemas.typeRefToTs(field.type)while table-derived fields usescalarToTsType(fieldType) + ' | null'. Verify the nullability semantics are correct for both paths (table fields always get| null, plugin fields get nullability from the TypeRef wrapper).graphile-pgvector-pluginand confirm the generatedinput-types.tsnow includesembeddingNearbyin condition types,VectorMetricenum, and distance-based orderBy values. The unit tests use mocked registries that may not perfectly match actual PostGraphile output.pnpm codegenagainst it, and inspect the generatedinput-types.tsfor completeness.Notes