Fix build with latest Spring for GraphQL changes
This commit is contained in:
@@ -26,7 +26,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.graphql.servlet.GraphQlWebMvcAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.graphql.execution.SecurityContextThreadLocalAccessor;
|
||||
import org.springframework.graphql.execution.SecurityDataFetcherExceptionResolver;
|
||||
import org.springframework.graphql.server.webmvc.GraphQlHttpHandler;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
@@ -50,10 +49,4 @@ public class GraphQlWebMvcSecurityAutoConfiguration {
|
||||
return new SecurityDataFetcherExceptionResolver();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SecurityContextThreadLocalAccessor securityContextThreadLocalAccessor() {
|
||||
return new SecurityContextThreadLocalAccessor();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.log.LogMessage;
|
||||
import org.springframework.graphql.ExecutionGraphQlService;
|
||||
import org.springframework.graphql.execution.GraphQlSource;
|
||||
import org.springframework.graphql.execution.ThreadLocalAccessor;
|
||||
import org.springframework.graphql.server.WebGraphQlHandler;
|
||||
import org.springframework.graphql.server.WebGraphQlInterceptor;
|
||||
import org.springframework.graphql.server.webmvc.GraphQlHttpHandler;
|
||||
@@ -98,11 +97,9 @@ public class GraphQlWebMvcAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public WebGraphQlHandler webGraphQlHandler(ExecutionGraphQlService service,
|
||||
ObjectProvider<WebGraphQlInterceptor> interceptorsProvider,
|
||||
ObjectProvider<ThreadLocalAccessor> accessorsProvider) {
|
||||
ObjectProvider<WebGraphQlInterceptor> interceptorsProvider) {
|
||||
return WebGraphQlHandler.builder(service)
|
||||
.interceptors(interceptorsProvider.orderedStream().collect(Collectors.toList()))
|
||||
.threadLocalAccessors(accessorsProvider.orderedStream().collect(Collectors.toList())).build();
|
||||
.interceptors(interceptorsProvider.orderedStream().collect(Collectors.toList())).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -185,13 +182,14 @@ public class GraphQlWebMvcAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings("deprecation")
|
||||
public HandlerMapping graphQlWebSocketMapping(GraphQlWebSocketHandler handler, GraphQlProperties properties) {
|
||||
String path = properties.getWebsocket().getPath();
|
||||
logger.info(LogMessage.format("GraphQL endpoint WebSocket %s", path));
|
||||
WebSocketHandlerMapping mapping = new WebSocketHandlerMapping();
|
||||
mapping.setWebSocketUpgradeMatch(true);
|
||||
mapping.setUrlMap(Collections.singletonMap(path,
|
||||
handler.asWebSocketHttpRequestHandler(new DefaultHandshakeHandler())));
|
||||
handler.initWebSocketHttpRequestHandler(new DefaultHandshakeHandler())));
|
||||
mapping.setOrder(2); // Ahead of HTTP endpoint ("routerFunctionMapping" bean)
|
||||
return mapping;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.graphql.execution.ErrorType;
|
||||
import org.springframework.graphql.execution.RuntimeWiringConfigurer;
|
||||
import org.springframework.graphql.execution.SecurityContextThreadLocalAccessor;
|
||||
import org.springframework.graphql.execution.SecurityDataFetcherExceptionResolver;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -78,10 +77,8 @@ class GraphQlWebMvcSecurityAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void contributesSecurityComponents() {
|
||||
this.contextRunner.run((context) -> {
|
||||
assertThat(context).hasSingleBean(SecurityDataFetcherExceptionResolver.class);
|
||||
assertThat(context).hasSingleBean(SecurityContextThreadLocalAccessor.class);
|
||||
});
|
||||
this.contextRunner
|
||||
.run((context) -> assertThat(context).hasSingleBean(SecurityDataFetcherExceptionResolver.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user