jasonkuhrt / graphql-request

Minimal GraphQL client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Show errors when HTTP code is not 2xx

andikhadev opened this issue · comments

Perceived Problem

I have a problem to display error messages in graphql such as query not found, one field not found, etc. the problem is that I don't get data errors in the response if the status code is not 2xx like 4xx or in a fetch that is not ok in the response. I only get the status code and a message that is not good to display to the user.

Ideas / Proposed Solution(s)

When fetch response is not ok/ 4xx, return the client error with errors property that can be obtained by a response that has been parsed in JSON.

This will be solved by #921. Not sure it works in your case, but, you could also consider putting known errors into the schema.