Gatsby: RootQueryType.allSitePage field type must be Output Type but got: SitePageConnection.

Created on 2 Sep 2017  Â·  32Comments  Â·  Source: gatsbyjs/gatsby

Got the following error when trying to build my project on Netlify (haven't been able to replicate locally):

Error: RootQueryType.allSitePage field type must be Output Type but got: SitePageConnection.

- Array.forEach

- Array.reduce

- index.js:54 _callee$
[repo]/[gatsby]/dist/schema/index.js:54:20

Just updated my gatsby version (didn't work with 1.6.X either), so these are my current gatsby dependencies:

  "gatsby": "^1.9.21",
    "gatsby-link": "^1.6.16",
    "gatsby-plugin-react-helmet": "^1.0.6",
    "gatsby-plugin-sass": "^1.0.10",
    "gatsby-plugin-sitemap": "^1.2.5",
    "gatsby-plugin-styled-components": "^1.0.5",
    "gatsby-source-contentful": "^1.3.7",
    "gatsby-source-filesystem": "^1.4.11",
    "gatsby-transformer-toml": "^1.1.4",

Any idea as to what can cause this on Netlify but not locally? And optimally a hint on how to fix it 🗡

UPDATE:

I found a way to replicate this locally. If I update the graphql version to the latest one it happens.
And the problem externally seemed to be my node version. It failed when running Node 6.X, but works with Node 8.X

Most helpful comment

I came across this issue when erroneously thinking I may have to additionally install graphql. Silly of me, but it would still be nice if running an innocent "npm install graphql" in a gatsby project wouldn't kill it the way it did.

Working on a gatsby-example-site starter.

What solved it for me:
npm remove graphql
npm install gatsby

All 32 comments

This is usually (always) due to having more than one copy of graphql installed in your dependency tree, which it really hates. We should have a page about fixing it tho

What about throwing a more specific error if that's the case? It seems this causes a multitude of errors, that take quite a bit of time to debug. Could scan node_modules for multiple graphql versions and abort the build if that's the case

Better errors would be great. I'm not sure if it's gonna be efficient to try and scan for instances but we could definitely have a more useful error. Feel free to jump in with a PR as well

Running find node_modules -iname graphql outputs the following in my case:

node_modules/@playlyfe/gql/node_modules/graphql
node_modules/@types/graphql
node_modules/apollo-codegen/node_modules/graphql
node_modules/graphql
node_modules/graphql-language-service-interface/node_modules/graphql
node_modules/graphql-language-service-types/node_modules/graphql
node_modules/graphql-language-service-utils/node_modules/graphql

right now I don't have any errors I know of. But would any of these potentially posing a problem?

I'll close since the base issue was resolved

@Aleksion How was the base issue resolved? Getting the same problem, but can't seem to get rid of it.

@jquense I've tried everything, but this is still plaguing me.

@mboudreau - I believe I played around with my different graphql dependencies. The biggest sinner I found was when I was trying to use Relay. I never got that working. But apollo did.

The problem was, that when I added or removed a dependency, I needed to completely delete the cache folder and public folder to verify whether it helped. The easiest way to test it is to remove all your graphql related dependencies and add them back one by one. And make sure to clear your cache EVERY TIME

@mboudreau - and the issue is back for me. I'm debugging with netlify's docker build image, since I can get a completely clean install every time. But it's slow as hell.

My current approach is:

  • Remove all pages
  • Remove all plugins
    And add them one by one

  • And experiment with different gatsby dependency versions.

Doing one thing at a time every time. But honestly, this issue has now cost quite a few days of development. Mainly because it tends to happen seldom enough that the reason for it is completely unclear. So I'm seriously considering ditching an otherwise really great framework. Or at least cut my use down (right now it's running both the marketing page and the app).

Checkout what reactjs.org does in "resolutions" https://github.com/facebook/react/blob/master/www/package.json

Our hands are a bit tied here until upstream fixes things.

You can also try and make sure all your graphql packages are on the same version as generally this problem arrives when they get out of sync.

Just to give an update: I'm testing out your suggestion, and i have a feeling it might work. But Yarn 1.0 doesn't work on Netlify yet, so I have to resolve that first.

Bah, I've stopped using Gatsby because of the extreme amount of errors
setting up. Can't say I'm a fan of all the magic happening behind the
scenes. I wasted too many days getting it working and not getting my
website done.

On Tue., 10 Oct. 2017, 7:56 am Aleksander, notifications@github.com wrote:

Just to give an update: I'm testing out your suggestion, and i have a
feeling it might work. But Yarn 1.0 doesn't work on Netlify yet, so I have
to resolve that first.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/2001#issuecomment-335285547,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAjA5Cy6L33_e4q1rdcXepKOcQFZpW70ks5sqoiOgaJpZM4PK9OS
.

@Aleksion yeah, wasted a number of hours on the Yarn / Netlify thing myself :-( BTW, is the resolutions thing a Yarn 1+ feature? https://yarnpkg.com/lang/en/docs/selective-version-resolutions/

@mboudreau you consistently ran into this problem? E.g. on starters you saw it as well? Sorry you had troubles :-( @jquense has a PR in graphql-js to fix this problem so hopefully they'll merge it soon. It's bit me a number of times too.

@KyleAMathews I could never get past this particular error, so I dropped it, but there were many others.

All I wanted to do is have a website that used typescript and TSX for templating, but graphql had other ideas. Can't say I'm a fan of all the magic happening without knowing what's going on, or imports not being added because it's some weird webpack compilation step. Even when I look at the base project, I couldn't understand why there wasn't a compilation issue with a lot of things since of the lacking imports...

@KyleAMathews yeah I think it is: https://code.facebook.com/posts/274518539716230/announcing-yarn-1-0/

Regarding the Yarn issue, I'm not getting it with a gatsby starter project. But I am getting it with my typescript gatsby project.

Really looking forward to the graphql-js fix. Because I'm with @mboudreau on this on. Being blocked by "hard to debug" magic is frustrating.

This shouldn't be seen as a rant though. I really appreciate all the hard work you and the contributors have put into this project. I realize projects like these are only as good as the contributions made by it's users. And you spun out an incredible set of features for the 1.0 release.

So it is only what could be expected. And as soon as I have a few extra hours again, I'll do what I can to give back to the project!

as soon as I have a few extra hours again, I'll do what I can to give back to the project!

Sweet! Yeah, there's no way I could have built Gatsby by myself. Gatsby is only pretty good cause there's 300+ contributors.

I'm having this error, and not using yarn. So yeah, this really should be handled :-/

This is happening to me in yarn 1.2.1. My project is pretty simple and I'm not sure what triggered it. I just removed node_modules and use npm instead (on 5.5.1) and gatsby develop works. Not ideal, but no longer getting the error.

I modified gatsby by creating a index.js that just does exports.graphql = require('graphql'), and changed my plugins from requiring graphql to const { GraphQLString } = require('gatsby').graphql, and that solved the problem.

Is there a reason error might throw outside of the duplicate graphql dependencies?

I've been trying to pinpoint the Gatsby version where my build started breaking w/ a different error (https://github.com/gatsbyjs/gatsby/issues/2796), but so far I keep hitting the same error as OP:

RootQueryType.allSitePage field type must be Output Type but got: SitePageConnection.

But when I run yarn why graphl, I don't see anything outside of gatsby:

yarn why v1.2.1
[1/4] Why do we have the module "graphql"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
info Has been hoisted to "graphql"
info Reasons this module exists
   - "gatsby" depends on it
   - "gatsby#relay-compiler" depends on it
Done in 0.90s.

I should note that this error stops if i upgrade to >= 1.9.89, as my build breaks diff't ways depending on the Gatsby version. I've yet to do a proper git bisect, but here are some versions where the nature of the break seems to shift (not sure if germane to OP, but since it's throwing same err at certain versions, figured I'd include):

1.9.9 - feelin' fine, all systems go.

v1.9.50 , 1.9.75, and 1.9.85:
OP error (Error: RootQueryType.allSitePage field type must be Output Type but got: SitePageConnection.)

v1.9.88: Build completes! But, no queried data loads:
GraphQL Error There was an error while compiling your site's GraphQL queries.

1.9.90 - 1.9.108: aforementioned other error (memory leak after "extract queries from components")

try yarn list graphql you'll see two i'm pretty certain. There is a theoretical chance the error is legitimate but its very unlikely considering the types are defined by plugins we understand

Oh interesting--here's results @ Gatsby 1.9.50:

$ yarn list graphql
yarn list v1.2.1
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ [email protected]
│  └─ [email protected]
└─ [email protected]
Done in 0.88s.


$ yarn why graphql-skip-limit
yarn why v1.2.1
[1/4] Why do we have the module "graphql-skip-limit"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
info This module exists because "gatsby" depends on it.
info Disk size without dependencies: "1.1MB"
info Disk size with unique dependencies: "4.83MB"
info Disk size with transitive dependencies: "6.41MB"
info Number of shared dependencies: 5
Done in 1.74s.

So that appears to be that. But if it's 2 versions of graphql _within gatsby_, I'm left wondering how this version builds at all, no?

Hi folks,
I want to report experience.

I created a source plugin to get Twitter Search api result inside GraphQL node and I get the same error when a try to build a website using my plugin.

My plugin has graphql as dependency and I think this is the issue as reported in the previous posts.

On my local setup linking gatsby-source-twitter node_modules folder to my local folder result in the same error, but if I point, with a symlink, the node_module/graphql folder of my plugin to node_module/graphql folder of my gatsby website, the error disappear.

So, with this setup everything is working, but pushed on CI the build process exit with the error.

Hope this could help.
Thank you

Update: I'm using npm v5.4.2 and node v8.7.0

I found a working solution workaround for my projects.

I added graphql as peerDependency in my plugin package.json, and after a fresh packages installation and regeneration of the package-lock.json file, build work perfectly.

No more errors.

In my node_modules folder I have only one graphql folder.

Maybe is not the best solution, but it suit for my needs 😸

I came across this issue when erroneously thinking I may have to additionally install graphql. Silly of me, but it would still be nice if running an innocent "npm install graphql" in a gatsby project wouldn't kill it the way it did.

Working on a gatsby-example-site starter.

What solved it for me:
npm remove graphql
npm install gatsby

Manually updating node_modules poses a difficulty to continuous integration.
Our solution within CircleCI should ideally be mappable to other CI services. Running find node_modules -iname graphql revealed two offending plugins beyond graphql: relay-compiler and graphql-skip-limit.We updated our circleci.yml file to include:

- run: npm install #update graphql using sub-modules to use peer dependancy - run: rm node_modules/relay-compiler/package.json - run: cp relay_compiler_package.json node_modules/relay-compiler/package.json - run: rm node_modules/graphql-skip-limit/package.json - run: cp graphql_skip_limit_package.json node_modules/graphql-skip-limit/package.json #remove sub-modules node-modules to force update - run: rm -r node_modules/relay-compiler/node_modules - run: rm -r node_modules/graphql-skip-limit/node_modules - run: npm install
The files relay_compiler_package.json and graphql_skip_limit_package.json are derived from the respectively named plugins' original package.jsons. The notable difference in these files are the movement of the graphql dependancy (with the cited version) into a "peerDependancy" tree. Thank you @G100g for introducing us to this concept.

We fervently hope for a solution to the root issue as our work-around is designed to be temporary.

I have a same problem with [email protected]. I found just 1 more graphql module in node_modules folder which is dependent by graphql-skip-limit(depedency of gatsby). And I removed that.

rm -rf node_modules/graphql-skip-limit/node_modules/graphql

then bootstrapping worked well. Now I installed latest version of [email protected], there is no more problem. Of course there is no additional graphql folder in node_modules.

There was a difference in package-lock.json(I use npm rather than yarn)

2018-01-14 1 48 40

I think this issue might be a problem with some other dependency module which uses graphql.

Note that the solution proposed here (https://github.com/gatsbyjs/gatsby/issues/2814) by @Alxandr should fix this issue. Going to try implementing this.

Just want to add my own experience about this issue as I am now writing a plugin (transformer). @G100g 's solution/workaround worked for me, in production. i.e. I added graphql as peer dependency, publish my package to npm, install it on my site, it worked. But it doesn't work when I try to develop the plugin. My setup is: in my site folder I have MySite/plugins/my-plugin, which is a symbol link to my local development repo of my-plugin. In order for it to work, like @G100g said, I have to symbol link graphql from my site's node_modules folder to my my-plugin one, it's very fiddly, for plugin developers, and intimidating for first time plugin developers.

UPDATE:
In case anyone is interested in the detailed setup, here is my plugin. It's a org-mode transformer, which is totally based on the Remark one.

@calcsam Just want to add, export graphql from Gatsby doesn't solve the problem for plugin development either, unless I am missing something. because you don't have gatsby as dependency in your plugin package.

I ran into the same issue when authoring a plugin. Not published yet, but seems to be working now. I removed graphql as a dependency from the plugin. Makes sense as the plugin doesn't run in isolation, has to run with Gatsby which ships with graphqlanyway. Could possibly add graphql as a peerDependency if needed.

v2 helps a lot with this issue as now plugins shouldn't have a seperate dependency on graphql so it's harder for versions to get out of sync. Try upgrading! https://next.gatsbyjs.org/docs/migrating-from-v1-to-v2/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KyleAMathews picture KyleAMathews  Â·  97Comments

cusspvz picture cusspvz  Â·  128Comments

cutemachine picture cutemachine  Â·  112Comments

jonathan-chin picture jonathan-chin  Â·  69Comments

blainekasten picture blainekasten  Â·  130Comments