-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Description
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 or ImageWithAltText.
mediaModuleFull (Entity)
media: (Link: BackgroundVideo|ImageWithAltText)
mediaModuleHalf (Entity)
media: (Link: BackgroundVideo|ImageWithAltText)
When running gatsby develop, the above setup errors out with the following error message:
Error: Schema must contain unique named types but contains multiple types named "Union_media___NODE_ContentfulBackgroundVideo__ContentfulImageWithAltText"
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
- Create 4 types in Contentful,
mediaModuleFull,mediaModuleHalf,backgroundVideo,imageWithAltText` - Add a multi-reference field both
mediaModuleHalfandmediaModuleFull, namedmedia - Create 2 instances of
mediaModuleFull, one with abackgroundVideolinked inmedia, and 1 with aimageWithAltTextlinked inmedia. - Do the same for
mediaModuleFull. - Make sure all of this is fully published.
- Fire up a Gatsby project with
gatsby develop, which is connected to this Contentful space via thatgatsby-contentful-sourceplugin.
...