You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on a site, we will sometimes create invalid GraphQL for various reasons. The current error message looks like this:
...
success createPagesStatefully — 0.130 s
success onPreExtractQueries — 0.001 s
success update schema — 0.415 s
GraphQL Error There was an error while compiling your site's GraphQL queries.
GraphQLParser
success extract queries from components — 0.553 s
success run graphql queries — 0.171 s
...
Create a GraphQL query that references a non-existent property, run gatsby build or gatsby develop.
Expected result
The error message should give me some level of information to go on here. Either the raw text of the query that could not be parsed, or the file it came from.
Actual result
Gatsby tells me there is a problem but gives me absolutely no information to go on to fix it. When I was working on a small site this was fine, but now with a large site and CMS it often takes a long time to track these errors down.
Environment
Gatsby version (npm list gatsby): gatsby@1.9.246
gatsby-cli version (gatsby --version): Not in use, I use package.json scripts to run the embedded gatsby in the project's node_modules folder.
I took the standard gatsby starter then did these steps:
Removed Page 2 and the 404 page to simplify
Added gatsby-source-filesystem and gatsby-transformer-json
Added a query in index.js which is invalid. It tries to query a body field when none exists.
When you run gatsby develop:
$ gatsby develop
success delete html and css files from previous builds — 0.006 s
success open and validate gatsby-config.js — 0.005 s
success copy gatsby files — 0.017 s
success onPreBootstrap — 0.025 s
success source and transform nodes — 0.039 s
success building schema — 0.144 s
success createLayouts — 0.006 s
success createPages — 0.001 s
success createPagesStatefully — 0.011 s
success onPreExtractQueries — 0.000 s
success update schema — 0.090 s
GraphQL Error There was an error while compiling your site's GraphQL queries.
GraphQLParser
success extract queries from components — 0.031 s
success run graphql queries — 0.011 s
success write out page data — 0.004 s
success write out redirect data — 0.001 s
success onPostBootstrap — 0.001 s
info bootstrap finished - 1.778 s
DONE Compiled successfully in 2171ms 15:25:50
You can now view gatsby-starter-default 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
It'd be fantastic if this error message could be improved.
The text was updated successfully, but these errors were encountered:
Thanks for reproduction, it'll help a lot. I'm suprised there is still a vague one like this somewhere, generally we do show the file, query and the exact line that's wrong and why. We must of missed a place so the repro is helpful!
This seems to be regression after #4618 it added capturing parenthesis but didn't adjust indices later used for passing error messages. Will submit PR with fix soonish
Description
While working on a site, we will sometimes create invalid GraphQL for various reasons. The current error message looks like this:
Steps to reproduce
Repro: https://github.com/blargity/gatsby-graphql-error-demo
Create a GraphQL query that references a non-existent property, run
gatsby build
orgatsby develop
.Expected result
The error message should give me some level of information to go on here. Either the raw text of the query that could not be parsed, or the file it came from.
Actual result
Gatsby tells me there is a problem but gives me absolutely no information to go on to fix it. When I was working on a small site this was fine, but now with a large site and CMS it often takes a long time to track these errors down.
Environment
npm list gatsby
): gatsby@1.9.246gatsby --version
): Not in use, I use package.json scripts to run the embedded gatsby in the project's node_modules folder.File contents (if changed):
Here's a repro case:
https://github.com/blargity/gatsby-graphql-error-demo
I took the standard gatsby starter then did these steps:
gatsby-source-filesystem
andgatsby-transformer-json
index.js
which is invalid. It tries to query abody
field when none exists.When you run
gatsby develop
:It'd be fantastic if this error message could be improved.
The text was updated successfully, but these errors were encountered: