Gatsby: ERROR #11321 PLUGIN "gatsby-source-graphql"

Created on 24 Aug 2019  路  11Comments  路  Source: gatsbyjs/gatsby

Description

using the default starter and added "gatsby-source-graphql" plugin I get the following error:
ERROR #11321 PLUGIN

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

Cannot use GraphQLDirective "@include" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

Steps to reproduce

  • create gatsby starter template
  • add to the plugins {
    resolve: "gatsby-source-graphql",
    options: {
    // This type will contain remote schema Query type
    typeName: "SWAPI",
    // This is field under which it's accessible
    fieldName: "swapi",
    // Url to query from
    url: "https://api.graphcms.com/simple/v1/swapi",
    },
    },
  • gatsby develop

Expected result

gatsby-source-graphql plugin should create Gatsby nodes when project is run

Actual result

no nodes created

Environment

System:
OS: macOS High Sierra 10.13.6
CPU: (4) x64 Intel(R) Core(TM) i7-5650U CPU @ 2.20GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.11.0 - ~/.nvm/versions/node/v10.11.0/bin/node
npm: 6.4.1 - ~/.nvm/versions/node/v10.11.0/bin/npm
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 76.0.3809.100
Firefox: 68.0.2
Safari: 12.1.2
npmPackages:
gatsby: ^2.13.73 => 2.13.73
gatsby-image: ^2.2.10 => 2.2.10
gatsby-plugin-manifest: ^2.2.6 => 2.2.6
gatsby-plugin-offline: ^2.2.7 => 2.2.7
gatsby-plugin-react-helmet: ^3.1.4 => 3.1.4
gatsby-plugin-sharp: ^2.2.13 => 2.2.13
gatsby-source-filesystem: ^2.1.11 => 2.1.11
gatsby-source-graphql: ^2.1.10 => 2.1.10
gatsby-transformer-sharp: ^2.2.7 => 2.2.7
npmGlobalPackages:
gatsby-cli: 2.7.40
gatsby: 2.13.76

Most helpful comment

Fixed in [email protected] thanks to @stefanprobst

All 11 comments

i ran into the same issue, hopefully fixed by #17052

Fixed in [email protected] thanks to @stefanprobst

i m trying all the solutions proposed here but i don t figure out why it didn't work for me .
11:28:46 PM: error "gatsby-source-graphql" threw an error while running the sourceNodes lifecycle: 11:28:46 PM: Response not successful: Received status code 401 11:28:46 PM: 11:28:46 PM: ServerError: Response not successful: Received status code 401 11:28:46 PM: 11:28:46 PM: - index.js:23 Object.exports.throwServerError 11:28:46 PM: [repo]/[apollo-link-http-common]/lib/index.js:23:17 11:28:46 PM: 11:28:46 PM: - index.js:48 11:28:46 PM: [repo]/[apollo-link-http-common]/lib/index.js:48:21 11:28:46 PM: 11:28:46 PM: - next_tick.js:68 process._tickCallback 11:28:46 PM: internal/process/next_tick.js:68:7 11:28:46 PM: 11:28:46 PM: 11:28:46 PM: not finished source and transform nodes - 0.373s 11:28:46 PM: npm 11:28:46 PM: ERR! code 11:28:46 PM: ELIFECYCLE 11:28:46 PM: npm ERR! errno 1

@khalilbenachir
Received status code 401 looks like an authorization error

I'm also getting this error:

``` ERROR #11321 PLUGIN

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

createResolveType is not a function

TypeError: createResolveType is not a function

  • transforms.js:35 fields
    [localgatsby]/[gatsby-source-graphql]/transforms.js:35:65

  • Array.reduce

  • transforms.js:60 NamespaceUnderFieldTransform.transformSchema
    [localgatsby]/[gatsby-source-graphql]/transforms.js:60:12

  • transforms.js:5
    [localgatsby]/[graphql-tools-fork]/dist/transforms/transforms.js:5:54

  • Array.reduce

  • transforms.js:4 Object.applySchemaTransforms
    [localgatsby]/[graphql-tools-fork]/dist/transforms/transforms.js:4:23

  • transformSchema.js:29 wrapSchema
    [localgatsby]/[graphql-tools-fork]/dist/transforms/transformSchema.js:29:25

  • transformSchema.js:33 transformSchema
    [localgatsby]/[graphql-tools-fork]/dist/transforms/transformSchema.js:33:18

  • gatsby-node.js:101 Object.exports.sourceNodes
    [localgatsby]/[gatsby-source-graphql]/gatsby-node.js:101:18
    ```

