graphql icon indicating copy to clipboard operation
graphql copied to clipboard

Update client to pass response along rather than pulling out errors

Open erutherford opened this issue 7 years ago • 2 comments

With graphQL it's possible the response could be partially successful. With the way the client is currently configured, it's parsing the errors property and returning an error with the first error in the array if it's not empty.

Would you be open to a PR that instead passes the entire response? This would allow the caller to decide how it wants to handle the returned errors. We're also currently losing additional error context if more than one error is present.

erutherford avatar Sep 04 '18 17:09 erutherford

This seems fair enough.

I think the default behaviour should be to pull out the first error as it does today (it's simpler and what most people need), but I'm not against adding the complete response as an option.

I think the API should be something like this:

err := client.Run(ctx, req, &resp)
if err != nil {
  resp, ok := graphql.Response(err)
  if ok {
    // TODO: use the complete resp here
  }
}

matryer avatar Oct 15 '18 09:10 matryer

What's the status of this one?

fubarhouse avatar Jan 14 '19 10:01 fubarhouse