graphql-got icon indicating copy to clipboard operation
graphql-got copied to clipboard

Swallows GraphQL errors

Open stephenmathieson opened this issue 7 years ago • 4 comments

If your GraphQL endpoint returns an error, this module will swallow it here: https://github.com/kevva/graphql-got/blob/v0.1.1/index.js#L38

Instead of dropping res.body.errors, they should be assigned to res (maybe as res.errors?). Would you accept a PR that introduces this change?

stephenmathieson avatar Mar 14 '18 15:03 stephenmathieson

@stephenmathieson, sure!

kevva avatar Mar 14 '18 18:03 kevva

What do you think about rejecting if errors are present? It can be pretty easy for a user to miss them, especially if they aren't too well-versed with GraphQL.

wtgtybhertgeghgtwtg avatar May 13 '18 23:05 wtgtybhertgeghgtwtg

I agree. It should reject on errors.

@kevva Thoughts?

sindresorhus avatar May 14 '18 12:05 sindresorhus

Interesting thought. I'm pretty used to doing something like this (coming from apollo-client):

if (data.error) {
  handleErrorSomehow(data.error)
}

Where data.error is the error coming back from the GraphQL server. The errors raised (thrown) by apollo-client are network errors instead. See the docs for more.

Not suggesting we should mirror the behavior from apollo-client, but it is why I figured keeping it on the returned res object was the right move.

stephenmathieson avatar May 14 '18 13:05 stephenmathieson