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

Commit b7d879b

Browse files
author
Tad Sanden
committed
use ApplicationReadyEvent to init error handler
1 parent 13861e3 commit b7d879b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

graphql-kickstart-spring-support/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ dependencies {
22
compileOnly "com.graphql-java-kickstart:graphql-java-kickstart:$LIB_GRAPHQL_SERVLET_VER"
33
compileOnly "org.springframework:spring-web:$LIB_SPRING_CORE_VER"
44
compileOnly "org.springframework:spring-context:$LIB_SPRING_CORE_VER"
5+
compileOnly "org.springframework.boot:spring-boot-starter-web:$LIB_SPRING_BOOT_VER"
56

67
testCompile "com.graphql-java-kickstart:graphql-java-kickstart:$LIB_GRAPHQL_SERVLET_VER"
78
testCompile "com.graphql-java:graphql-java:$LIB_GRAPHQL_JAVA_VER"
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package graphql.kickstart.spring.error;
22

33
import graphql.kickstart.execution.error.GraphQLErrorHandler;
4+
import org.springframework.boot.context.event.ApplicationReadyEvent;
45
import org.springframework.context.ApplicationListener;
56
import org.springframework.context.ConfigurableApplicationContext;
6-
import org.springframework.context.event.ContextRefreshedEvent;
77
import org.springframework.lang.NonNull;
88

9-
public class GraphQLErrorStartupListener implements ApplicationListener<ContextRefreshedEvent> {
9+
public class GraphQLErrorStartupListener implements ApplicationListener<ApplicationReadyEvent> {
1010

1111
private final ErrorHandlerSupplier errorHandlerSupplier;
1212
private final boolean exceptionHandlersEnabled;
@@ -17,11 +17,10 @@ public GraphQLErrorStartupListener(ErrorHandlerSupplier errorHandlerSupplier, bo
1717
}
1818

1919
@Override
20-
public void onApplicationEvent(@NonNull ContextRefreshedEvent event) {
21-
ConfigurableApplicationContext context = (ConfigurableApplicationContext) event.getApplicationContext();
20+
public void onApplicationEvent(@NonNull ApplicationReadyEvent event) {
21+
ConfigurableApplicationContext context = event.getApplicationContext();
2222
GraphQLErrorHandler errorHandler = new GraphQLErrorHandlerFactory().create(context, exceptionHandlersEnabled);
2323
context.getBeanFactory().registerSingleton(errorHandler.getClass().getCanonicalName(), errorHandler);
2424
errorHandlerSupplier.setErrorHandler(errorHandler);
2525
}
26-
2726
}

0 commit comments

Comments
 (0)