Skip to content

Commit

Permalink
graphql-java 21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartisk committed Oct 4, 2023
1 parent 19c3acf commit 293068a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<version.jakarta.servlet>6.0.0</version.jakarta.servlet>
<version.jakarta.websocket>2.0.0</version.jakarta.websocket>
<version.graphql-java-federation>2.1.1</version.graphql-java-federation>
<version.graphql-java>20.2</version.graphql-java>
<version.graphql-java>21.1</version.graphql-java>
<verison.io.micrometer>1.11.3</verison.io.micrometer>
<version.vertx>4.4.1</version.vertx>
<version.smallrye-opentelemetry>2.4.0</version.smallrye-opentelemetry>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ public List<GraphQLError> toGraphQLErrors(DataFetchingEnvironment dfe, Throwable
.exception(t)
.build();

DataFetcherExceptionHandlerResult exceptionHandlerResult = exceptionHandler.onException(handlerParameters);
DataFetcherExceptionHandlerResult exceptionHandlerResult = null;
try {
exceptionHandlerResult = exceptionHandler.handleException(handlerParameters).get();
} catch (Exception e) {
// this should generally not happen - exceptionHandler.handleException doesn't do any IO and doesn't
// throw exceptions, so maybe only if we get interrupted at the right moment
throw new RuntimeException(e);
}

return exceptionHandlerResult.getErrors();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import static io.smallrye.graphql.SmallRyeGraphQLServerLogging.log;

import java.util.concurrent.CompletableFuture;

import graphql.ExceptionWhileDataFetching;
import graphql.execution.DataFetcherExceptionHandler;
import graphql.execution.DataFetcherExceptionHandlerParameters;
Expand All @@ -20,7 +22,8 @@ public class ExceptionHandler implements DataFetcherExceptionHandler {
private final Config config = Config.get();

@Override
public DataFetcherExceptionHandlerResult onException(DataFetcherExceptionHandlerParameters handlerParameters) {
public CompletableFuture<DataFetcherExceptionHandlerResult> handleException(
DataFetcherExceptionHandlerParameters handlerParameters) {
Throwable throwable = handlerParameters.getException();
throwable = unwrapThrowable(throwable);
SourceLocation sourceLocation = handlerParameters.getSourceLocation();
Expand All @@ -30,7 +33,8 @@ public DataFetcherExceptionHandlerResult onException(DataFetcherExceptionHandler
log.dataFetchingError(throwable);
}

return DataFetcherExceptionHandlerResult.newResult().error(error).build();
// we don't do any IO in this method, so we can just synchronously compute the result and return after that
return CompletableFuture.completedFuture(DataFetcherExceptionHandlerResult.newResult().error(error).build());
}

private ExceptionWhileDataFetching getExceptionWhileDataFetching(Throwable throwable, SourceLocation sourceLocation,
Expand Down

0 comments on commit 293068a

Please sign in to comment.