Skip to content

Commit

Permalink
Update PR: return original error if formatted graphql error is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Simpson committed Nov 10, 2017
1 parent e87ac98 commit 63a6a45
Showing 1 changed file with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,25 +175,18 @@ export function graphqlError(
)
}

message = `There was an error while compiling your site's GraphQL queries.
${message}
let reportedMessage = `There was an error while compiling your site's GraphQL queries.
${message || error.message}
`

if (error.message.match(/must be an instance of/)) {
message +=
reportedMessage +=
`This usually means that more than one instance of 'graphql' is installed ` +
`in your node_modules. Remove all but the top level one or run \`npm dedupe\` to fix it.`
}

if (error.message.match(/Duplicate document/)) {
message += `${error.message.slice(21)}\n`
reportedMessage += `${error.message.slice(21)}\n`
}

if (
process.env.gatsby_log_level === `verbose` &&
error.message.match(/GraphQLParser/)
) {
message += `${error.message}`
}

return message
return reportedMessage
}

0 comments on commit 63a6a45

Please sign in to comment.