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

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

Closed
Aleksion opened this issue Sep 2, 2017 · 32 comments

Comments

@Aleksion
Copy link

@Aleksion Aleksion commented Sep 2, 2017

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

@jquense

This comment has been minimized.

Copy link
Contributor

@jquense jquense commented Sep 2, 2017

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

@Aleksion

This comment has been minimized.

Copy link
Author

@Aleksion Aleksion commented Sep 2, 2017

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

@jquense

This comment has been minimized.

Copy link
Contributor

@jquense jquense commented Sep 2, 2017

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

@Aleksion

This comment has been minimized.

Copy link
Author

@Aleksion Aleksion commented Sep 2, 2017

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?

@Aleksion

This comment has been minimized.

Copy link
Author

@Aleksion Aleksion commented Sep 4, 2017

I'll close since the base issue was resolved

@Aleksion Aleksion closed this Sep 4, 2017
@mboudreau

This comment has been minimized.

Copy link

@mboudreau mboudreau commented Sep 21, 2017

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

@mboudreau

This comment has been minimized.

Copy link

@mboudreau mboudreau commented Sep 27, 2017

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

@Aleksion

This comment has been minimized.

Copy link
Author

@Aleksion Aleksion commented Sep 28, 2017

@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

@Aleksion

This comment has been minimized.

Copy link
Author

@Aleksion Aleksion commented Oct 6, 2017

@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).

@Aleksion Aleksion reopened this Oct 6, 2017
@KyleAMathews

This comment has been minimized.

Copy link
Contributor

@KyleAMathews KyleAMathews commented Oct 6, 2017

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.

@Aleksion

This comment has been minimized.

Copy link
Author

@Aleksion Aleksion commented Oct 9, 2017

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.

@mboudreau

This comment has been minimized.

Copy link

@mboudreau mboudreau commented Oct 9, 2017

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

@KyleAMathews KyleAMathews commented Oct 9, 2017

@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.

@mboudreau

This comment has been minimized.

Copy link

@mboudreau mboudreau commented Oct 9, 2017

@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...

@Aleksion

This comment has been minimized.

Copy link
Author

@Aleksion Aleksion commented Oct 10, 2017

@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!

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

@KyleAMathews KyleAMathews commented Oct 10, 2017

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.

@Alxandr

This comment has been minimized.

Copy link

@Alxandr Alxandr commented Nov 1, 2017

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

@tcjcodes

This comment has been minimized.

Copy link

@tcjcodes tcjcodes commented Nov 4, 2017

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.

@Alxandr

This comment has been minimized.

Copy link

@Alxandr Alxandr commented Nov 4, 2017

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.

@brandonmp

This comment has been minimized.

Copy link
Contributor

@brandonmp brandonmp commented Nov 10, 2017

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 (#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")

@jquense

This comment has been minimized.

Copy link
Contributor

@jquense jquense commented Nov 11, 2017

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

@brandonmp

This comment has been minimized.

Copy link
Contributor

@brandonmp brandonmp commented Nov 11, 2017

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.
├─ graphql-skip-limit@1.0.7
│  └─ graphql@0.11.7
└─ graphql@0.10.5
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?

@G100g

This comment has been minimized.

Copy link
Contributor

@G100g G100g commented Nov 13, 2017

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

@G100g

This comment has been minimized.

Copy link
Contributor

@G100g G100g commented Nov 14, 2017

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 😸

@esuus

This comment has been minimized.

Copy link

@esuus esuus commented Dec 20, 2017

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

@kennedyrose kennedyrose mentioned this issue Jan 2, 2018
@kickerbear

This comment has been minimized.

Copy link

@kickerbear kickerbear commented Jan 4, 2018

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:

        #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.

@rhostem

This comment has been minimized.

Copy link

@rhostem rhostem commented Jan 14, 2018

I have a same problem with gatsby@1.9.74. 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 gatsby@1.9.155, 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.

@calcsam

This comment has been minimized.

Copy link
Member

@calcsam calcsam commented Jan 14, 2018

Note that the solution proposed here (#2814) by @Alxandr should fix this issue. Going to try implementing this.

@xiaoxinghu

This comment has been minimized.

Copy link
Contributor

@xiaoxinghu xiaoxinghu commented Jan 31, 2018

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.

@xiaoxinghu

This comment has been minimized.

Copy link
Contributor

@xiaoxinghu xiaoxinghu commented Jan 31, 2018

@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.

@stewartduffy

This comment has been minimized.

Copy link

@stewartduffy stewartduffy commented Apr 17, 2018

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 graphql anyway. Could possibly add graphql as a peerDependency if needed.

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

@KyleAMathews KyleAMathews commented Jun 27, 2018

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/

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

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.