Skip to content

refactor(api): type D-batch-1 GraphQL resolver args from generated types (#8158)#8174

Closed
kai392 wants to merge 1 commit into
JSONbored:mainfrom
kai392:feat/graphql-types-d-batch1
Closed

refactor(api): type D-batch-1 GraphQL resolver args from generated types (#8158)#8174
kai392 wants to merge 1 commit into
JSONbored:mainfrom
kai392:feat/graphql-types-d-batch1

Conversation

@kai392

@kai392 kai392 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Closes #8158

Summary

types-epic D (#7862) batch 1 — converts the 20 discovery & subnet-lifecycle Query-field resolvers in src/graphql.ts from Row-typed args to the generated Query<Field>Args types, following the exact process PR #8005 established for the 5 pilot fields. Purely a resolver-argument typing change.

What changed (1 file: src/graphql.ts)

  • 16 fields declare SDL arguments and now use their generated Args type directly (the plain object-shape type, not the Apollo Resolvers wrapper — matching feat(types): types-epic D — GraphQL codegen from the SDL, pilot resolver adoption #8005, since this rootValue uses graphql-js's (args, context, info) default-field-resolver convention): subnet_registrations, subnet_hyperparameters, subnet_hyperparameters_history, subnet_deregistrations, subnet_serving, subnet_health_trends, subnet_uptime, subnet_health_incidents, subnet_health_percentiles, subnet_volume, candidates, saved_query, fixture, agent_catalog, top_holders, search.
  • 4 no-arg fields (agent_resources, curation, fixtures, freshness) — the SDL declares them with no arguments, so codegen emits no Args type; they already used an unknown args param, which already satisfies acceptance-criterion chore(deps): bump astral-sh/setup-uv from d0d8abe699bfb85fec6de9f7adb5ae17292296ff to d0cc045d04ccac9d8b7881df0226f9e82c39688e #1 (no args: Row). Left unchanged.
  • Batch note at the rootValue declaration updated to record batch 1 as done.

Step-2 mismatch check

The issue requires actually reading each resolver for an SDL/resolver type mismatch. Found one real type-surface issue: saved_query hands the SDL's opaque JSON params (which codegen types as unknown) to runSavedQuery, whose 3rd param is Row. Since runSavedQuery owns param coercion/validation, the value is cast to Row at the call site — no behavior change, and called out here per the issue's instruction. All other 15 fields converted with zero body changes.

No generated-types / SDL change

No SDL edit in src/graphql-sdl.ts, so generated/graphql/types.ts is unchanged and scripts/validate-graphql-types-drift.ts stays green (verified locally against the codegen output, EOL-normalized).

Validation

  • npx tsc --noEmit clean, repo-wide.
  • Generated-types drift check: no drift.
  • tests/graphql.test.ts green (1022 tests), unchanged.
  • 100% patch coverage verified locally via lcov on the exact changed line ranges (the one runtime line, the saved_query cast, is hit with both ?? branches taken).
  • eslint + prettier clean.

@kai392
kai392 requested a review from JSONbored as a code owner July 25, 2026 23:14
@superagent-security

Copy link
Copy Markdown

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

…pes (JSONbored#8158)

types-epic D (JSONbored#7862) batch 1: convert the 20 discovery & subnet-lifecycle
Query-field resolvers in src/graphql.ts from Row-typed args to the generated
Query<Field>Args types, following PR JSONbored#8005's pilot process. 16 of the fields
declare SDL arguments and adopt their generated Args type; the 4 no-arg fields
(agent_resources, curation, fixtures, freshness) already used an unknown args
param (codegen emits no Args type for a no-argument field), so they satisfy the
no-Row criterion unchanged.

Step-2 mismatch check (per the issue): one real type-surface fix -- saved_query
passes the SDL's opaque JSON params (typed unknown) to runSavedQuery, which
takes Row; cast at the call site since runSavedQuery owns param coercion. No
behavior change. No SDL change, so generated/graphql/types.ts is unchanged and
the drift gate stays green.

Closes JSONbored#8158
@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.82%. Comparing base (1ada9a4) to head (1f944fe).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8174   +/-   ##
=======================================
  Coverage   97.82%   97.82%           
=======================================
  Files         415      415           
  Lines       28893    28893           
  Branches    10850    10850           
=======================================
  Hits        28265    28265           
  Misses        141      141           
  Partials      487      487           
Files with missing lines Coverage Δ
src/graphql.ts 99.66% <100.00%> (ø)
🚀 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:bug Gittensor-scored bug fix or unsolicited PR — scores a 0.05x multiplier. label Jul 25, 2026
@loopover-orb

loopover-orb Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-25 23:32:57 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a mechanical type-narrowing refactor of 20 GraphQL Query-field resolvers in src/graphql.ts, replacing `Row`-typed args with generated `Query<Field>Args` types, following the exact precedent PR #8005 established for the 5 pilot fields. Body logic is untouched in every field except `saved_query`, where `params` (now typed `unknown` via `QuerySaved_QueryArgs`) is explicitly cast to `Row` at the `runSavedQuery` call site — a documented, behavior-preserving cast since that function owns its own coercion/validation. The imports and full-file content confirm all 16 new type names are correctly imported and used, and CI is green.

Nits — 5 non-blocking
  • No new tests were added for this PR, but since it is a pure type-annotation change with zero runtime behavior modification (verified against the diff — only type positions changed, no logic), existing test coverage on these resolvers should already catch any regression.
  • The `saved_query` cast `(params ?? {}) as Row` silently discards the `unknown` type safety codegen just introduced; a follow-up could have `runSavedQuery` accept `unknown` directly and narrow internally, though this is explicitly flagged as intentional in the PR description and comment.
  • Consider filing a fast-follow to change `runSavedQuery`'s third parameter to `unknown` so the cast at src/graphql.ts's `saved_query` resolver becomes unnecessary rather than papered over.
  • Given the batch-based epic structure (types-epic D: GraphQL codegen from the SDL — typed resolvers replacing Row-typed args #7862), confirm the batch-note comment convention (now updated to record batch 1) is consistently applied so future batches don't drift from this pattern.
  • Code changes lack test evidence — Add focused regression tests or explain why existing coverage is sufficient.

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 #8158
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: 149 registered-repo PR(s), 78 merged, 7 issue(s).
Contributor context ✅ Confirmed Gittensor contributor kai392; Gittensor profile; 149 PR(s), 7 issue(s).
Linked issue satisfaction

Addressed
The diff converts all 16 fields in this batch that take SDL arguments to their generated Query<Field>Args types (with the 4 no-arg fields already satisfying the acceptance criterion via `unknown`), updates the batch-note comment, and explicitly calls out the one found saved_query/runSavedQuery type-surface mismatch with a cast rather than a silent behavior change, matching the issue's required pro

Review context
  • Author: kai392
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, Cuda, JavaScript, Kotlin, Perl, TypeScript, Vue
  • Official Gittensor activity: 149 PR(s), 7 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 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (Linked issue #8158 is assigned to the maintainer (@JSONbored) — that work is reserved for the maintainer, so this PR cannot be auto-accepted.). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

@loopover-orb loopover-orb Bot closed this Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix or unsolicited PR — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

types-epic D batch 1: GraphQL resolver typing for discovery & subnet lifecycle (20 fields)

1 participant