feat(graphile-pgvector-plugin): auto-discover vector columns; remove old postgraphile-plugin-pgvector#768
Merged
pyramation merged 5 commits intomainfrom Mar 3, 2026
Conversation
…dition, distance, orderBy, and filter Adds VectorSearchPlugin that auto-discovers all vector columns across all tables and adds the following capabilities with zero configuration: - Condition fields: vectorEmbedding nearby condition on connections (accepts query vector, metric, optional distance threshold) - Computed distance fields: embeddingDistance on output types (returns distance when nearby condition is active, null otherwise) - OrderBy enum values: EMBEDDING_DISTANCE_ASC/DESC for sorting by distance - Connection filter operator: closeTo for Vector scalar Follows the same patterns as graphile-search-plugin (for tsvector columns). Wired into ConstructivePreset via graphile-settings.
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:
|
…e-pgvector-plugin)
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(graphile-pgvector-plugin): auto-discover vector columns; remove old postgraphile-plugin-pgvector
Summary
Adds a new
VectorSearchPlugintographile-pgvector-pluginthat auto-discovers allvectorcolumns across all tables — no per-table configuration required. This follows the same patterns asgraphile-search-plugin(for tsvector columns).Previously, using pgvector similarity search through PostGraphile required either:
postgraphile-plugin-pgvector(the old plugin)Now, any table with a
vector(n)column automatically gets:vectorEmbeddingcondition field on connection condition inputs — accepts{ vector, metric?, distance? }to filter by distance thresholdembeddingDistancecomputed field on output types — returns the distance when a nearby condition is active (null otherwise)EMBEDDING_DISTANCE_ASC/DESCorderBy enum values — sort results by vector distanceThe plugin is wired into
ConstructivePresetviagraphile-settingsso it's active by default.The old
postgraphile-plugin-pgvectorpackage (which required manual per-collection config) has been deleted entirely, along with its CI job. It was fully superseded by the auto-discover approach — nothing unique to preserve.Files changed
graphile/graphile-pgvector-plugin/src/vector-search.ts— New: the main plugin (~480 lines)graphile/graphile-pgvector-plugin/src/types.ts— New:VectorSearchPluginOptions,VectorMetrictypesgraphile/graphile-pgvector-plugin/src/index.ts— Updated exportsgraphile/graphile-pgvector-plugin/src/vector-codec.ts— Minor comment additiongraphile/graphile-pgvector-plugin/package.json— Added@dataplan/pgpeer dep, optionalpostgraphile-plugin-connection-filtergraphile/graphile-settings/src/presets/constructive-preset.ts— WiresVectorSearchPluginintoConstructivePresetgraphile/graphile-settings/src/plugins/index.ts— Re-exports new plugin + typesgraphile/graphile-pgvector-plugin/src/__tests__/vector-search.test.ts— New: integration tests (~370 lines)graphile/postgraphile-plugin-pgvector/— Deleted: entire old plugin package.github/workflows/run-tests.yaml— Removed old plugin CI jobGRAPHILE.md— Updated plugin listingUpdates since last revision
postgraphile-plugin-pgvector— The old plugin required manual per-collection config (collections: [{ schema, table, embeddingColumn }]), which is the opposite of the auto-discover approach. It was fully superseded bygraphile-pgvector-pluginand had no unique code worth preserving. Removed from CI workflow and docs as well.VectorMetricenum type error — TheVectorMetricenum was being registered twice: once inline vianew GraphQLEnumType()inside theVectorNearbyInputfields closure, and again viabuild.registerEnumType(). Fix: register the enum type first, then reference it viabuild.getTypeByName('VectorMetric').closeTofilter operator — ThecloseTooperator was a placeholder that modified the globalVectorfilter type (hardcodeddistance <= 1.0). Removed entirely; thevectorEmbeddingcondition field provides full control over metric and threshold.ConstructivePreset.Review & Testing Checklist for Human
graphile-pgvector-pluginpassing, including new vector-search integration tests against live PostgreSQL 17 + pgvectorbuild.registerInputObjectTypeandbuild.registerEnumTypeAPIs — The plugin uses these in theinithook. CI passing suggests they work, but double-check these are stable PostGraphile v5 RC APIs and won't break in future RC updates.anytype assertions — The plugin usesanytype assertions throughout (e.g.,const $parent = $condition.dangerouslyGetParent();). These access internal PostGraphile APIs that may not be stable. Verify these work with real schema builds or consider adding stronger typing.Test Plan
vector(1536)column and some OpenAI embeddingsConstructivePresetallItems(condition: { vectorEmbedding: { vector: [...], metric: COSINE, distance: 0.5 } }) { nodes { id embeddingDistance } }allItems(... orderBy: EMBEDDING_DISTANCE_ASC)cnc get-graphql-schemaand verify thatVectorNearbyInput,VectorMetricenum,vectorEmbeddingcondition field,embeddingDistanceoutput field, andEMBEDDING_DISTANCE_ASC/DESCorderBy values are present without duplicate type errorsKnown Limitations
selectAndReturnIndex,getMetaRaw,dangerouslyGetParent) that may not be stable across RC versionsvectorEmbeddingcondition with standard column conditions in complex ways (e.g., nestedand/or) may produce unexpected results — use separate filters if neededNotes