How to avoid breaking changes when redeploying Sanity API
Good news - in the vast majority of cases, these warnings about breaking changes are not something you need to worry about!
What's Happening
These changes you're seeing (like BlogPost._id changed type from ID! to ID) are related to a schema correction Sanity made a while back. The GraphQL schema previously indicated that certain system fields (_id, _type, _createdAt, _updatedAt, _rev) were always present (marked with ! in GraphQL, meaning non-nullable). However, Sanity discovered this wasn't technically accurate - when document types are embedded inside other documents, these fields might not always be present.
The change from ID! to ID (and String! to String, DateTime! to DateTime) simply means these fields are now correctly marked as nullable in the GraphQL schema. This is a more accurate representation of how Sanity actually works.
Should You Be Concerned?
For most use cases, no. This is a correction to make the schema more accurate, not a change to your actual content or how Sanity functions. Your content hasn't changed, and the fields will still be present in your documents where they should be.
How to Handle This
You have two options:
Accept the change (recommended): Simply proceed with the deployment. The warnings are informing you of the schema change, but it's unlikely to cause issues with your existing queries.
Use the flag to keep old behavior: If you want to maintain the old non-nullable behavior, you can use the
--non-null-document-fieldsflag:
sanity graphql deploy --non-null-document-fieldsThis will deploy your GraphQL API with the system fields marked as non-nullable, just like before.
Why You're Seeing This Now
You mentioned not remembering modifying schemas this much - that's because you didn't! This change is on Sanity's side to correct how the GraphQL schema represents these system fields. It's appearing now because you're redeploying your GraphQL API, which triggers the schema comparison between your current deployment and the previous one.
Remember, the GraphQL API needs to be redeployed whenever you update your schema - it doesn't automatically update when you deploy your Studio. This is a normal part of the workflow, and these particular warnings are just Sanity being transparent about the schema corrections they've made.
Show original thread5 replies
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.