Skip to content

feat(api): GraphQL search_index filter/sort/page parity#8051

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
andriypolanski:feat/graphql-search-index-filters-7877
Jul 24, 2026
Merged

feat(api): GraphQL search_index filter/sort/page parity#8051
JSONbored merged 2 commits into
JSONbored:mainfrom
andriypolanski:feat/graphql-search-index-filters-7877

Conversation

@andriypolanski

Copy link
Copy Markdown
Contributor

Summary

Adds type, netuid, q, sort, and order to the GraphQL search_index field so it matches list_search_index / GET /api/v1/search-index.

Closes #7877

Why previous PRs were closed

PR Closed reason
#7989 CI failing (checks, test) — auto-closed
#8001 CI failing (checks) — auto-closed
#8012 Base-branch conflicts (DIRTY) — CI green, review approved; gate could not merge

Reimplementation on a fresh branch off current main (no competing open PR). SDL lives in graphql-sdl.ts (split from the monolithic file #8012 targeted).

What changed (4 files)

src/graphql-sdl.ts

  • search_index args: type, netuid, q, sort, order, limit, cursor (cursor: Int, matching REST/MCP)
  • New SearchIndexList return type with full list-query pagination meta (returned/limit/cursor/next_cursor/sort/order/generated_at)

src/graphql.ts

  • Resolver delegates to loadSearchIndexList (same loader MCP list_search_index + REST already use) — no local filter logic

generated/graphql/types.ts

  • Regenerated (npm run build:graphql-types)

tests/graphql.test.ts

  • Existing slim-artifact test expects integer next_cursor
  • Keyword q filter test
  • type + netuid AND-combination test

Validation

  • vitest run tests/graphql.test.ts -t 'search_index' — 3/3 passed
  • vitest run tests/graphql.test.ts -t 'discovery parity' — 16/16 passed
  • Gittensory Gate + full CI green (incl. codecov/patch ≥99%)

Test plan

  • search_index(q: "…") narrows documents by keyword
  • search_index(type: "subnet", netuid: N) combines filters with AND
  • search_index(limit: 1) returns integer next_cursor pagination
  • Invalid sort / type / limit / cursor surface as GraphQL errors

andriy-polanski and others added 2 commits July 24, 2026 20:46
Reuse loadSearchIndexList so search_index accepts type/netuid/q/sort/order with the same pagination meta as REST and MCP. Closes JSONbored#7877.

Co-authored-by: Cursor <cursoragent@cursor.com>
@superagent-security

Copy link
Copy Markdown

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.67%. Comparing base (739ba45) to head (20767fa).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8051      +/-   ##
==========================================
- Coverage   97.67%   97.67%   -0.01%     
==========================================
  Files         220      220              
  Lines       27230    27229       -1     
  Branches    10800    10800              
==========================================
- Hits        26598    26597       -1     
  Misses        140      140              
  Partials      492      492              
Files with missing lines Coverage Δ
src/graphql-sdl.ts 100.00% <ø> (ø)
src/graphql.ts 99.66% <100.00%> (-0.01%) ⬇️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 24, 2026
@loopover-orb

loopover-orb Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-24 21:01:50 UTC

4 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds type/netuid/q/sort/order filter parity to the GraphQL search_index field by delegating to the existing loadSearchIndexList loader (same one MCP list_search_index/REST already use), replacing the old cursor:String/manual listPage implementation with a new SearchIndexList type carrying full pagination metadata. The change is a thin, low-risk pass-through (no new business logic), the SDL, generated types, and resolver map are all consistently updated together, and the cursor type change from String to Int is a breaking but intentional and clearly documented contract change matching REST's convention. Tests cover the q filter and type+netuid AND-combination; the diff is coherent and CI is green.

Nits — 5 non-blocking
  • The `cursor: String` -> `cursor: Int` change on `search_index` is a breaking schema change for any existing GraphQL client passing a string cursor — confirm this is acceptable given the field was presumably functional pre-PR (src/graphql-sdl.ts search_index args).
  • src/graphql.ts's search_index resolver signature changed from destructured `{ limit, cursor }` to a raw `args: Row` passthrough — verify no args sanitization/whitelisting is lost since loadSearchIndexList now receives the full args object directly.
  • generated/graphql/types.ts is a large generated file; ensure `npm run build:graphql-types` was the actual generation step used (not hand-edited) since diffs against generated artifacts are easy to accidentally drift from the SDL.
  • Consider a follow-up test asserting an invalid `sort`/`order` value on search_index produces a GraphQL BAD_USER_INPUT error, mirroring the coverage pattern used for other filtered fields like source_snapshots.
  • Double check apps/ui or other GraphQL clients aren't passing a string cursor to search_index elsewhere in the codebase, given the Int type change.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7877
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 220 registered-repo PR(s), 139 merged, 22 issue(s).
Contributor context ✅ Confirmed Gittensor contributor andriypolanski; Gittensor profile; 220 PR(s), 22 issue(s).
Linked issue satisfaction

Addressed
The PR adds type/netuid/q/sort/order args to search_index in the SDL, has the resolver delegate to loadSearchIndexList (the same loader used by search-index-mcp.ts), and includes both a q keyword test and a type+netuid combination test as requested.

Review context
  • Author: andriypolanski
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, Rust, Cuda, JavaScript, Kotlin, MDX, Scala
  • Official Gittensor activity: 220 PR(s), 22 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 24, 2026
@JSONbored
JSONbored merged commit bc3e949 into JSONbored:main Jul 24, 2026
7 checks passed
@JSONbored JSONbored mentioned this pull request Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GraphQL parity: search_index field missing type/netuid/q/sort/order filters

3 participants