Currently, I am trying to set up a headless environment with wpgraphql so my config looks like this:

{ resolve: `gatsby-source-graphql`, options: { // Arbitrary name for the remote schema Query type typeName: `WPGraphQL`, // Field under which the remote schema will be accessible. You'll use this in your Gatsby query fieldName: `wpgraphql`, // Url to query from url: `http://six12creative.local/graphql`, }, },

Any help would be much appreciated!

I'm also getting this error:

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

createResolveType is not a function



  TypeError: createResolveType is not a function

  - transforms.js:35 fields
    [localgatsby]/[gatsby-source-graphql]/transforms.js:35:65

  - Array.reduce

  - transforms.js:60 NamespaceUnderFieldTransform.transformSchema
    [localgatsby]/[gatsby-source-graphql]/transforms.js:60:12

  - transforms.js:5 
    [localgatsby]/[graphql-tools-fork]/dist/transforms/transforms.js:5:54

  - Array.reduce

  - transforms.js:4 Object.applySchemaTransforms
    [localgatsby]/[graphql-tools-fork]/dist/transforms/transforms.js:4:23

  - transformSchema.js:29 wrapSchema
    [localgatsby]/[graphql-tools-fork]/dist/transforms/transformSchema.js:29:25

  - transformSchema.js:33 transformSchema
    [localgatsby]/[graphql-tools-fork]/dist/transforms/transformSchema.js:33:18

  - gatsby-node.js:101 Object.exports.sourceNodes
    [localgatsby]/[gatsby-source-graphql]/gatsby-node.js:101:18

Currently, I am trying to set up a headless environment with wpgraphql so my config looks like this:

      resolve: `gatsby-source-graphql`,
      options: {
        // Arbitrary name for the remote schema Query type
        typeName: `WPGraphQL`,
        // Field under which the remote schema will be accessible. You'll use this in your Gatsby query
        fieldName: `wpgraphql`,
        // Url to query from
        url: `http://six12creative.local/graphql`,
      },
    },```

Any help would be much appreciated!

I am having the exact same error. Everything was working until I ran yarn update which means some package version mismatch or similar is happening. Haven't been able to find the root cause for this yet.

Anyone know what could be causing this?

I'm also getting this error:

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

createResolveType is not a function



  TypeError: createResolveType is not a function

  - transforms.js:35 fields
    [localgatsby]/[gatsby-source-graphql]/transforms.js:35:65

  - Array.reduce

  - transforms.js:60 NamespaceUnderFieldTransform.transformSchema
    [localgatsby]/[gatsby-source-graphql]/transforms.js:60:12

  - transforms.js:5 
    [localgatsby]/[graphql-tools-fork]/dist/transforms/transforms.js:5:54

  - Array.reduce

  - transforms.js:4 Object.applySchemaTransforms
    [localgatsby]/[graphql-tools-fork]/dist/transforms/transforms.js:4:23

  - transformSchema.js:29 wrapSchema
    [localgatsby]/[graphql-tools-fork]/dist/transforms/transformSchema.js:29:25

  - transformSchema.js:33 transformSchema
    [localgatsby]/[graphql-tools-fork]/dist/transforms/transformSchema.js:33:18

  - gatsby-node.js:101 Object.exports.sourceNodes
    [localgatsby]/[gatsby-source-graphql]/gatsby-node.js:101:18

Currently, I am trying to set up a headless environment with wpgraphql so my config looks like this:

      resolve: `gatsby-source-graphql`,
      options: {
        // Arbitrary name for the remote schema Query type
        typeName: `WPGraphQL`,
        // Field under which the remote schema will be accessible. You'll use this in your Gatsby query
        fieldName: `wpgraphql`,
        // Url to query from
        url: `http://six12creative.local/graphql`,
      },
    },```

Any help would be much appreciated!

I am having the exact same error. Everything was working until I ran yarn update which means some package version mismatch or similar is happening. Haven't been able to find the root cause for this yet.

Anyone know what could be causing this?

I was able to resolve the issue by deleting yarn.lock and package-lock.json. Then re-installing packages with npm.

Still don't know exactly what package is causing the dependencies to clash but it's either gatsby-source-graphql or gatsby-source-graphql-universal

Probably same as #20015

i keep getting this error when i try to create a blog page using the createPage code from the gatsby node api documentation.

here is my code

module.exports.createPages = async ({ graphql, actions }) => {
const {createPages} = actions
const blogTemplates = path.resolve('./src/templates/blogTemplates.js')
const res = await graphql (`
    query{
        allMarkdownRemark{
            edges{
                node{
                    fields{
                        slug
                    }
                }
            }
        }
    }
