Skip to content

feat(graphql): export schema SDL artifact, add drift guard and breaki… - #476

Merged
Miracle656 merged 3 commits into
Divinity-Labs:mainfrom
Bigclavsfx:feat/graphql-schema-sdl-artifact
Oct 18, 2026
Merged

Miracle656 merged 3 commits into
Divinity-Labs:mainfrom
Bigclavsfx:feat/graphql-schema-sdl-artifact

Conversation

@Bigclavsfx

Copy link
Copy Markdown
Contributor

Closes #372

Summary

Related issue

Type of change

  • Bug fix
  • New feature
  • Refactor
  • Docs
  • Tests
  • CI / tooling

Checklist

  • I have read CONTRIBUTING.md
  • npx tsc --noEmit passes
  • npm run build passes
  • I added / updated tests where relevant
  • I updated docs where relevant

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Bigclavsfx Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

The drift guard this PR adds caught its own artifact going stale:

    × committed schema.graphql matches the code-defined schema exactly

Between this branch being cut and now, Divinity-Labs#380 (invalid/unknown/empty pair
distinctions), Divinity-Labs#381 (the oracle query and OracleSourceStatus enum) and
Divinity-Labs#390 (from/to on getPriceHistory) all changed the code-defined schema.

    npm run graphql:schema:gen

Which is the guard doing exactly what it was written for, on its first
outing.

graphqlSchemaDrift.test.ts: 6 passed.

Claude-Session: https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB

@Miracle656 Miracle656 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging. This closes #372 and the guard proved itself before it even landed.

The drift test caught its own artifact going stale, which is the best possible demonstration of why it exists:

× committed schema.graphql matches the code-defined schema exactly

Between your branch being cut and now, #380 (invalid/unknown/empty pair distinctions), #381 (the oracle query and the OracleSourceStatus enum) and #390 (from/to on getPriceHistory) all changed the code-defined schema. The committed SDL described a GraphQL API that no longer existed — in under a day. I regenerated it with npm run graphql:schema:gen and pushed that to your branch; 6 tests pass.

That is the whole argument for this PR, delivered by accident. A schema living only as a template literal inside src/api/graphql.ts drifts from what clients were generated against and nothing says so.

Three tests, three different jobs, which is what makes this more than a file dump:

  • committed schema.graphql matches the code-defined schema exactly — the drift guard.
  • regenerates deterministically — without it, a generator with unstable ordering makes the guard fail at random and someone eventually deletes it.
  • produces valid GraphQL SDL that client generators and validators can parse, asserting a real Query and Subscription type — so the artifact is actually consumable, not just byte-equal to itself.

That middle test is the one people skip, and it is the one that keeps the other two alive.

The repo already had this pattern for .env.example and for the OpenAPI document; GraphQL was the surface without it.

@Miracle656
Miracle656 merged commit 994fb76 into Divinity-Labs:main Oct 18, 2026
This was referenced Oct 18, 2026
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.

The schema is a template literal with nothing checking it

2 participants