Closed AndrewRayCode closed 6 years ago
Wow, this is great! For years, I have just kept the network tab open.
I just tweaked this a tiny bit and released it as 1.4.8
!
I separated our message from the server response like so:
Thanks again for this great improvement :)
:O woohoo!
For a future improvement I think it would be great to preserve line breaks / not treat it as json. Rails (sometimes) provides a comprehensive stack trace with line breaks, and it's much harder to parse as one line.
My original code, even when not returning JSON, did not seem to make the line breaks work and instead showed \n
but I did not investigate why
If a server 500s or otherwise fails to return valid JSON, the GraphiQL interface will simply show the error of trying to parse the response as JSON. This means that for any meaningful GraphQL development, you have to keep the network tab open at all times to read the actual server response.
This replaces
.json()
with.text()
andJSON.parse()
. This is a quick fix without much thought put into it, but I couldn't find a more obvious way to preserve the JSON parsing error along with the actual server error. The Response() API is...interesting.