Skip to content

Commit 9255803

Browse files
Upgrade Spring Boot to 3.2.12, DGS to 8.7.1
- DataFetcherExceptionHandler: onException -> handleException (CompletableFuture) Co-Authored-By: Travis Myers <travis.myers@cognition.ai>
1 parent 8110fe2 commit 9255803

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'org.springframework.boot' version '3.1.12'
2+
id 'org.springframework.boot' version '3.2.12'
33
id 'io.spring.dependency-management' version '1.1.4'
44
id 'java'
55
id "com.netflix.dgs.codegen" version "6.0.3"
@@ -36,7 +36,7 @@ dependencies {
3636
implementation 'org.springframework.boot:spring-boot-starter-hateoas'
3737
implementation 'org.springframework.boot:spring-boot-starter-security'
3838
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.3'
39-
implementation 'com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter:7.6.0'
39+
implementation 'com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter:8.7.1'
4040
implementation 'org.flywaydb:flyway-core'
4141
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
4242
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5',

src/main/java/io/spring/graphql/exception/GraphQLCustomizeExceptionHandler.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
import io.spring.api.exception.InvalidAuthenticationException;
1212
import io.spring.graphql.types.Error;
1313
import io.spring.graphql.types.ErrorItem;
14+
import jakarta.validation.ConstraintViolation;
15+
import jakarta.validation.ConstraintViolationException;
1416
import java.util.ArrayList;
1517
import java.util.Arrays;
1618
import java.util.HashMap;
1719
import java.util.List;
1820
import java.util.Map;
21+
import java.util.concurrent.CompletableFuture;
1922
import java.util.stream.Collectors;
20-
import jakarta.validation.ConstraintViolation;
21-
import jakarta.validation.ConstraintViolationException;
2223
import org.springframework.stereotype.Component;
2324

2425
@Component
@@ -28,7 +29,7 @@ public class GraphQLCustomizeExceptionHandler implements DataFetcherExceptionHan
2829
new DefaultDataFetcherExceptionHandler();
2930

3031
@Override
31-
public DataFetcherExceptionHandlerResult onException(
32+
public CompletableFuture<DataFetcherExceptionHandlerResult> handleException(
3233
DataFetcherExceptionHandlerParameters handlerParameters) {
3334
if (handlerParameters.getException() instanceof InvalidAuthenticationException) {
3435
GraphQLError graphqlError =
@@ -37,7 +38,8 @@ public DataFetcherExceptionHandlerResult onException(
3738
.message(handlerParameters.getException().getMessage())
3839
.path(handlerParameters.getPath())
3940
.build();
40-
return DataFetcherExceptionHandlerResult.newResult().error(graphqlError).build();
41+
return CompletableFuture.completedFuture(
42+
DataFetcherExceptionHandlerResult.newResult().error(graphqlError).build());
4143
} else if (handlerParameters.getException() instanceof ConstraintViolationException) {
4244
List<FieldErrorResource> errors = new ArrayList<>();
4345
for (ConstraintViolation<?> violation :
@@ -61,9 +63,10 @@ public DataFetcherExceptionHandlerResult onException(
6163
.path(handlerParameters.getPath())
6264
.extensions(errorsToMap(errors))
6365
.build();
64-
return DataFetcherExceptionHandlerResult.newResult().error(graphqlError).build();
66+
return CompletableFuture.completedFuture(
67+
DataFetcherExceptionHandlerResult.newResult().error(graphqlError).build());
6568
} else {
66-
return defaultHandler.onException(handlerParameters);
69+
return defaultHandler.handleException(handlerParameters);
6770
}
6871
}
6972

0 commit comments

Comments
 (0)