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

Unhelpful error message when gatsby-source-graphql introspection call fails. #20892

Closed
ricokahler opened this issue Jan 26, 2020 · 3 comments
Closed
Assignees
Labels
topic: GraphQL Related to Gatsby's GraphQL layer

Comments

@ricokahler
Copy link
Contributor

Description

Unhelpful error message when gatsby-source-graphql introspection call fails.

 ERROR #11321  PLUGIN

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

[object Object]

Steps to reproduce

  • create a new gatsby project
  • add gatsby-source-graphql
  • add this 👇 bit of configuration with a mockfetch implementation
{
  resolve: `gatsby-source-graphql`,
  options: {
    typeName: `Test`,
    fieldName: `test`,
    url: `/test`,
    fetch: () =>
      Promise.resolve({
        text: () =>
          Promise.resolve(
            JSON.stringify({
              data: {},
              errors: [
                {
                  message: `Internal server error`,
                },
              ],
            })
          ),
      }),
  },
},
  • run gatsby build
  • observe the [object Object] error message

Expected result

This should output the error message from the GraphQL server (e.g. "Internal server error") and indicate that the error came from the GraphQL server.

Actual result

 ERROR #11321  PLUGIN

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

[object Object]

Environment

Run gatsby info --clipboard in your project directory and paste the output here.

System:
    OS: macOS 10.15.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.13.1 - /usr/local/bin/node
    Yarn: 1.21.1 - /usr/local/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 79.0.3945.130
    Firefox: 72.0.1
    Safari: 13.0.3
  npmPackages:
    gatsby: ^2.19.5 => 2.19.5
    gatsby-image: ^2.2.39 => 2.2.39
    gatsby-plugin-manifest: ^2.2.38 => 2.2.38
    gatsby-plugin-offline: ^3.0.32 => 3.0.32
    gatsby-plugin-react-helmet: ^3.1.21 => 3.1.21
    gatsby-plugin-sharp: ^2.4.0 => 2.4.0
    gatsby-source-filesystem: ^2.1.46 => 2.1.46
    gatsby-source-graphql: ^2.1.32 => 2.1.32
    gatsby-transformer-sharp: ^2.3.13 => 2.3.13
@vientang
Copy link

vientang commented Feb 18, 2020

I wrestled with something similar and it's not a server error. Definitely agree that it's a bit unclear.

What it looks like is that gatsby-source-graphql is trying to operate on nodes but it's given a string, so it fails there. On the web, this you'd see something in the console related to JSON ... "syntaxError: Unexpected token o" or something like that.

@haasman
Copy link

haasman commented May 8, 2020

My build works fine on Netlify, but when I setup the same exact site on Gatsby cloud I get this same error.
error [object Object]

Does anyone know why that would make a difference?

@LekoArts
Copy link
Contributor

Should be fixed with #28786

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: GraphQL Related to Gatsby's GraphQL layer
Projects
None yet
Development

No branches or pull requests

5 participants