The Schema Workflow
Enable GraphQL, keep a committed SDL snapshot, and gate breaking changes in CI.
The schema is an output of your code, but it's also an artifact worth tracking: Base generates it to a committed file and checks compatibility against it, so breaking a client is a failed check instead of a production incident.
Enable GraphQL
Two lines in settings.ts:
Optional settings:
route: defaults to/graphql(POST;GETis added only when GraphiQL is on).graphiql/introspection: environment-keyed booleans; both default to on in development, off in production. Enable introspection deliberately if you have a schema-consuming toolchain in production.- CORS comes from the worker's one allowlist: Base deliberately overrides the GraphQL server's own permissive CORS handling.
Generate the SDL snapshot
This writes the generated SDL (e.g. graphql/schemas/schema.graphql in your worker) — commit it. The snapshot is the reviewable face of your schema: a PR that changes resolvers shows the schema diff right next to the code diff.
Gate breaking changes
Verifies the current code's schema is backward-compatible with the committed baseline, failing on breaking changes — removed fields, changed types, newly-required arguments. Run it in CI and schema breakage becomes a deliberate decision (update the baseline in the same PR) rather than an accident.
The rhythm
- Change types or resolvers.
npx base graphql schema:generate: refresh the snapshot, read the diff.npx base graphql schema:check: confirm compatibility (CI runs it too).- Commit code + snapshot together.
That's the whole loop: no separate schema file to maintain by hand, but a full audit trail of every schema change in git history.