Closed kibagateaux closed 5 years ago
Mysteriously started working again today. Didn't update or reinstall packages, just checked out from master into the feature branch that had the problems as always and it worked. 🤷♂
Just wanted to second this, we are faced with this same issue now. It had been working before but now mysteriously broke. The quick fix for us was to rename one of the fields.
It seems like gatsby is not a big fan when two documents of the same content type have different types. In example above first value is array and second is a string.
I haven't touched this project or Gatsby in months but I believe Gatsby should handle different types by creating a GraphQL union of the two as mentioned here https://github.com/gatsbyjs/gatsby/issues/3535
I'm also seeing this in the prismic plugin as well.
Description
As far as I can tell it's an issue with the Gatsby
id
field generation in the contentful-plugin. Obviously one is generating an array of string and the other is just a string. I'm not familiar with the library at all but I think I've narrowed it down to this section of code innormalize.js
. Sometimes when I run build there are multiple items in the array, but most times it's only a single string.Not sure what caused this because everything was working last night and then this morning, after adding more
seo
content for testing, this error started occurring.I think this might be caused by the setup of my SEO module. In Contentful I have two different models for pages -
ContentfulPage
andContentfulArticlePage
. Both have a single-reference field with the same name/id ofseo
that points to mySEO
model. TheSEO
model also has a reference fieldseoPage
that points back to aContentfulPage
orContentfulArticlePage
for ease of querying in Gatsby and navigation in Contentful. ThisseoPage
field used to be single-reference but after hitting #3535 I converted it to a multi-reference with a 1 ref max.This error only occurs on
ContentfulPage
, I can still query theseo
field on myContentfulArticlePage
even though there are multiple pages of both that referenceSEO
modules.seo works on
ContentfulArticlePage
seo DOES NOT work on
ContentfulPage
This leads me to believe that it is something wrong with the plugin and not my content model but I can't be sure.
Maybe important detail - all SEO modules are in a 1-1 relationship with a page. They are not referenced multiple times.
Seeing as this is an error generating from an automated process in the plugin, are there any suggestions for a workaround? This error is preventing any builds from succeeding so it's a big blocker.
I looked through #15344 and nothing helped :/
Steps to reproduce
Not sure what is actually causing this but here is what I did with the SEO module which appears to be the trigger.
parent1
andparent2
child
that has a multi-reference field. Add validation rules to this field so it can only select typesparent1/2
and at most 1 referenceparent1
andparent2
calledchild
that only acceptschild
typeschild
s that reference both parent typesExpected result
Auto generated schema types to be consistent for each content type.
Actual result
Inconsistent types for standard GraphQL field causes build to fail.
Environment