I’m trying to create a custom exception when GraphQL throws its owns. The default GraphQL exception response I got is (except for the fillings):
{
"errors": [
{
"message": "Validation error of type WrongType: argument 'inputLocals.localId' with value 'IntValue{value=7777800}' is not a valid 'Int' - Expected value to be in the Integer range but it was '7777800' @ 'getLocals'",
"locations": [
{
"line": 1,
"column": 25
}
],
"extensions": {
"classification": "ValidationError"
}
}
],
"data": null
}
So this is an error I got when I surpass the int limit, and I want this to be like this:
{
"code": "400",
"reason": "BAD_REQUEST",
"message": "/localId 7777800 is not less or equal to 99999",
"status": "",
"referenceError": ""
}
I am using the Kickstart GraphQL library, I have checked for some GraphQL Error Handler but it ain’t as expected (same format). I want the exception to appear when I use this query in my resolver:
@Override
public OutputLocals getLocals(InputLocals inputLocals) throws CustomGraphQLError {
int localId = inputLocals.localId();
if (localId > 99999) {
throw new CustomGraphQLError("fields matching the JSON above");
}
// Rest of code