Add two-layer GraphQL schema drift checker#6
Merged
dkijania merged 1 commit intoMay 27, 2026
Conversation
The SDK previously had no drift detection — schema changes could ship that subtly broke queries. This adds parity with the Go / Python / Rust SDKs: 1. Introspection diff (Layer 1): compare schema/graphql_schema.json (new snapshot from devnet) to the live __schema. Detects added / removed types, field-type changes, argument-type changes (e.g. UInt64 -> TokenId), inputField-type changes, enum-value changes. 2. Live query check (Layer 2): parse src/queries.ts, send each operation with sentinel variables, classify errors as schema drift vs runtime (auth, value-validation). Drift patterns matched against the message before the path-based runtime fallback; bare "expected type" deliberately excluded (false-positives on value coercion); "expected on field X, found Y" routed to runtime explicitly. Other design choices: - AbortController with 30s timeout on every fetch - HTTP status check (non-2xx -> error with body snippet) - normalizeSchema throws on error envelopes (no silent fake-empty) - nameOf sort key safe against null / non-object entries - kind nil-guard avoids spurious "<undefined> -> X" diffs - parseQueries filters to bodies that start with an operation keyword - parseVariableDecls anchored to body start - Sentinel table supports SignatureInput (legitimate `null` value) via a NO_SENTINEL marker that lets us distinguish "no sentinel known" from "explicit null sentinel" - Connection / HTTP errors counted as infra failures, not "drift"; always exits 1 - SKIPped ops (stale sentinel table) fail in --strict Adds .github/workflows/schema-drift.yml mirroring the other SDKs: master / compatible / develop matrix against lightnet images; weekly cron + workflow_dispatch + PRs that touch schema/ or the script. Exposes `npm run check:drift`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2 tasks
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.
Stacked on #5 — review/merge that one first; rebase this on `main` afterward.
Summary
The JS SDK previously had no schema-drift detection. This adds parity with the Go / Python / Rust SDKs:
Design choices
CI
`.github/workflows/schema-drift.yml` mirrors the other SDKs: master / compatible / develop matrix against lightnet images; weekly cron + `workflow_dispatch` + PRs that touch `schema/` or the script. Exposes `npm run check:drift`.
Test plan
🤖 Generated with Claude Code