Replies: 2 comments
-
I don't think there's an issue. When there's an error before query execution (e.g. when the query is validated against a schema), Error handling in Apollo Client (v3.0) treats HTTP responses with valid JSON but a status
(ref) It would be nice though if Apollo Client first attempts to parse the HTTP response body as GraphQL errors and only if that fails fallback and handle it as a generic network error. TL;DR: It's perfectly fine for a GraphQL server to respond with a 4xx code when there's a syntax/validation error that occurs before query execution. It's also (probably) expected that Apollo Client treats statuses |
Beta Was this translation helpful? Give feedback.
-
Sending HTTP errors codes is a thing done by RESTful APIs; it goes against the GraphQL spirit. HTTP is just the transport, so let us keep status codes out of the GraphQL (different OSI layer). Can do it over FTP as well! Anyway,
Note the message about accepting connections, but since the client gets a 4xx, it thinks something is wrong with the transport. You can change this behavior by using
Now the GraphQL world and its clients will be happy and show a much better error:
Maybe it can be added to the gqlgen configuration? Changing how it works now is going to break things :) Alternatively, if you want keep pestering GraphQL clients with HTTP Status Codes, you can add an error presenter:
Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
What happened?
Getting 422 http status code error message on all query calls from Apollo client to gqlgen graphql server. Apollo client works fine when I query Apollo Graphql server.
Error Message
Objects are not valid as a React child (found: Error: Response not successful: Received status code 422). If you meant to render a collection of children, use an array instead.
What did you expect?
Query calls be executed as expected return the result with any error message
Minimal graphql.schema and models to reproduce
type Test {
name; String
}
query {
Testnow: Test
}
Resolver:
Just return Test Model. Very simple
versions
gqlgen version
?0.12.2
go version
?1.15
go modules
Beta Was this translation helpful? Give feedback.
All reactions