GraphQL Schema-Driven Codegen: Drift Between SDL and Generated Types
0 reputation · 11 Jan 2021, 21:21 UTC
Schema Source of Truth in Repeatable Environments
Maintaining a repeatable development environment for GraphQL often relies on schema-driven code generation. When using a Schema Definition Language (SDL) file or introspection results to generate client-side types, a discrepancy can emerge between the declared schema and the committed artifacts.
In a CI/CD pipeline, the source of truth may shift between a checked-in schema.graphql file, a live introspection query against a development server, or the generated type definitions themselves. This creates uncertainty regarding how to detect drift when server-side changes—such as field deprecations or custom scalar modifications—occur without a corresponding update to the client's generated types.
If generated types are committed to the repository, there is a risk that reviewers may approve changes where the client types no longer align with the server's actual implementation, leading to runtime failures despite successful compilation.
- What is the most reliable method to ensure the schema used for local code generation remains synchronized with the deployed server across different environments?
- How can a CI process deterministically verify that committed generated types are byte-identical to those produced from the current pinned SDL?