Skip to content

feat: GraphQL schema drift validator with CI and query fixes#77

Merged
jonathanprozzi merged 7 commits intomainfrom
feature/graphql-schema-validator
Apr 1, 2026
Merged

feat: GraphQL schema drift validator with CI and query fixes#77
jonathanprozzi merged 7 commits intomainfrom
feature/graphql-schema-validator

Conversation

@jonathanprozzi
Copy link
Copy Markdown
Member

Summary

  • Schema validator: Zero-dependency Node.js script that validates all 242 documented GraphQL queries against live schema introspection (dual-endpoint: mainnet errors, testnet warnings)
  • Query fixes: Corrected 131 GraphQL query errors across docs (missing fields, invalid selections, schema mismatches)
  • CI workflow: PR checks validate queries against committed snapshots; nightly cron detects schema drift and opens a single auto-updating draft PR
  • Supply chain ready: Committed schema snapshots enable fast offline pre-commit validation

Key files

  • scripts/validate-graphql-queries.js — core validator (introspection, query extraction, field-level validation)
  • scripts/graphql-schema-{mainnet,testnet}.json — committed schema snapshots
  • .github/workflows/validate-graphql.yml — PR checks + nightly drift detection with single-PR reuse
  • package.json — npm scripts (validate-queries, update-schema) + lint-staged config

How it works

  1. Schema: Introspects both endpoints, builds type maps, commits snapshots
  2. Extraction: Finds queries in playground exports, inline code blocks, and GraphQLPlayground.tsx
  3. Validation: Recursive descent parser walks field selections against the type map
  4. Drift detection: Nightly cron fetches fresh schemas — if changed, force-pushes to a stable auto/schema-update branch and creates/updates a single draft PR (not a new PR per run)

Test plan

  • --dry-run extracts 242 queries across all doc files
  • Full validation runs and reports errors against committed snapshots
  • --update-schema fetches fresh schemas from both endpoints
  • Schema divergence detection works (99 differences between mainnet/testnet)
  • Pre-commit: lint-staged triggers validator on staged doc files
  • CI: workflow triggers on PR and validates against snapshots

🤖 Generated with Claude Code

jonathanprozzi and others added 5 commits February 25, 2026 23:06
Introspection-based validator that catches field-level bugs in documented
GraphQL queries (wrong fields, missing selection sets) without executing
queries. Validates against committed schema snapshots from both mainnet
and testnet endpoints.

- Phase 1: Schema introspection + type map building (--update-schema)
- Phase 2: Query extraction from playground exports + code blocks
- Phase 3: Minimal recursive descent GraphQL parser for field walking
- Phase 4: Reporting with mainnet errors (blocking) + testnet warnings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- npm run validate-queries: full validation against both schemas
- npm run update-schema: refresh schema snapshots from live endpoints
- lint-staged: runs query validator on graphql-api and tutorial query docs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two jobs:
- PR checks: validates queries against committed snapshots on doc changes
- Schema drift: nightly cron + repository_dispatch (Phase 4 ready)
  fetches fresh schemas, opens draft PR if drift detected

Triggers: pull_request, schedule (8am UTC), repository_dispatch,
workflow_dispatch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix all documented queries to match the live mainnet schema:

- accounts: remove non-existent created_at, following, follower fields
- signals: atom→term, block_timestamp→created_at, shares_delta→delta
- terms: term_id→id, label/image/creator→atom { label image creator }
- events: block_timestamp→created_at, remove sender_id/receiver_id/data
- vaults: atom/triple→term relationship
- deposits: assets_for_receiver→assets_after_fees, shares_for_receiver→shares
- redemptions: assets_for_receiver→assets, shares_from_receiver→shares
- PinOutput: remove hash/name/size, keep only uri
- share_price_changes: old_price/new_price/price_change→share_price
- stats: updated_at→last_updated
- fee_transfers: block_timestamp→created_at
- PnL charts: add selection sets for data field (AccountPnlChartPoint, etc.)

Validator now passes with 0 mainnet errors (19 testnet-only warnings
from expected schema divergence).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…cates

The nightly schema drift workflow was creating a new branch and draft PR
every run, resulting in 27+ identical stale PRs. Now uses a stable
branch name (auto/schema-update) and checks for an existing open PR
before creating a new one — force-pushes updates to the same PR instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fresh introspection reveals schema drift: PnL and volume fields now use
_formatted/_raw suffixes, and get_vault_leaderboard_period was renamed
to get_pnl_leaderboard_period. Updates schema snapshots and fixes all
14 broken queries across 3 leaderboard docs. 242/242 queries now pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jonathanprozzi jonathanprozzi temporarily deployed to feature/graphql-schema-validator - intuition-docs PR #77 April 1, 2026 01:36 — with Render Destroyed
@jonathanprozzi jonathanprozzi merged commit 874c171 into main Apr 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant