Skip to content
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

'Error: Schema must contain uniquely named types but contains multiple types named "GatsbyImageLayout" #122

Closed
3200pro opened this issue May 6, 2021 · 9 comments

Comments

@3200pro
Copy link

3200pro commented May 6, 2021

Hi Sanity,

Ran into this error today while using gatsby-source-shopify and gatsby-source-sanity at the same time:

Missing onError handler for invocation 'building-schema', error was 'Error: Schema must contain uniquely named types but
contains multiple types named "GatsbyImageLayout".'.

Removing either the shopify or sanity plugin from gatsby-config removes the error. I looked for a solution for a while and here's a similar scenario that happened while someone was using the contentful plugin alongside the shopify plugin:

Problem the had: Development build fails if I have both gatsby-source-contentful and gatsby-source-shopify-experimental enabled but succeeds if I drop either from gatsby-config.js.

Gatsby's Answer: The problem arises when two different source plugins are using gatsby-plugin-image

Their Solution: This is actually a bug in gatsby-source-contentful, rather than this plugin. I've opened a PR which should fix it.

Source:
gatsbyjs/gatsby-source-shopify#65

PR he mentioned
gatsbyjs/gatsby#30834

@alainkaiser
Copy link

Hi sanity, hi @3200pro

I have the exact same issue and created a bug at "gatsby-source-shopify" but i am not sure which plugin is the source of the error.

Also noticed the already created issues at "gatsby-source-shopify" which @3200pro mentioned.

My bug description:

gatsbyjs/gatsby-source-shopify#137

Would be helpful if we could resolve this issue together as i am stuck at the moment.

Thanks in advance for the help!

@3200pro
Copy link
Author

3200pro commented May 7, 2021

@alainkaiser ,

Based on the PR at contentful, my guess is that it's a Sanity issue that needs to be corrected.

@3200pro
Copy link
Author

3200pro commented May 7, 2021

I dug into a bit just now and I think the change on Sanity's end may need to be in:

/node_modules/gatsby-source-sanity/src/images/extendImageNode.ts

Looking at the PR for contentful there are a fair amount of similarities in each file. My guess is Sanity is reusing the GatsbyImageLayout from gatsby-plugin-image without renaming it.

@alainkaiser
Copy link

Any new on this one? @3200pro Did you manage to get it work somehow (workaround)?

@geball
Copy link

geball commented May 10, 2021

Setting options.downloadImages: true in the gatsby-source-shopify configuration seems to permit the build, though it definitely remains a workaround and not a solution.

@tizzle
Copy link

tizzle commented Aug 23, 2021

Hi, is this being worked on? I think this is quite important to fix, as the workaround from @geoffreyjball works, but is not good for builds on e.g. Netlify which are time-constrained on free tiers. Downloading the images bloats the build process unnecessarily imho.

Best regards

@explorador
Copy link

This was fixed here: gatsbyjs/gatsby#32544
Just update gatsby and gatsby-plugin-image to the latest.
It works at least in version 3, not sure about v4

@SimeonGriggs
Copy link

SimeonGriggs commented Nov 3, 2021

I've just resolved this by:

  1. Installing gatsby-plugin-image (even if you don't use it)
  2. Adding gatsby-plugin-image to plugins in gatsby-config.js

@3200pro 3200pro closed this as completed Nov 3, 2021
@Jxmedia
Copy link

Jxmedia commented Feb 26, 2024

I've just resolved this by:

  1. Installing gatsby-plugin-image (even if you don't use it)
  2. Adding gatsby-plugin-image to plugins in gatsby-config.js

This worked for me as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants