oliyh / re-graph

A graphql client for clojurescript and clojure
460 stars 39 forks source link

fix corruption of graphql error responses #54

Closed loomis closed 4 years ago

loomis commented 4 years ago

When using re-graph from Clojure, the current code corrupts the graphql error responses. This PR preserves the original graphql error response, unless that response is actually invalid or incomplete.

oliyh commented 4 years ago

Hi,

Thank you for this contribution. I haven't personally used much of the error handling so I'm finding it a bit hard to understand what the issue was and how this fixes it. Is there a test that could be written to explain it? Or do you have a sample error payload that would show where it goes wrong? I am slightly wary that GraphQL error payloads can differ slightly across implementations.

Thanks

loomis commented 4 years ago

I've added tests:

  1. To ensure that insert-http-status does not overwrite an existing :status value and
  2. To verify that the error response from the server (rather than the default) is returned when using clj-http as the client.

The last check required an additional test dependency.

oliyh commented 4 years ago

Thank you for this! I've deployed 0.1.12-SNAPSHOT to Clojars.