feat(pgvector): move vector search from condition to filter argument#796
Merged
pyramation merged 2 commits intomainfrom Mar 12, 2026
Merged
feat(pgvector): move vector search from condition to filter argument#796pyramation merged 2 commits intomainfrom
pyramation merged 2 commits intomainfrom
Conversation
Migrates vector embedding search fields from PostGraphile's built-in `condition` argument to the connection filter plugin's `filter` argument. Changes: - Scope check: isPgCondition -> isPgConnectionFilter - Field scope: isPgConnectionConditionInputField -> isPgConnectionFilterField - Plugin ordering: add PgConnectionArgFilterPlugin to after[] deps - Rename conditionPrefix option to filterPrefix (backwards compat kept) - Make postgraphile-plugin-connection-filter a required peer dependency - Update all tests to use filter: instead of condition: - Add PostGraphileConnectionFilterPreset to test preset The core apply function logic is unchanged since the v5 connection filter plugin uses PgCondition wrapping PgSelectStep — identical to the condition approach. getQueryBuilder() traversal, selectAndReturnIndex, setMeta, and orderBy all work the same way.
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:
|
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(pgvector): move vector search from condition to filter argument
Summary
Migrates vector embedding search fields from PostGraphile's built-in
conditionargument to the connection filter plugin'sfilterargument for unified filtering DX. All vector search inputs now live alongside PostGIS and column filters underfilter:.Before:
After:
Key changes in
graphile-pgvector-plugin:vector-search.ts: Scope check changed fromisPgCondition→isPgConnectionFilter. Plugin ordering updated to load afterPgConnectionArgFilterPlugin. The coreapplyfunction logic is unchanged — the v5 connection filter plugin createsPgConditionwrappingPgSelectStepin its apply chain, sogetQueryBuilder()traversal,selectAndReturnIndex,setMeta, andorderByshould all work identically.types.ts:conditionPrefixoption renamed tofilterPrefix(old name kept as@deprecatedalias).package.json:postgraphile-plugin-connection-filterpromoted from optional to required peer dependency.condition:tofilter:,PostGraphileConnectionFilterPresetadded to test preset.Review & Testing Checklist for Human
getQueryBuilder()parent traversal works under the filter's PgCondition chain. This is the highest risk item. The approach assumes the connection filter plugin's v5applyPlancreates aPgCondition(pgSelectStep)with the same parent structure as the native condition system. If the parent chain differs,selectAndReturnIndex/setMeta/orderBywill silently fail (distance field returns null, ordering doesn't apply). Run the vector-search tests (cd graphile/graphile-pgvector-plugin && pnpm test) against a real Postgres instance with pgvector to confirm.applyfunction is invoked by the connection filter system. The field is registered with anapply:property, but the connection filter plugin's v5 adaptation may use a different invocation pattern than native condition fields. Confirm filter queries actually trigger the apply function and produce correct SQL.condition: { vectorEmbedding: ... }must update tofilter: { vectorEmbedding: ... }. Check for any other packages in the monorepo (codegen, server-test, etc.) that may reference the old query shape.embeddingDistanceoutput field andEMBEDDING_DISTANCE_ASC/DESCorderBy still work. These hooks are unchanged but rely on the meta system being populated by the filter's apply function. Test withfilter: { vectorEmbedding: {...} }+orderBy: EMBEDDING_DISTANCE_ASCto verify end-to-end.Notes
scope: { isPgConnectionFilter, pgCodec } = {} as anyandisPgConnectionFilterField: true as anyare type escape hatches. The connection filter plugin is a v4 plugin adapted for v5, so its scope properties aren't in PostGraphile's v5 type declarations. These casts are necessary but mean wrong scope property names would silently fail instead of producing type errors.ConstructivePresetalready loadsPostGraphileConnectionFilterPresetbeforeVectorSearchPluginin its extends array, which should satisfy the new dependency, but this wasn't verified.Session: https://app.devin.ai/sessions/c7c114e9d17e421bba9564e48d0421c0
Requested by: @pyramation