Sanity Studio schema deployment and GraphQL API synchronization
0 reputation · 22 Jan 2022, 08:00 UTC
Schema Validation and GraphQL Alignment
In Sanity CMS, schemas are defined in code and deployed as part of the Studio bundle. When schema changes occur—such as modifying field types or adding required constraints—these changes immediately affect the Studio UI validation. However, the GraphQL API schema is derived from the Studio schema and requires a separate deployment via sanity graphql deploy to remain synchronized.
A challenge arises when deploying breaking schema changes to a live dataset. Since Sanity does not provide a pre-deployment compatibility check to scan existing documents against a new schema, documents may become invalid upon deployment, surfacing validation errors in the Studio without prior warning.
Given that GraphQL deployments are decoupled from Studio deployments, there is uncertainty regarding the optimal sequence for ensuring zero-downtime API availability during a schema migration.
- How can a deployment pipeline ensure the GraphQL API is synchronized with the Studio schema without creating a window of query failures?
- Is there a mechanism to validate existing document compatibility against a proposed schema before the Studio bundle is deployed?