`,

res.data.allMarkdownRemark.edges.forEach((edge) => {

    createPage ({
        component: blogTemplates,
        path: `/blog/${edge.node.fields.slug}`,
        context: { 
        slug: edge.node.fields.slug
        }
    })
})
)}

### This is the error message:

```
ERROR #11321 PLUGIN

"gatsby-node.js" threw an error while running the createPages lifecycle:

allMarkdownRemark is not defined

ReferenceError: allMarkdownRemark is not defined

gatsby-node.js:35 Object.module.exports.createPages C:/Users/Mr Prewsh/Desktop/gatsby-bootcamp/gatsby-node.js:35:5

api-runner-node.js:235 runAPI [gatsby-bootcamp]/[gatsby]/dist/utils/api-runner-node.js:235:41

api-runner-node.js:375 Promise.catch.pluginName [gatsby-bootcamp]/[gatsby]/dist/utils/api-runner-node.js:375:13

new Promise

api-runner-node.js:374 runPlugin [gatsby-bootcamp]/[gatsby]/dist/utils/api-runner-node.js:374:10

api-runner-node.js:328 module.exports [gatsby-bootcamp]/[gatsby]/dist/utils/api-runner-node.js:328:24

index.js:437 module.exports [gatsby-bootcamp]/[gatsby]/dist/bootstrap/index.js:437:9

develop.js:420 async module.exports [gatsby-bootcamp]/[gatsby]/dist/commands/develop.js:420:7

failed createPages - 0.506s

```Please, I need help in solving this.

@prewsh what are you using for the blog? Markdown? if that's the case you don't need gatsby-source-graphql, you should use gatsby-transfomer-remark and it's accompanying plugins.

You can read more about it in here and also if i were you, i would check this compendium of available resources.

To add a clarification on what that query is refering.

In a nutshell that query will grab all the data that was created by the plugin i mentioned above. If you don't have it installed then Gatsby will throw the error, saying that it can't find that node allMarkdownRemark . The usage of gatsby-source-graphql with gatsby is oriented to other third party graphql sources, something like strapi, Hasura, GraphCms among others

Hi I am having this same problem in build.
Tried switching to different versions but still nothing.

 ERROR #11321  PLUGIN

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

Response not successful: Received status code 401



  ServerError: Response not successful: Received status code 401

  - index.ts:114 Object.exports.throwServerError
    [Portfolio]/[apollo-link-http-common]/src/index.ts:114:17

  - index.ts:145
    [Portfolio]/[apollo-link-http-common]/src/index.ts:145:11

  - task_queues.js:93 processTicksAndRejections
    internal/process/task_queues.js:93:5


not finished source and transform nodes - 6.074s
Was this page helpful?
0 / 5 - 0 ratings

Related issues

hobochild picture hobochild  路  3Comments

theduke picture theduke  路  3Comments

ferMartz picture ferMartz  路  3Comments

brandonmp picture brandonmp  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments