Polishing

This commit is contained in:
Rossen Stoyanchev
2020-09-18 17:44:21 +01:00
parent b0b10dd8d3
commit 40a79ab71a
6 changed files with 10 additions and 12 deletions

View File

@@ -41,12 +41,12 @@ public class WebFluxGraphQLAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public WebFluxGraphQLHandler graphQLHandler(GraphQL.Builder graphQLBuilder) {
return new WebFluxGraphQLHandler(graphQLBuilder, Collections.emptyList());
return new WebFluxGraphQLHandler(graphQLBuilder.build(), Collections.emptyList());
}
@Bean
public RouterFunction<ServerResponse> graphQLQueryEndpoint(WebFluxGraphQLHandler handler) {
return RouterFunctions.route().POST("/graphql", handler::handle).build();
return RouterFunctions.route().POST("/graphql", handler).build();
}
}

View File

@@ -44,13 +44,13 @@ public class WebMvcGraphQLAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public WebMvcGraphQLHandler graphQLHandler(GraphQL.Builder graphQLBuilder) {
return new WebMvcGraphQLHandler(graphQLBuilder, Collections.emptyList());
return new WebMvcGraphQLHandler(graphQLBuilder.build(), Collections.emptyList());
}
@Bean
public RouterFunction<ServerResponse> graphQLQueryEndpoint(WebMvcGraphQLHandler handler) {
return RouterFunctions.route()
.POST("/graphql", accept(MediaType.APPLICATION_JSON), handler::handle)
.POST("/graphql", accept(MediaType.APPLICATION_JSON), handler)
.build();
}

View File

@@ -31,8 +31,8 @@ import org.springframework.web.reactive.function.server.ServerResponse;
public class WebFluxGraphQLHandler extends WebHandlerSupport implements HandlerFunction<ServerResponse> {
public WebFluxGraphQLHandler(GraphQL.Builder builder, List<WebInterceptor> interceptors) {
super(builder, interceptors);
public WebFluxGraphQLHandler(GraphQL graphQL, List<WebInterceptor> interceptors) {
super(graphQL, interceptors);
}

View File

@@ -36,8 +36,8 @@ public abstract class WebHandlerSupport {
private final List<WebInterceptor> interceptors;
public WebHandlerSupport(GraphQL.Builder builder, List<WebInterceptor> interceptors) {
this.graphQL = builder.build();
public WebHandlerSupport(GraphQL graphQL, List<WebInterceptor> interceptors) {
this.graphQL = graphQL;
this.interceptors = (!CollectionUtils.isEmpty(interceptors) ?
Collections.unmodifiableList(new ArrayList<>(interceptors)) : Collections.emptyList());
}

View File

@@ -17,11 +17,9 @@ package org.springframework.graphql;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import graphql.ExecutionInput;
import reactor.core.publisher.Mono;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpHeaders;

View File

@@ -38,8 +38,8 @@ import org.springframework.web.servlet.function.ServerResponse;
public class WebMvcGraphQLHandler extends WebHandlerSupport implements HandlerFunction<ServerResponse> {
public WebMvcGraphQLHandler(GraphQL.Builder builder, List<WebInterceptor> interceptors) {
super(builder, interceptors);
public WebMvcGraphQLHandler(GraphQL graphQL, List<WebInterceptor> interceptors) {
super(graphQL, interceptors);
}