Repository navigation
Conversation
Skip embedding fields in ordinary filter generation so vector schemas remain valid when generated updates are disabled. Cover all eight mutation-generation combinations and preserve cosine indexes, read queries, and ordinary filters. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe schema generator now excludes ChangesVector filter generation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable issue is established for this change; it is mergeable after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
|
||
| for _, fld := range defn.Fields { | ||
| // Vector indexes support similarity queries, not ordinary field filters. | ||
| if hasEmbeddingDirective(fld) { |
There was a problem hiding this comment.
With this guard in place, the "hnsw": "HNSWSearchFilter" entry in builtInFilters (line 543) is unreachable, and it still names a type that has never existed. Worth deleting it in this PR so a future refactor doesn't rewire it and bring the bug back.
There was a problem hiding this comment.
Partly agreed — thanks. The mapping was not quite unreachable: searchValidation in rules.go also used builtInFilters as the registry of supported @search arguments, so deleting only that entry made every hnsw(...) field fail with "not among supported search types". a7ae10e removes the dead HNSWSearchFilter mapping and validates search arguments against supportedSearches instead (both maps had identical keys apart from hnsw), so HNSW remains a valid search type without an ordinary filter type.
| ) | ||
|
|
||
| // TestVectorGenerateRestrictions keeps vector query generation independent of mutation generation. | ||
| func TestVectorGenerateRestrictions(t *testing.T) { |
There was a problem hiding this comment.
Schema generation coverage in this package is golden-file based: TestSchemaString walks testdata/schemagen/input/ and diffs against testdata/schemagen/output/. A fixture like embedding-directive-with-generate-restrictions.graphql with @generate(mutation: {update: false}) would pin the whole generated schema (not just a handful of substrings) and is where the next person will look for this.
The eight-combination loop is fine as a belt-and-braces check, but as written it breaks package convention in a couple of ways: every other test file here uses testify require rather than t.Fatal, and there's no precedent for a standalone *_regression_test.go file. I'd suggest adding the golden fixture, and either folding this loop into schemagen_test.go with require or dropping it since the fixture covers the failing case.
There was a problem hiding this comment.
Done in a7ae10e: added the embedding-directive-with-generate-restrictions.graphql input/output fixtures with @generate(mutation: {update: false}), covered by TestSchemaString, which also re-parses the generated schema. I removed the standalone regression test and confirmed that the fixture fails when the addFilterType guard is removed. go test ./graphql/schema/ passes.
- Remove the dead HNSWSearchFilter mapping and validate HNSW through supportedSearches. - Replace the standalone regression with a schemagen golden fixture for update:false. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Description
Fixes #9838
Fix GraphQL schema generation for indexed embeddings on types with
@generate(mutation: { update: false }).Why we encountered this
We encountered this while adding semantic search to an existing GraphQL API.
Some types deliberately disable generated mutations because application-owned
custom mutations enforce domain validation and business rules. Those types still
need generated read and similarity queries.
Adding an indexed embedding made the schema invalid. Enabling generated updates
would change the intended write API, so it is not an appropriate workaround.
Vector search should not depend on whether an unrelated update operation is
generated.
Minimal reproduction
Submit this schema to
/admin/schema/validate:On unmodified v25.4.1, validation fails with:
The same failure is reproducible using the schema generator on current
mainat
ddc4841. Changing onlyupdatetotruemakes validation succeed.Root cause
addFilterTypetreats the HNSW index as an ordinary field filter and emits areference to
HNSWSearchFilter, although that input type does not exist.When generated updates are enabled,
cleanupInputhappens to remove the invalidreference while traversing
Update...Inputand itsfilterinput. With updatesdisabled, that traversal does not happen and the invalid reference survives.
Fix
Skip
@embeddingfields when constructing ordinary field filters. HNSW indexesare consumed by similarity queries, not ordinary field filters.
This preserves:
hasfilter.get,ByEmbedding, andByIdqueries.The production change is four lines. A regression test covers all eight
add/update/delete combinations and checks the preserved schema surfaces.
Validation
update: falseand passes on the other four.graphql/schemapackage passes:go test -race -count=1 ./graphql/schema.go vet ./graphql/schema,gofmt, andgit diff --checkpass.jemallocbuild tag.application schema through
/admin/schema/validate.1024-dimensional cosine-vector predicates, including insertion, replacement,
deletion, and concurrent-source-change handling. Application-specific fixtures
are not included in this contribution.
This fixes an existing feature; no new public API or documentation change is
proposed.
Checklist
current validation environment.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit