-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[gatsby-source-contentful] - Gatsby errors trying to create two Union types with the same name #3544
Comments
@Khaledgarbaya, FYI. Not sure if you've seen this. |
Hey @JasonStoltz, I will try to check it out soon, I've been crazy busy lately :( Best, |
Running into this too. I don't think it's to do with the multi-type single reference fields bug. This seems to occur when two different content types have fields that create the same union. I'm getting this error on a one-to-many reference, it's just that three different kinds of pages have the same type of one-to-many reference. |
I'm not that versed in Gatsby's internals, but I tried working with this a bit. Just reusing a single union type seemed to cause problems because descendants of the type could have duplicate names, so it seemed worth just having an increment value appended to the union type name. For the example in the issue, that would become I'm not sure if that has unintended consequences, but since the union type is internal from a Gatsby user's perspective, I was hoping it wouldn't cause problems to just change the name. |
@michaek if you want to fix this I would try wrapping name of created union type ( https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/schema/infer-graphql-type.js#L251 ) with |
@pieh That does the trick. Perhaps if it was called |
@pieh Is there some published process for how to consume a hotfixed lerna package? Since this issue is a showstopper for builds, I'd really like to avoid waiting for a merge and release of #4925. The elaborate build and release process Gatsby uses makes it kind of tricky to just plug in a hotfixed dependency via npm, which is what I would expect to be able to do. |
I didn't do anything like that but maybe this blog post will be helpful - https://medium.com/@denis.zhbankov/maintaining-a-fork-of-create-react-app-as-an-alternative-to-ejecting-c555e8eb2b63#1568 and then you would probably need to some tricks in package json to alias your package to gatsby so another temporary solution would be |
The The convenience of being able to just
until one's PR is accepted is pretty appealing. I understand the appeal of a monorepo and transpiled source from an author's perspective, but it can make things kind of cumbersome for a consumer. :) |
For what it's worth, I was just missing the
Where the tarball was generated with Sorry to everyone for this off-topic series of messages! |
Description
I have two Content Types in Contentful. They both have a
media
field that can be a Link to one of two types,BackgroundVideo
orImageWithAltText
.When running
gatsby develop
, the above setup errors out with the following error message:I believe the error stems from this: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/schema/infer-graphql-type.js#L318. There is no check here to see if this Union type already exists, it appears that it always attempts to create a new Union.
Environment
Gatsby version: 1.9.149
Node.js version: v8.9.4
Operating System: macOS 10.12.1
Actual result
An error is throw
Expected behavior
The Union already exists, so it is reused for this field.
Steps to reproduce
mediaModuleFull,
mediaModuleHalf,
backgroundVideo,
imageWithAltText`mediaModuleHalf
andmediaModuleFull
, namedmedia
mediaModuleFull
, one with abackgroundVideo
linked inmedia
, and 1 with aimageWithAltText
linked inmedia
.mediaModuleFull
.gatsby develop
, which is connected to this Contentful space via thatgatsby-contentful-source
plugin....
The text was updated successfully, but these errors were encountered: