Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

apollo-link-http loses contents of error responses from apollo-server #178

Closed
glasser opened this issue Oct 25, 2017 · 3 comments
Closed

Comments

@glasser
Copy link
Member

glasser commented Oct 25, 2017

apollo-server turns any response with error and no data into a 400. An easy way to trigger such a response is to ask for a field that doesn't exist, eg query { xxxx }.

apollo-link-http turns that into an error which doesn't actually have the JSON on it.

It does put the response on the error, but the JSON was already read so you can't re-read it from the response.

Also, it puts an error describing the fact that this was a 400 response onto the thus-misleadingly-named parseError field.

This is the root cause behind [errors showing up in the devtools as [object Object]]: apollographql/apollo-client-devtools#81

apollo-link-http should make the contents of the error available to its clients even if it's on a 400, as long as JSON parses properly. Or perhaps apollo-server should not make these errors return 400. I'm not sure.

@oliviertassinari
Copy link

oliviertassinari commented Nov 22, 2017

apollo-link-http should make the contents of the error available to its clients even if it's on a 400, as long as JSON parses properly.

This! 👍 I'm getting a Error: body used already for error when trying to read the response a second time networkError.response.text().

@jbaxleyiii
Copy link
Contributor

@evans did this get changed with your error PR? Can you take a look?

@evans
Copy link
Contributor

evans commented Nov 27, 2017

Yeah this should be solved with #244. On a network error(>= 300 status), the parsed body of the response will be the result field of the error.

We also removed parseError.

CC @glasser

@evans evans closed this as completed Nov 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants