Closed nghiepdev closed 4 years ago
👋 Hey @nghiepit, ultimately this is neither on next-urql
or urql
's end, and is more a factor of how most servers and clients implement the rather sparsely documented error spec in GraphQL. In your case, updating the request to use id2
rather than id
will result in a 400 error status (Bad Request):
This is pretty standard for most GraphQL servers to throw in the case of a request like this, which fails the parse and validation phases of executing the query. Basically, the server at https://graphql-pokemon.now.sh
attempts to parse and validate that query against its schema and says, "Nope, this isn't a valid query for this schema, the client malformed the request." In this case, 400 is the appropriate response code, and urql
handles the 400 correctly as a networkError
.
graphQLErrors
are typically reserved for when an error is thrown inside of a resolver on the server. This would be more a case of something like missing data or a failure to acquire all the data for a fragment. Typically with graphQLErrors
your query passes the parse and validation phases, but something about the state of data on the backend prevents the resolvers from returning all of your requested data.
Here's a pretty good discussion of this separation, albeit in Apollo land: https://blog.apollographql.com/full-stack-error-handling-with-graphql-apollo-5c12da407210
Hi guys,
I cloned your example https://codesandbox.io/s/next-urql-pokedex-oqj3x
I changed the query. The purpose for faulty
But, I did not get
graphQLErrors
, it's always empty. Should have received the following error message;Cannot query field "id2" on type "Pokemon". Did you mean "id"
Sorry, If the problem in
urql
, notnext-urql
, thanks in advance.