Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 69c65cf

Browse files
committed
Include GraphQLException when using exception handler; #166
1 parent 3737451 commit 69c65cf

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

graphql-spring-boot-autoconfigure/src/main/java/com/oembedler/moon/graphql/boot/error/GraphQLErrorFromExceptionHandler.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.oembedler.moon.graphql.boot.error;
22

3-
import graphql.ErrorType;
43
import graphql.ExceptionWhileDataFetching;
54
import graphql.GraphQLError;
5+
import graphql.GraphQLException;
66
import graphql.SerializationError;
77
import graphql.servlet.DefaultGraphQLErrorHandler;
88
import graphql.servlet.GenericGraphQLError;
@@ -28,18 +28,16 @@ protected List<GraphQLError> filterGraphQLErrors(List<GraphQLError> errors) {
2828
}
2929

3030
private GraphQLError transform(GraphQLError error) {
31-
if (error.getErrorType() == ErrorType.DataFetchingException) {
32-
return extractException(error).map(this::transform).orElse(defaultError(error.getMessage()));
33-
}
34-
35-
return defaultError(error.getMessage());
31+
return extractException(error).map(this::transform).orElse(defaultError(error.getMessage()));
3632
}
3733

3834
private Optional<Throwable> extractException(GraphQLError error) {
3935
if (error instanceof ExceptionWhileDataFetching) {
4036
return Optional.of(((ExceptionWhileDataFetching) error).getException());
4137
} else if (error instanceof SerializationError) {
4238
return Optional.of(((SerializationError) error).getException());
39+
} else if (error instanceof GraphQLException) {
40+
return Optional.of((GraphQLException) error);
4341
}
4442
return Optional.empty();
4543
}

0 commit comments

Comments
 (0)