Custom Error Handling for Network Errors
See original GitHub issueLets say I have a GraphQL schema defined has below,
input User {
name: String!
email: String!
}
type Mutation {
createUser (payload: User!): Boolean
}
When I send a mutation createUser
with input field/s missing, the server sends me a 400 Bad Request with some payload like below (as seen on browser Inspect logs),
{
"errors": [
{
"message": "Field User.name of required type String! was not provided.",
"locations": [
{
"line": 2,
"column": 10
}
]
}
]
}
But Playground shows be the below error, and Apollo Client also receives this error.
{
"error": "Response not successful: Received status code 400"
}
Is there a way to customise this error, maybe something like below,
{
"errors": {
"name": "ValidationError",
"details": [
"Field User.name of required type String! was not provided."
]
}
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:12 (1 by maintainers)
Top Results From Across the Web
Error Handling for Network Requests in Client-Side JavaScript ...
Using Custom JavaScript Errors to classify our errors and build advanced logic in the event of a failure. Resources. Postman. A popular request ......
Read more >Handling operation errors - Apollo GraphQL Docs
Apollo Client helps you handle these errors according to their type, enabling you to show appropriate information to the user when an error...
Read more >Fetch - Error Handling for Failed HTTP Responses and ...
A quick example of how to handle both network errors and HTTP errors (4xx or 5xx) for fetch requests in a single catch...
Read more >Error Handling with Combine and SwiftUI - Peter Friese
Learn how you can use Combine to improve error handling in your SwiftUI apps.
Read more >Custom Error Handling for Network Errors · Issue #304 - GitHub
Lets say I have a GraphQL schema defined has below, input User { name: String! email: String! } type Mutation { createUser (payload:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same here. How to display this payload in the server response body?
Same here when creating a custom scalar.
In the network tab I can see
{"errors":[{"message":"Expected type ReferenceNumber!, found \"12345678\"; String's length must be at most 7, got 8","locations":[{"line":2,"column":69}]}]}
.In the playground I only see
{"error": "Response not successful: Received status code 400"}
.