Structured Content 2022: Join our conference to explore fresh perspectives on content and digital experiences →

How to avoid breaking changes when redeploying Sanity API

5 replies
Last updated: Feb 8, 2021

Hello again! I went to re-deploy my api and got a lot of warnings re: dangerous changes. Should I be concerned about these? Is there a specific reason these would all be changing like this? I don’t remember modifying the schemas this much. Here’s a sample:
Found BREAKING changes from previous schema:
- BlogPost._id changed type from ID! to ID.
- BlogPost._type changed type from String! to String.
- BlogPost._createdAt changed type from DateTime! to DateTime.
- BlogPost._updatedAt changed type from DateTime! to DateTime.
- BlogPost._rev changed type from String! to String.
- Document._id changed type from ID! to ID.
- Document._type changed type from String! to String.
- Document._createdAt changed type from DateTime! to DateTime.
- Document._updatedAt changed type from DateTime! to DateTime.
- Document._rev changed type from String! to String.
- SanityImageAsset._id changed type from ID! to ID.
- SanityImageAsset._type changed type from String! to String.
- SanityImageAsset._createdAt changed type from DateTime! to DateTime.
- SanityImageAsset._updatedAt changed type from DateTime! to DateTime.
[….]

Feb 8, 2021, 9:59 PM

Hi Stu!
In the vast majority of cases this particular change is not something you should be worried about.

A while back we discovered that the schema incorrectly said that these fields were "always" present - but that people were embedding document types inside of other documents, which makes that assumption false (in those cases).

Feb 8, 2021, 10:08 PM

We added a flag to let you get the old behavior back, should you not want the change - add the

--non-null-document-fields
flag to the command. Eg:

sanity graphql deploy --non-null-document-fields

Feb 8, 2021, 10:10 PM

Ok, good to know - thanks a lot!

Feb 8, 2021, 10:10 PM

We added a flag to let you get the old behavior back, should you not want the change - add the

--non-null-document-fields
flag to the command. Eg:

sanity graphql deploy --non-null-document-fields

Feb 8, 2021, 10:10 PM

Hi Stu!
In the vast majority of cases this particular change is not something you should be worried about.

A while back we discovered that the schema incorrectly said that these fields were "always" present - but that people were embedding document types inside of other documents, which makes that assumption false (in those cases).

Feb 8, 2021, 10:08 PM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.