shurcooL / graphql

Package graphql provides a GraphQL client implementation.
MIT License
708 stars 282 forks source link

Include response body in non-200 OK error text. #30

Closed dmitshur closed 6 years ago

dmitshur commented 6 years ago

When a GraphQL server returns a non-200 OK status code, it may be very helpful to for caller to know what the response body was. So, when such an error occurs, fetch the response body and include it in the returned error text.

Fixes #29. Updates #24.

/cc @cjwagner @jorgesece @robermorales

robermorales commented 6 years ago

Great advance! It is not covering all the cases that we covered in #24, but I can understand the limitations of guessing if a body with a 4xx status code can be try to be decoded as a graphql valid response. At least the client can see the body response if something went wrong, so the troubleshooting can be improved a lot.