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
If in your gatsby-node.js you send a bad graphql query to the graphql function (this is commonly done to query data to create pages), you won't get any error. Instead you'll generally get an error that you can't access expected data from the graphql result e.g.
Ideally we'd catch errors return from the graphql function and create structured errors for common problems.
Steps to reproduce
Create a site add add the following code to your gatsby-node.js:
exports.createPages=({ graphql, actions })=>{returngraphql(` query HomePageQuery { site { # Typo here siteMetadat { description } } } `).then(result=>{constdoesthisexist=result.data.siteMetadat})}
If you run gatsby build, it'll give an error like the following:
It should instead show that there was an error with your graphql query including what file/line number it happened in and the GraphQL error message.
Category
Categorize the error. Is it from GraphQL, Webpack, or something else?
GraphQL
Grade
Give the error a grade according to the key at the bottom of this issue.
0
The text was updated successfully, but these errors were encountered:
…sed in gatsby-node.js (#15227)
* Show structured errors for graphql errors from the graphql function used in gatsby-node.js
Fixes#15212
* Update packages/gatsby/src/bootstrap/index.js
Co-Authored-By: Mike Allanson <michael.allanson@gmail.com>
* Filter out null errors & mark error as from graphql function
Description
If in your
gatsby-node.js
you send a bad graphql query to the graphql function (this is commonly done to query data to create pages), you won't get any error. Instead you'll generally get an error that you can't access expected data from the graphql result e.g.Ideally we'd catch errors return from the graphql function and create structured errors for common problems.
Steps to reproduce
Create a site add add the following code to your
gatsby-node.js
:If you run
gatsby build
, it'll give an error like the following:It should instead show that there was an error with your graphql query including what file/line number it happened in and the GraphQL error message.
Category
GraphQL
Grade
0
The text was updated successfully, but these errors were encountered: