I’m trying to send custom error details from my Spring Boot GraphQL backend to the frontend but it’s not working properly.
When I create a mutation method like this:
@MutationMapping
public Mono<User> testError() {
return Mono.error(new CustomErrorException("Test error", "Details for frontend"));
}
The frontend receives a generic Apollo error instead of my custom error details:
{
"errors": [
{
"message": "INTERNAL_ERROR for abc123-45",
"locations": [
{
"line": 1,
"column": 2
}
],
"path": [
"testError"
],
"extensions": {
"classification": "INTERNAL_ERROR"
}
}
],
"data": {
"testError": null
}
}
I also tried extending GraphQLError but still can’t get the custom error info to reach the frontend. What’s the right way to handle this?