Gatsby: "gatsby-source-graphql" threw an error while running the sourceNodes lifecycle:

Created on 9 Dec 2019  ·  29Comments  ·  Source: gatsbyjs/gatsby

Description

On build, the following error is thrown "gatsby-source-graphql" threw an error while running the sourceNodes lifecycle:; TypeError: createResolveType is not a function.
I found this issue in my Continuos delivery process and was able to replicate locally after reinstalling node modules to get the latest version of gatsby-source-graphql, that was published to npm about 1 hour ago, 2.1.26. Before, I was running "gatsby-source-graphql": "^2.0.18"

Steps to reproduce

Install latest package version and run the build command.

Expected result

run build without no issues

Actual result

the build process is stopped

Environment

System:
OS: macOS 10.14.6
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.16.0 - ~/.nvm/versions/node/v8.16.0/bin/node
Yarn: 1.17.0 - /usr/local/bin/yarn
npm: 6.13.2 - ~/.nvm/versions/node/v8.16.0/bin/npm
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 78.0.3904.108
Firefox: 71.0
Safari: 13.0.1
npmPackages:
gatsby: ^2.18.6 => 2.18.6
gatsby-cli: ^2.8.15 => 2.8.15
gatsby-image: ^2.0.37 => 2.2.34
gatsby-plugin-alias-imports: ^1.0.5 => 1.0.5
gatsby-plugin-eslint: ^2.0.4 => 2.0.8
gatsby-plugin-intl: ^0.1.7 => 0.1.7
gatsby-plugin-manifest: ^2.0.28 => 2.2.31
gatsby-plugin-offline: ^2.0.25 => 2.2.10
gatsby-plugin-react-helmet: ^3.0.12 => 3.1.16
gatsby-plugin-sharp: ^2.0.32 => 2.3.5
gatsby-plugin-sitemap: ^2.1.0 => 2.2.22
gatsby-source-filesystem: ^2.0.29 => 2.1.40
gatsby-source-graphql: ^2.1.26 => 2.1.26
gatsby-transformer-sharp: ^2.1.17 => 2.3.6
npmGlobalPackages:
gatsby-cli: 2.7.2

bug

Most helpful comment

Can confirm aswell, works fine on 2.1.25 and breaks with 2.1.26

All 29 comments

Upgrading from 2.1.25 to 2.1.26 gives me the same error message.

Can confirm. Downgraded to 2.1.20 and was able to build
.

Can confirm aswell, works fine on 2.1.25 and breaks with 2.1.26

Confirmed, except downgrading to 2.1.25 makes no difference on my end.

"gatsby": "^2.18.4",
"gatsby-source-graphql": "^2.1.25",
"graphql": "^14.5.8",

@emaddoma downgrading to the previous version 2.1.25 should solve it, hope I don't sound patronizing but give it another shot making sure it's set as "2.1.25" and not "^2.1.25" because with that you're installing the latest available not 2.1.25

@heldrida Thanks for that. Back in business.

This was caused by #19504 which is reverted now. Can you try again with version 2.1.27?

@vladar yeh, I'll do. side note, don't think npm allows overwriting versions, that should be latest 2.1.28

@vladar thanks! Version 2.1.28 solves the issue.

Sorry about that, hope not too much trouble, #20042 should be permanent fix.

For me this was still an issue.
"gatsby": "^2.19.17"
"graphql": "^14.6.0"
"gatsby-source-graphql": "2.1.33"

Going back to version 2.1.25 fixed it.

I'm still having this issue, downgrade did not solve it:
"gatsby-source-graphql": "2.1.25",
"gatsby": "^2.19.7",
"graphql": "^14.6.0"

Can you check what version of graphql-tools-fork you have installed?

@yaacovCR I don't have a graphql-tools-fork dependency installed.

Hmm. With latest version of gatsby-source-graphql, you should. Try upgrading and refreshing dependencies?

I'm experiencing the same error with the following Gatsby starter : https://github.com/smakosh/gatsby-portfolio-dev

Error happens right after making a first gatsby develop on a fresh install.

The gatsby-source-graphql I use is 2.1.21

@thomasfaller Try installing what @yaacovCR said above, I think that should solve it.

I just installed the latest version of gatsby-source-graphql, version 2.1.33 and the same issue happens.
@yaacovCR you mention gatsby-tools-fork is that different from gatsby-tools ?

Same error with graphql-tools-fork

