From 7c7a32a5681172bb0111f06aa092c22bfaf5b3ad Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Tue, 19 Jul 2022 16:53:11 +0200 Subject: [PATCH] Auto-configure GraphQL subscription exception handling Closes gh-31794 --- .../boot/autoconfigure/graphql/GraphQlAutoConfiguration.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java index 6b19ade6a1..bc90f07e5c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.java @@ -50,6 +50,7 @@ import org.springframework.graphql.execution.DefaultBatchLoaderRegistry; import org.springframework.graphql.execution.DefaultExecutionGraphQlService; import org.springframework.graphql.execution.GraphQlSource; import org.springframework.graphql.execution.RuntimeWiringConfigurer; +import org.springframework.graphql.execution.SubscriptionExceptionResolver; /** * {@link EnableAutoConfiguration Auto-configuration} for creating a Spring GraphQL base @@ -76,6 +77,7 @@ public class GraphQlAutoConfiguration { @ConditionalOnMissingBean public GraphQlSource graphQlSource(ResourcePatternResolver resourcePatternResolver, GraphQlProperties properties, ObjectProvider exceptionResolvers, + ObjectProvider subscriptionExceptionResolvers, ObjectProvider instrumentations, ObjectProvider wiringConfigurers, ObjectProvider sourceCustomizers) { String[] schemaLocations = properties.getSchema().getLocations(); @@ -83,6 +85,7 @@ public class GraphQlAutoConfiguration { properties.getSchema().getFileExtensions()); GraphQlSource.SchemaResourceBuilder builder = GraphQlSource.schemaResourceBuilder() .schemaResources(schemaResources).exceptionResolvers(toList(exceptionResolvers)) + .subscriptionExceptionResolvers(toList(subscriptionExceptionResolvers)) .instrumentation(toList(instrumentations)); if (!properties.getSchema().getIntrospection().isEnabled()) { builder.configureRuntimeWiring(this::enableIntrospection);