Error deploying GraphQL schema on Netlify due to removal of type, resolved by understanding schema changes.
12 replies
Last updated: Feb 7, 2022
R
I just committed a change to my studio & gatsby site to include a new content type, added via a plugin. Locally, everything works. On Netlify, Studio builds correctly, but my Gatsby site not. I get this error and I have no clue what to do now:
Should I run with
10:04:41 PM: > sanity graphql deploy --playground 10:04:42 PM: Dataset: production 10:04:42 PM: Tag: default 10:04:42 PM: - Checking for deployed API 10:04:42 PM: β Checking for deployed API 10:04:42 PM: - Generating GraphQL schema 10:04:45 PM: β Generating GraphQL schema 10:04:45 PM: - Validating GraphQL API 10:04:45 PM: β Validating GraphQL API 10:04:45 PM: Found BREAKING changes from previous schema: 10:04:45 PM: - BlockOrMainImage was removed. 10:04:45 PM: Error: Dangerous changes found - falling back. Re-run the command with the `--force` flag to force deployment. 10:04:45 PM: at confirmValidationResult (/opt/build/repo/studio/node_modules/@sanity/core/lib/actions/graphql/deployApiAction.js:273:11) 10:04:45 PM: at deployApiActions (/opt/build/repo/studio/node_modules/@sanity/core/lib/actions/graphql/deployApiAction.js:157:15) 10:04:45 PM: at processTicksAndRejections (node:internal/process/task_queues:96:5) 10:04:45 PM: 10:04:45 PM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 10:04:45 PM: "build.command" failed 10:04:45 PM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
--force? How can I investigate to understand more what is going on here?
Feb 3, 2022, 9:09 PM
R
Hello
So Iβm quite firm I didnβt do anything with
user E
, I donβt think I removed a type at all. I have a single commit on ./studio/schemas/schema.js, a file which was generated via this template . My change of yesterday was adding a plugin which contributes a content type via the parts system and which I added to `./studio/schemas/objects/bodyPortableText.js`:
{ type: "github.gist", options: { hotspot: true }, },
BlockOrMainImage. Also, I have no idea which queries are run at the moment as my Gatsby setup also came from the mentioned blog template project. What should I do now?
Feb 4, 2022, 11:47 AM
R
When I search in my project setup for
BlockOrMainImage, I only found a partial match on line 176 in `web/.cache/schema.gql`:
union SanityBlockOrMainImage = SanityBlock | SanityMainImage
Feb 4, 2022, 12:00 PM
R
When I search in my project setup for
BlockOrMainImage, I only found a partial match on line 176 in `web/.cache/schema.gql`:
union SanityBlockOrMainImage = SanityBlock | SanityMainImage
Feb 4, 2022, 12:00 PM
A
The
Is your site currently live and in use? It seems unlikely you're querying for this type, so it's probably safe for you to deploy using
BlockOrMainImagetype is automatically generated when you deploy GraphQL. It seems that some underlying schema configuration changed, which means that combination of types no longer appears in your Sanity documents, so it's no longer being generated for you.
Is your site currently live and in use? It seems unlikely you're querying for this type, so it's probably safe for you to deploy using
--forceand then check out the site to make sure nothing's broken.
Feb 4, 2022, 12:33 PM
R
While the
MainImageis still in my schema, I donβt have a document yet which contains an actual image. So this field probably is empty or nonexistent in all of my content. Could that be the underlying reason?
Feb 4, 2022, 12:36 PM
A
I'm not an expert on the GraphQL generation system, but I believe the
Could I take a look at your schema definition?
SanityBlockOrMainImagetype will have to exist if your schema allows this combination. Even if none of your content currently uses this combination, it could do in the future, so it's important for your GraphQL types to support this combination.
Could I take a look at your schema definition?
Feb 4, 2022, 12:39 PM
R
My blog is in a private repo at the moment. Can I have your GH userhandle, then I can provide you access?
Feb 4, 2022, 12:41 PM
A
Sure! It's
juice49.
Feb 4, 2022, 12:43 PM
R
FYI, the plugin with content type I added is this self-made plugin: https://github.com/ringods/sanity-plugin-github
Feb 4, 2022, 12:47 PM
R
user E
I think I found it, and finally understand a lot better how more of the graphql generation works. Given I added a third content type option for my blog post body, the generated graphql union type changed from:union BlockOrMainImage = Block | MainImage
union BlockOrGithubGistOrMainImage = Block | GithubGist | MainImage
BlockOrMainImagewas removed, but not because I removed one of the existing content options, but because I added one. Wow, what an adventure was this. π
Feb 6, 2022, 5:20 PM
R
user E
I think I found it, and finally understand a lot better how more of the graphql generation works. Given I added a third content type option for my blog post body, the generated graphql union type changed from:union BlockOrMainImage = Block | MainImage
union BlockOrGithubGistOrMainImage = Block | GithubGist | MainImage
BlockOrMainImagewas removed, but not because I removed one of the existing content options, but because I added one. Wow, what an adventure was this. π
Feb 6, 2022, 5:20 PM
A
Aha! That makes sense. Nice debugging π.
The warning is a little difficult to understand at first... and scary if you're not sure why something has been removed.
The warning is a little difficult to understand at first... and scary if you're not sure why something has been removed.
Feb 7, 2022, 9:27 AM
Sanityβ build remarkable experiences at scale
The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.