Here are my dependencies if it helps:

    "dotenv": "^6.2.0",
    "formik": "^1.4.1",
    "gatsby": "^2.17.7",
    "gatsby-image": "^2.2.30",
    "gatsby-plugin-canonical-urls": "^2.0.8",
    "gatsby-plugin-favicon": "^3.1.6",
    "gatsby-plugin-google-analytics": "^2.0.8",
    "gatsby-plugin-manifest": "^2.2.6",
    "gatsby-plugin-nprogress": "^2.0.7",
    "gatsby-plugin-offline": "^3.0.14",
    "gatsby-plugin-react-helmet": "^3.0.2",
    "gatsby-plugin-sharp": "^2.2.13",
    "gatsby-plugin-sitemap": "^2.0.3",
    "gatsby-plugin-styled-components": "^3.0.4",
    "gatsby-source-filesystem": "^2.1.35",
    "gatsby-source-graphql": "^2.1.33",
    "gatsby-transformer-sharp": "^2.2.7",
    "graphql": "^14.6.0",
    "graphql-tools-fork": "^8.6.1",
    "prop-types": "^15.6.2",
    "react": "^16.11.0",
    "react-anchor-link-smooth-scroll": "^1.0.12",
    "react-dom": "^16.11.0",
    "react-google-recaptcha": "^1.0.5",
    "react-helmet": "^5.2.0",
    "styled-components": "^4.1.3",
    "yup": "^0.26.6"

@thomasfaller Yes, it is a different one. Also, try to downgrade gatsby-source-graphql to 2.1.29.

I downgraded it to 2.1.29 but I’m still getting the same error message.

That's weird, @yaacovCR could you help us here?

Hi! Can you post a stack trace?

Here's the output when typing gatsby develop

$ gatsby develop
success open and validate gatsby-configs - 0.075s
success load plugins - 1.628s
success onPreInit - 0.054s
success initialize cache - 0.015s
success copy gatsby files - 0.075s
success onPreBootstrap - 0.012s
success createSchemaCustomization - 0.007s

 ERROR #11321  PLUGIN

"gatsby-source-graphql" threw an error while running the sourceNodes lifecycle:

Response not successful: Received status code 401

warn The gatsby-source-graphql plugin has generated no Gatsby nodes. Do you need it?
success source and transform nodes - 0.487s
success building schema - 0.420s
success createPages - 0.005s
success createPagesStatefully - 0.117s
success onPreExtractQueries - 0.005s
success update schema - 0.062s

 ERROR #85923  GRAPHQL

There was an error in your GraphQL query:

Cannot query field "github" on type "Query".

If you don't expect "github" to exist on the type "Query" it is most likely a typo.
However, if you expect "github" to exist there are a couple of solutions to common problems:

- If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
- The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
- You want to optionally use your field "github" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add a least one entry with that field ("dummy content")

It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "Query":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions

File: src/components/landing/Projects/index.jsx:18:9

failed extract queries from components - 0.523s
success write out requires - 0.076s
success write out redirect data - 0.009s
warn The icon(./static/favicon/favicon-512.png) you provided to
'gatsby-plugin-manifest' is not square.
The icons we generate will be square and for the best results we recommend you
success Build manifest and related icons - 0.191s
success onPostBootstrap - 0.218s
⠀
info bootstrap finished - 11.323 s
⠀
success run queries - 0.039s - 4/4 101.60/s
⠀
You can now view portfolio in the browser.
⠀
  http://localhost:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
  http://localhost:8000/___graphql
⠀
Note that the development build is not optimized.
To create a production build, use gatsby build
⠀
success Building development bundle - 5.266s

This is a new error. You can possibly open a new issue. Seems possible status code 401 is referring to an auth error. Is your GitHub token working? You might want to open that issue on the starter repo for more targeted help.

@thomasfaller the second error about github is due to your token, that project need a .env file with your github token, did you set it up ?.

And the ERROR #11321 is weird, that must be solved with downgrade and installing graphql-tools-fork. We will have to open a new issue as @yaacovCR said.

@Jlopezjlx Thanks, I will check that token issue. I don't remember ever having to set a .env with my GH token in it but I don't work with Gatsby as often as I would like and certainly not often enough to be on par with the best practices :+1:

@thomasfaller get it, everything you need we're here. I'll keep looking for a workaround about the plugin error.

I think that the project must have an example of the .env file.

@thomasfaller open a new issue with this info, please, as this is closed. When you it please send the url o issue number.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KyleAMathews picture KyleAMathews  ·  3Comments

Oppenheimer1 picture Oppenheimer1  ·  3Comments

3CordGuy picture 3CordGuy  ·  3Comments

benstr picture benstr  ·  3Comments

brandonmp picture brandonmp  ·  3Comments