Skip to content

Commit

Permalink
Tidy up the query-runner error log
Browse files Browse the repository at this point in the history
  • Loading branch information
alexluong committed May 24, 2018
1 parent 074dac3 commit 1a2d7e1
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions packages/gatsby/src/internal-plugins/query-runner/query-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const { store } = require(`../../redux`)

const resultHashes = {}

const indentString = string => string.replace(/\n/g, `\n `)

// Run query for a page
module.exports = async (pageOrLayout, component) => {
pageOrLayout.id = pageOrLayout._id
Expand All @@ -32,22 +34,19 @@ module.exports = async (pageOrLayout, component) => {
// If there's a graphql error then log the error. If we're building, also
// quit.
if (result && result.errors) {
report.log(
report.stripIndent`
The GraphQL query from ${component.componentPath} failed.
report.log(`
The GraphQL query from ${component.componentPath} failed.
Errors:
${result.errors || []}
URL path:
${pageOrLayout.path}
Context:
${JSON.stringify(pageOrLayout.context, null, 4)}
Plugin:
${pageOrLayout.pluginCreatorId || `none`}
Query:
${component.query}
`
)
Errors:
${result.errors || []}
URL path:
${pageOrLayout.path}
Context:
${indentString(JSON.stringify(pageOrLayout.context, null, 2))}
Plugin:
${pageOrLayout.pluginCreatorId || `none`}
Query:
${indentString(component.query)}`)

// Perhaps this isn't the best way to see if we're building?
if (program._name === `build`) {
Expand Down

0 comments on commit 1a2d7e1

Please sign in to comment.