Skip to content

Commit

Permalink
Add GraphQLParser errors to verbose output (#2873)
Browse files Browse the repository at this point in the history
* Add GraphQLParser errors to verbose output

Was having issues with a malformed graphql query due to the differences between allContentfulX and contentfulX mappings.  Very difficult to track down until I added the following GraphQLParser exception.  I've scoped this to only show if verbose output is turned on to ensure newbies have some reference while using graphql, without getting in anyone else's way.

* Update PR: return original error if formatted graphql error is empty
  • Loading branch information
daniel-simpson authored and KyleAMathews committed Nov 13, 2017
1 parent 6cd114f commit 23e0dc5
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,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`
}

return message
return reportedMessage
}

0 comments on commit 23e0dc5

Please sign in to comment.