How to handle custom scalar validation errors? #2018
Unanswered
ayushs-2k4
asked this question in
Q&A
Replies: 1 comment
-
Specifically I want to handle GraphQL coercing errors. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have created a custom scalar 'EmailScalar' which is as follows
`
import graphql.GraphQLContext;
import graphql.Internal;
import graphql.execution.CoercedVariables;
import graphql.language.StringValue;
import graphql.language.Value;
import graphql.schema.Coercing;
import graphql.schema.CoercingParseLiteralException;
import graphql.schema.CoercingSerializeException;
import graphql.schema.GraphQLScalarType;
import org.jetbrains.annotations.NotNull;
import java.util.Locale;
import static graphql.scalar.CoercingUtil.typeName;
@internal
public final class EmailScalar {
}
`
`
public class InvalidEmailFormatException extends RuntimeException {
public InvalidEmailFormatException(final String message) {
super(message);
}
}
`
I am trying to handle it like other exceptions as:
`
@ControllerAdvice
public class CustomExceptionHandler {
`
but this is not even getting called (other GraphQlExceptionHandlers are working perfectly). The output in client side is
and on server side is:
Now my question is how to handle this type of error, I mean how to send custom graphql error response like we send with other errors?
Beta Was this translation helpful? Give feedback.
All reactions