Gatsby: ERROR #85901 GRAPHQL

Created on 3 Jul 2019  ·  39Comments  ·  Source: gatsbyjs/gatsby

Description

Updated to the latest version of gatsby 2.13.1 and started getting the following error after running gatsby develop.

ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

Error: RelayParser: Encountered duplicate defintitions for one or more documents: each document must have a unique name. Duplicated documents:
- SiteTitleQuery

I was able to fix this issue after removing gatsby-plugin-mailchimp

Apparently the mailchimp examples are creating a problem.

Just wanted to let everyone else know.

help wanted confirmed bug

Most helpful comment

@darrencarlin Not ideal, but this probably happens if you have 0 assets/images - as a workaround you might try adding dummy image there (that you don't have to use)

All 39 comments

Getting the same error, too. However, I don't have gatsby-plugin-mailchimp in my website

It could be another plugin, I searched my entire project for "SiteTitleQuery" and gatsby-plugin-mailchimp was the only result.

I think this is related to https://github.com/gatsbyjs/gatsby/pull/15284, let me see if I can put a repro together quickly.

cc @sidharthachatterjee repro here: https://github.com/m-allanson/gatsby-issue-15344

steps:

  • clone repo
  • yarn
  • yarn start

This is the hello-world starter with gatsby-plugin-mailchimp added. I've seen similar with the Algolia plugin. This seems to happen with plugins that ship example code, as it's also triggering the Using the global "graphql" tag is deprecated warning.

success update schema - 0.018 s
warn Using the global `graphql` tag is deprecated, and will not be supported in v3.
Import it instead like:  import { graphql } from 'gatsby' in file:
/Users/mike/d/temp/gatsby-issue-15344/node_modules/gatsby-plugin-mailchimp/examples/gatsby-v1/src/layouts/index.js

 ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

Error: RelayParser: Encountered duplicate defintitions for one or more documents: each document must have a unique name. Duplicated documents:
- SiteTitleQuery

success extract queries from components - 5.726 s

A quick fix might be to exclude example or examples dirs from being parsed? That might cause more problems than it solves though...

getting this error after updating gatsby

I am getting the same error when deploying my gatsby site on Netlify, none of the usual steps (npm install, deleting suspicious packages, clearing cache, ...) fixed this...

12:48:51 PM: error #85901 GRAPHQL 12:48:51 PM: There was an error in your GraphQL query: 12:48:51 PM: Unknown type "ImageSharpFixed".

This is occurring because some packages happen to ship example code (that includes queries). And we now parse node_modules to support queries in dependencies and themes since https://github.com/gatsbyjs/gatsby/pull/15284

The correct fix for this is for packages to add examples to .npmignore

I'm fixing gatsby-plugin-mailchimp and gatsby-plugin-algolia right now and writing a script to find more plugins in the wild that need to the resolved.

In the mean time, @javidhsueh @bogdancss @spookyMilly can you please post your gatsby info results so we can find the packages that are causing this for you and fix!

Edit: Fixes for gatsby-plugin-mailchimp and gatsby-plugin-algolia are open in https://github.com/benjaminhoffman/gatsby-plugin-mailchimp/pull/40 and https://github.com/algolia/gatsby-plugin-algolia/pull/31

am getting the same error when deploying my gatsby site on Netlify, none of the usual steps (npm install, deleting suspicious packages, clearing cache, ...) fixed this...

12:48:51 PM: error #85901 GRAPHQL 12:48:51 PM: There was an error in your GraphQL query: 12:48:51 PM: Unknown type "ImageSharpFixed".

@spookyMilly This should be fixed by updating gatsby-transformer-sharp to 2.2.1

Thank you so much for your help, @pieh and @sidharthachatterjee ! I updated gatsby-transformer-sharp to version 2.2.1, but got this error on deployment:

Error: Found vendored libvips v8.7.0 but require v8.7.4. Please remove the 'node_modules/sharp/vendor' directory and run 'npm install'.

Also this occured after running gatsby build:

The dependency "sharp" does not seem to have been built or installed correctly. (...) Library not loaded: @rpath/libvips-cpp.dylib (...) Reason: image not found

Here is my gatsby info, as requested by @sidharthachatterjee
System:

OS: macOS 10.14.4
CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
Shell: 3.2.57 - /bin/bash

Binaries:

Node: 11.10.1 - /usr/local/bin/node
Yarn: 1.16.0 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm

Languages:

Python: 2.7.10 - /usr/bin/python

Browsers:

Chrome: 75.0.3770.100
Firefox: 67.0.4
Safari: 12.1

npmPackages:

gatsby: ^2.4.0 => 2.4.0 
gatsby-cli: ^2.5.12 => 2.5.12 
gatsby-image: ^2.0.33 => 2.0.33 
gatsby-plugin-google-analytics: ^2.0.17 => 2.0.17 
gatsby-plugin-manifest: ^2.0.24 => 2.0.24 
gatsby-plugin-netlify: ^2.0.13 => 2.0.13 
gatsby-plugin-offline: ^2.0.25 => 2.0.25 
gatsby-plugin-react-helmet: ^3.0.9 => 3.0.9 
gatsby-plugin-sass: ^2.0.11 => 2.0.11 
gatsby-plugin-sharp: ^2.0.35 => 2.0.35 
gatsby-plugin-styled-components: ^3.0.7 => 3.0.7 
gatsby-source-filesystem: ^2.0.24 => 2.0.24 
gatsby-transformer-sharp: ^2.2.1 => 2.2.1

Again, thank you so much. Hope this is useful for you guys.

Hello again, sorry for the duplicate post, but I found a solution to the #85901 GRAPHQL error. Maybe this is helpful for others.

  • I updated gatsby-transformer-sharp to 2.2.1.
  • I removed sharp from the node_modules directory and re-installed it.
  • I checked my dependencies via npm list sharp, updated the packages that were listed, including gatsby-plugin-sharp and gatsby-transformer-sharp, and now gatsby build is successful and all deployments on Netlify are working as before.

Now everything is working fine again. 😆 Thanks again guys. Hope this helps you

[email protected] is out with the fix! Thanks to @Haroenv ❤️

I am also getting this error now, seems like its trying to 'query a query" within fragment.js in gatsby-source-contentful node_modules as if its a static query in one of my components.

If I comment out that entire file it works locally but not when deploying to netlify.

@darrencarlin Not ideal, but this probably happens if you have 0 assets/images - as a workaround you might try adding dummy image there (that you don't have to use)

@pieh That sorted it! Thank you.

I'm also seeing this issue on Netlify, the npm modules from gatsby info are:

npmPackages:
gatsby: ^2.3.22 => 2.3.22
gatsby-plugin-google-analytics: ^2.0.18 => 2.0.18
gatsby-plugin-hotjar: ^1.0.1 => 1.0.1
gatsby-plugin-sass: ^2.0.11 => 2.0.11
gatsby-source-contentful: ^2.0.48 => 2.0.48
gatsby-source-filesystem: ^2.0.29 => 2.0.29
gatsby-transformer-remark: ^2.3.8 => 2.3.8

Probably the contentful plugin, given the error messages in the netlify deploy log:
...
error #85901 GRAPHQL
10:36:30 PM: There was an error in your GraphQL query:
10:36:30 PM: Unknown type "ContentfulFixed". Did you mean "ContentfulJob", "ContentfulJobEdge", "ContentfulContentType", "ContentfulJobFieldsEnum", or "ContentfulJobFilterInput"?
10:36:30 PM: File: node_modules/gatsby-source-contentful/src/fragments.js:4:37
...

same problem, need a solution:

There was an error in your GraphQL query:
Unknown type "ContentfulFixed"

and in gatsby-transformer-sqip:
found 2 vulnerabilities (1 moderate, 1 high) in 38634 scanned packages

Probably the contentful plugin, given the error messages in the netlify deploy log:
...
error #85901 GRAPHQL
10:36:30 PM: There was an error in your GraphQL query:
10:36:30 PM: Unknown type "ContentfulFixed". Did you mean "ContentfulJob", "ContentfulJobEdge", "ContentfulContentType", "ContentfulJobFieldsEnum", or "ContentfulJobFilterInput"?
10:36:30 PM: File: node_modules/gatsby-source-contentful/src/fragments.js:4:37
...

Same here!

Edit/Update:

Still not sure what the issue exactly caused, but I reinstalled gatsby-source-contentful and gatsby itself from the latest version to:

"gatsby-source-contentful": "^2.0.41", and "gatsby": "^2.9.10",

worked for me!

I have the same problem after updating gatsby to 2.13.3 version.
I have two custom themes which are submodules in my main git project. One theme is using gatsby-source-datocms plugin. Any solution for this?

More info:

Main project:
```
System:
OS: macOS 10.14.5
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.14.2 - /usr/local/bin/node
Yarn: 1.16.0 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 75.0.3770.100
Firefox: 66.0.3
Safari: 12.1.1
npmPackages:
gatsby: ^2.13.3 => 2.13.3
gatsby-theme-datocms: * => 0.1.0
gatsby-theme-ui: * => 0.0.1
npmGlobalPackages:
gatsby-cli: 2.4.8

and `gatsby-theme-datocms` theme's dependencies
"gatsby-theme-ui": "*",
"gatsby": "^2.13.3",
"gatsby-image": "^2.2.4",
"gatsby-plugin-manifest": "^2.2.1",
"gatsby-plugin-offline": "^2.2.0",
"gatsby-plugin-react-helmet": "^3.1.0",
"gatsby-plugin-react-svg": "^2.1.1",
"gatsby-plugin-robots-txt": "^1.4.0",
"gatsby-plugin-sass": "^2.1.0",
"gatsby-plugin-sharp": "^2.2.2",
"gatsby-plugin-sitemap": "^2.2.1",
"gatsby-source-filesystem": "^2.1.2",
"gatsby-source-datocms": "^2.1.13",
"gatsby-transformer-sharp": "2.2.1",
"node-sass": "^4.12.0",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-css-modules": "^4.7.11",
"react-helmet": "^5.2.1"

```

Thanks @kerminz
Changing to those exact versions, without the caret in the version number, worked for me:

"gatsby-source-contentful": "2.0.41", and "gatsby": "2.9.10"
rather than
"gatsby-source-contentful": "^2.0.41", and "gatsby": "^2.9.10",

I tried using the versions with the caret but that didn't help.

That will do for a temporary fix to get my site back updating until I work out a proper fix.

I removed operations names from queries yesterday and I thought that fixed the issue but after proper testing this morning I found out that solution is not working. I'm getting more queries related errors.

I've created a minimal example to replicate ERROR #85901 GRAPHQL error. Gatsby starter + theme + site query
https://github.com/marcinsydor/gatsby-starter-default.git

Hello there,

I got this problem after trying to add documentation with docz in my project.
I typed npm install --save gatsby-theme-docz docz docz-theme-default and here comes the error.
If I uninstall gatsby-theme-docz, the project compiled without trouble.

I can also confirm this is still an issue in version 2.13.x Downgrading
Gatsby to strict version 2.9.10 seemed to temporarily fix the issue.

@andrewlsimplisafe I can use up to Gatsby 2.11.7 and avoid this error.

Also, I use none of the plugins mentioned above:


gatsby info

  System:
    OS: macOS 10.14.5
    CPU: (4) x64 Intel(R) Core(TM) i5-5287U CPU @ 2.90GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 11.6.0 - ~/.nvm/versions/node/v11.6.0/bin/node
    Yarn: 1.12.3 - ~/.nvm/versions/node/v11.6.0/bin/yarn
    npm: 6.5.0-next.0 - ~/.nvm/versions/node/v11.6.0/bin/npm
  Languages:
    Python: 2.7.10 - /usr/bin/python
  Browsers:
    Chrome: 75.0.3770.100
    Firefox: 67.0.4
    Safari: 12.1.1
  npmPackages:
    gatsby: ^2.11.7 => 2.11.7
    gatsby-image: ^2.2.4 => 2.2.4
    gatsby-link: ^2.2.0 => 2.2.0
    gatsby-plugin-gtag: ^1.0.11 => 1.0.11
    gatsby-plugin-mailchimp:
https://github.com/benjaminhoffman/gatsby-plugin-mailchimp.git#gatsby-v2 =>
3.3.0
    gatsby-plugin-manifest: ^2.2.1 => 2.2.1
    gatsby-plugin-offline: ^2.2.0 => 2.2.0
    gatsby-plugin-react-helmet: ^3.1.0 => 3.1.0
    gatsby-plugin-react-helmet-canonical-urls: ^1.2.0 => 1.2.0
    gatsby-plugin-remove-serviceworker: ^1.0.0 => 1.0.0
    gatsby-plugin-remove-trailing-slashes: ^2.1.0 => 2.1.0
    gatsby-plugin-sass: ^2.1.0 => 2.1.0
    gatsby-plugin-sharp: ^2.2.2 => 2.2.2
    gatsby-plugin-sitemap: ^2.2.1 => 2.2.1
    gatsby-plugin-webpack-bundle-analyzer: ^1.0.5 => 1.0.5
    gatsby-source-filesystem: ^2.1.2 => 2.1.2
    gatsby-source-prismic: ^2.2.0 => 2.2.0
    gatsby-transformer-sharp: ^2.2.1 => 2.2.1
    gatsby-transformer-sqip: 2.1.4 => 2.1.4

Started getting the same error after updating to Gatsby 2.13.0

Thanks for the repro @marcinsydor 👍 I can confirm the issue is fixed in your repro by updating to latest gatsby and plugins. However, after the update there's a new warning message.

cc @sidharthachatterjee

success update schema - 0.021 s
warn The GraphQL query in the non-page component
Exported queries are only executed for Page components. It's possible you're
trying to create pages in your gatsby-node.js and that's failing for some
reason.

If the failing component(s) is a regular component and not intended to be a page
component, you generally want to use a <StaticQuery> (https://gatsbyjs.org/docs/static-query)
instead of exporting a page query.

If you're more experienced with GraphQL, you can also export GraphQL
fragments from components and compose the fragments in the Page component
query and pass data down into the child component — http://graphql.org/learn/queries/#fragments
success extract queries from components - 0.230 s

Hey @m-allanson. I also tried the last Gatsby version but like you and I had got the same warnings. I did not have time to investigate in it then. But now I can say we have that message because of two index.js pages. One in the theme and one in the main project. To fix it work I need to add gatsby-plugin-page-creator plugin to the theme and rename index.js to theme-index.js. You can check it in my updated repo.

I'm not sure what Gatsby should do in that scenario. Maybe we should get warning the index.js page exists in theme and we should override it in gatsby-theme-starter/src/pages folder?

I'm also not clear why I need to add gatsby-plugin-page-creator plugin for pages in the theme. I thought all the js pages are created automatically from that folder? @sidharthachatterjee, can you give us some clarification about this?

I met the same error.
The problem is because I was using Hyper terminal in windows.
Solution is using the default terminal in windows.

I'm having this issue on [email protected]+ also, same as @andrewlsimplisafe I went back to [email protected] and all ok, for now.

T.Hanks

System:
OS: Linux 5.0 Ubuntu 19.04 (Disco Dingo)
CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
Shell: 5.0.3 - /bin/bash
Binaries:
Node: 10.10.0 - /tmp/yarn--1563253924944-0.6676510842109993/node
Yarn: 1.16.0 - /tmp/yarn--1563253924944-0.6676510842109993/yarn
npm: 6.4.1 - ~/n/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Firefox: 68.0
npmPackages:
gatsby: 2.12.0 => 2.12.0
gatsby-plugin-catch-links: ^2.0.9 => 2.1.2
gatsby-plugin-favicon: ^3.1.6 => 3.1.6
gatsby-plugin-google-analytics: 2.1.4 => 2.1.4
gatsby-plugin-manifest: 2.2.3 => 2.2.3
gatsby-plugin-netlify: ^2.0.6 => 2.1.3
gatsby-plugin-netlify-cms: 4.1.6 => 4.1.6
gatsby-plugin-offline: 2.2.4 => 2.2.4
gatsby-plugin-react-helmet: 3.1.2 => 3.1.2
gatsby-plugin-remove-serviceworker: ^1.0.0 => 1.0.0
gatsby-plugin-robots-txt: 1.5.0 => 1.5.0
gatsby-plugin-sharp: 2.2.7 => 2.2.7
gatsby-plugin-sitemap: 2.2.3 => 2.2.3
gatsby-plugin-styled-components: 3.1.2 => 3.1.2
gatsby-remark-autolink-headers: 2.1.3 => 2.1.3
gatsby-remark-external-links: 0.0.4 => 0.0.4
gatsby-remark-smartypants: ^2.0.9 => 2.1.2
gatsby-source-filesystem: 2.1.5 => 2.1.5
gatsby-source-graphql: 2.1.2 => 2.1.2
gatsby-transformer-remark: 2.6.6 => 2.6.6
gatsby-transformer-sharp: 2.2.3 => 2.2.3

I fixed my issue, for me it was a configuration issue :man_facepalming:

I didn't have gatsby-plugin-sharp & gatsby-transformer-sharp added to my transformer-remark plugins array.

I had the same problem and solved by deleting the files that resulted in errors and recreating them with different names. Apparently git was pushing both the uppercase and lowercase files (Eg: Opening and opening), resulting in the aforementioned error.

@darrencarlin Not ideal, but this probably happens if you have 0 assets/images - as a workaround you might try adding dummy image there (that you don't have to use)

After uploading the image, a new error has appeared.

ERROR #85907 GRAPHQL
There was an error in your GraphQL query:

  • Unknown field 'file' on type 'Query'.
    File: src/components/image.js

It happens when you use contentful as your CMS, as it forcefully creates image asset in the node modules folder. one needs to add a dummy image to the Media section in the contentful web application, further, if there are image manipulation plugins like gatsby-transformer-remark, gatsby-plugin-sharp or similar, you need to take care of that, as gatsby throws an exception by default in the most newer versions !!

Looks like this is safe to close since the original issue was resolved (as I commented above) and the rest look like unrelated (but similar looking) issues that folks have figured out fixes for.

Let's close this! Thank you everyone 🙌

@pieh Amazing.

If anyone was wondering what they meant by "adding dummy image there", follow these steps:

  1. Login to Contenify
  2. On the top navigation, select Media
  3. Upload any asset (I uploaded a 100px by 100px white square)
  4. Try rebuilding, and it just works

I have so many questions, but already wasted enough time on this to try to understand why that matters.

@pieh Amazing.

If anyone was wondering what they meant by "adding dummy image there", follow these steps:

  1. Login to Contenify
  2. On the top navigation, select Media
  3. Upload any asset (I uploaded a 100px by 100px white square)
  4. Try rebuilding, and it just works

I have so many questions, but already wasted enough time on this to try to understand why that matters.

Thanks for this answer. I'm currently trying to do this, but when I attempt any image upload, getting "An error occurred while uploading your asset.", no matter what image I upload.
Hopefully contentful will resolve that very soon. ( might be a corporate firewall though, too,.. so I'm going to try connecting to their guest wifi here ).
Edit: dang, that was it. ( shouldn't be working on their time anyway )

Spent an embarassing amount of time with this issue, when all it took to resolve was:

npm install [email protected]

i ran npm outdated to see that gatsby-plugin-mailchimp was red and needed to be updated.

It happens when you use contentful as your CMS, as it forcefully creates image asset in the node modules folder. one needs to add a dummy image to the Media section in the contentful web application, further, if there are image manipulation plugins like gatsby-transformer-remark, gatsby-plugin-sharp or similar, you need to take care of that, as gatsby throws an exception by default in the most newer versions !!

This worked just great for me. Thanks! @abhinav-anshul

@darrencarlin Not ideal, but this probably happens if you have 0 assets/images - as a workaround you might try adding dummy image there (that you don't have to use)

Adding a dummy image in contentful web app worked for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

magicly picture magicly  ·  3Comments

rossPatton picture rossPatton  ·  3Comments

Oppenheimer1 picture Oppenheimer1  ·  3Comments

mikestopcontinues picture mikestopcontinues  ·  3Comments

kalinchernev picture kalinchernev  ·  3Comments