2121
2222import com .fasterxml .jackson .databind .InjectableValues ;
2323import com .fasterxml .jackson .databind .ObjectMapper ;
24+ import com .oembedler .moon .graphql .boot .error .ErrorHandlerSupplier ;
2425import com .oembedler .moon .graphql .boot .error .GraphQLErrorHandlerFactory ;
2526import com .oembedler .moon .graphql .boot .metrics .MetricsInstrumentation ;
2627import graphql .execution .AsyncExecutionStrategy ;
3031import graphql .execution .preparsed .PreparsedDocumentProvider ;
3132import graphql .schema .GraphQLSchema ;
3233import graphql .servlet .*;
34+ import lombok .extern .slf4j .Slf4j ;
3335import org .springframework .beans .BeansException ;
36+ import org .springframework .beans .factory .InitializingBean ;
3437import org .springframework .beans .factory .ObjectProvider ;
3538import org .springframework .beans .factory .annotation .Autowired ;
39+ import org .springframework .beans .factory .annotation .Value ;
3640import org .springframework .boot .autoconfigure .AutoConfigureAfter ;
3741import org .springframework .boot .autoconfigure .condition .*;
3842import org .springframework .boot .autoconfigure .jackson .JacksonAutoConfiguration ;
4852import org .springframework .web .servlet .DispatcherServlet ;
4953import org .springframework .web .servlet .config .annotation .CorsRegistryWorkaround ;
5054
55+ import javax .annotation .PostConstruct ;
5156import javax .servlet .MultipartConfigElement ;
5257import java .util .Collections ;
5358import java .util .List ;
6065/**
6166 * @author <a href="mailto:java.lang.RuntimeException@gmail.com">oEmbedler Inc.</a>
6267 */
68+ @ Slf4j
6369@ Configuration
6470@ ConditionalOnWebApplication
6571@ ConditionalOnClass (DispatcherServlet .class )
@@ -85,6 +91,8 @@ public class GraphQLWebAutoConfiguration implements ApplicationContextAware {
8591 @ Autowired (required = false )
8692 private GraphQLErrorHandler errorHandler ;
8793
94+ private ErrorHandlerSupplier errorHandlerSupplier = new ErrorHandlerSupplier (null );
95+
8896 @ Autowired (required = false )
8997 private Map <String , ExecutionStrategy > executionStrategies ;
9098
@@ -110,6 +118,7 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
110118 errorHandler = new GraphQLErrorHandlerFactory ().create (context , graphQLServletProperties .isExceptionHandlersEnabled ());
111119 context .getBeanFactory ().registerSingleton (errorHandler .getClass ().getCanonicalName (), errorHandler );
112120 }
121+ errorHandlerSupplier .setErrorHandler (errorHandler );
113122 }
114123
115124 @ Bean
@@ -203,9 +212,7 @@ public GraphQLQueryInvoker queryInvoker(ExecutionStrategyProvider executionStrat
203212 public GraphQLObjectMapper graphQLObjectMapper (ObjectProvider <ObjectMapperProvider > objectMapperProviderObjectProvider ) {
204213 GraphQLObjectMapper .Builder builder = newBuilder ();
205214
206- if (errorHandler != null ) {
207- builder .withGraphQLErrorHandler (errorHandler );
208- }
215+ builder .withGraphQLErrorHandler (errorHandlerSupplier );
209216
210217 ObjectMapperProvider objectMapperProvider = objectMapperProviderObjectProvider .getIfAvailable ();
211218
@@ -214,7 +221,7 @@ public GraphQLObjectMapper graphQLObjectMapper(ObjectProvider<ObjectMapperProvid
214221 } else if (objectMapperConfigurer != null ) {
215222 builder .withObjectMapperConfigurer (objectMapperConfigurer );
216223 }
217-
224+ log . info ( "Building GraphQLObjectMapper including errorHandler: {}" , errorHandler );
218225 return builder .build ();
219226 }
220227
0 commit comments