From 0338607a9b1e549b83f1bfa98bd43bd85c0964b5 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 8 Apr 2021 20:36:39 +0100 Subject: [PATCH] Parameterize GraphQLRequestHandler This makes the contract more general and applicable to any GraphQL request, not necessary coupled to HTTP. Closes gh-42 --- .../boot/WebFluxGraphQLAutoConfiguration.java | 15 ++- .../boot/WebMvcGraphQLAutoConfiguration.java | 15 ++- ... => AbstractWebGraphQLRequestHandler.java} | 8 +- ...a => DefaultWebGraphQLRequestHandler.java} | 8 +- .../graphql/GraphQLRequestHandler.java | 7 +- .../springframework/graphql/RequestInput.java | 104 ++++++++++++++++++ .../org/springframework/graphql/WebInput.java | 78 +------------ .../graphql/webflux/GraphQLHttpHandler.java | 5 +- .../webflux/GraphQLWebSocketHandler.java | 5 +- .../graphql/webmvc/GraphQLHttpHandler.java | 5 +- .../webmvc/GraphQLWebSocketHandler.java | 5 +- ...DefaultWebGraphQLRequestHandlerTests.java} | 6 +- .../webflux/GraphQLWebSocketHandlerTests.java | 4 +- .../webmvc/GraphQLWebSocketHandlerTests.java | 4 +- 14 files changed, 160 insertions(+), 109 deletions(-) rename spring-graphql-web/src/main/java/org/springframework/graphql/{AbstractInterceptingGraphQLRequestHandler.java => AbstractWebGraphQLRequestHandler.java} (88%) rename spring-graphql-web/src/main/java/org/springframework/graphql/{DefaultGraphQLRequestHandler.java => DefaultWebGraphQLRequestHandler.java} (78%) create mode 100644 spring-graphql-web/src/main/java/org/springframework/graphql/RequestInput.java rename spring-graphql-web/src/test/java/org/springframework/graphql/{DefaultGraphQLRequestHandlerTests.java => DefaultWebGraphQLRequestHandlerTests.java} (94%) diff --git a/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/WebFluxGraphQLAutoConfiguration.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/WebFluxGraphQLAutoConfiguration.java index d8ede1c5..06bf41d6 100644 --- a/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/WebFluxGraphQLAutoConfiguration.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/WebFluxGraphQLAutoConfiguration.java @@ -34,9 +34,11 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; -import org.springframework.graphql.DefaultGraphQLRequestHandler; +import org.springframework.graphql.DefaultWebGraphQLRequestHandler; import org.springframework.graphql.GraphQLRequestHandler; +import org.springframework.graphql.WebInput; import org.springframework.graphql.WebInterceptor; +import org.springframework.graphql.WebOutput; import org.springframework.graphql.webflux.GraphQLHttpHandler; import org.springframework.graphql.webflux.GraphQLWebSocketHandler; import org.springframework.http.MediaType; @@ -63,15 +65,17 @@ public class WebFluxGraphQLAutoConfiguration { @Bean @ConditionalOnMissingBean - public GraphQLRequestHandler graphQLRequestHandler(GraphQL graphQL, ObjectProvider interceptors) { - DefaultGraphQLRequestHandler handler = new DefaultGraphQLRequestHandler(graphQL); + public GraphQLRequestHandler graphQLRequestHandler( + GraphQL graphQL, ObjectProvider interceptors) { + + DefaultWebGraphQLRequestHandler handler = new DefaultWebGraphQLRequestHandler(graphQL); handler.setInterceptors(interceptors.orderedStream().collect(Collectors.toList())); return handler; } @Bean @ConditionalOnMissingBean - public GraphQLHttpHandler graphQLHandler(GraphQLRequestHandler requestHandler) { + public GraphQLHttpHandler graphQLHandler(GraphQLRequestHandler requestHandler) { return new GraphQLHttpHandler(requestHandler); } @@ -98,7 +102,8 @@ public class WebFluxGraphQLAutoConfiguration { @Bean @ConditionalOnMissingBean public GraphQLWebSocketHandler graphQLWebSocketHandler( - GraphQLRequestHandler handler, GraphQLProperties properties, ServerCodecConfigurer configurer) { + GraphQLRequestHandler handler, GraphQLProperties properties, + ServerCodecConfigurer configurer) { return new GraphQLWebSocketHandler( handler, configurer, properties.getWebsocket().getConnectionInitTimeout()); diff --git a/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/WebMvcGraphQLAutoConfiguration.java b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/WebMvcGraphQLAutoConfiguration.java index 9b4a7ab2..64680199 100644 --- a/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/WebMvcGraphQLAutoConfiguration.java +++ b/graphql-spring-boot-starter/src/main/java/org/springframework/graphql/boot/WebMvcGraphQLAutoConfiguration.java @@ -38,9 +38,11 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; -import org.springframework.graphql.DefaultGraphQLRequestHandler; +import org.springframework.graphql.DefaultWebGraphQLRequestHandler; import org.springframework.graphql.GraphQLRequestHandler; +import org.springframework.graphql.WebInput; import org.springframework.graphql.WebInterceptor; +import org.springframework.graphql.WebOutput; import org.springframework.graphql.webmvc.GraphQLHttpHandler; import org.springframework.graphql.webmvc.GraphQLWebSocketHandler; import org.springframework.http.HttpHeaders; @@ -70,15 +72,17 @@ public class WebMvcGraphQLAutoConfiguration { @Bean @ConditionalOnMissingBean - public GraphQLRequestHandler graphQLRequestHandler(GraphQL graphQL, ObjectProvider interceptors) { - DefaultGraphQLRequestHandler handler = new DefaultGraphQLRequestHandler(graphQL); + public GraphQLRequestHandler graphQLRequestHandler( + GraphQL graphQL, ObjectProvider interceptors) { + + DefaultWebGraphQLRequestHandler handler = new DefaultWebGraphQLRequestHandler(graphQL); handler.setInterceptors(interceptors.orderedStream().collect(Collectors.toList())); return handler; } @Bean @ConditionalOnMissingBean - public GraphQLHttpHandler graphQLHandler(GraphQLRequestHandler requestHandler) { + public GraphQLHttpHandler graphQLHandler(GraphQLRequestHandler requestHandler) { return new GraphQLHttpHandler(requestHandler); } @@ -107,7 +111,8 @@ public class WebMvcGraphQLAutoConfiguration { @Bean @ConditionalOnMissingBean public GraphQLWebSocketHandler graphQLWebSocketHandler( - GraphQLRequestHandler handler, GraphQLProperties properties, HttpMessageConverters converters) { + GraphQLRequestHandler handler, GraphQLProperties properties, + HttpMessageConverters converters) { HttpMessageConverter converter = converters.getConverters().stream() .filter(candidate -> candidate.canRead(Map.class, MediaType.APPLICATION_JSON)) diff --git a/spring-graphql-web/src/main/java/org/springframework/graphql/AbstractInterceptingGraphQLRequestHandler.java b/spring-graphql-web/src/main/java/org/springframework/graphql/AbstractWebGraphQLRequestHandler.java similarity index 88% rename from spring-graphql-web/src/main/java/org/springframework/graphql/AbstractInterceptingGraphQLRequestHandler.java rename to spring-graphql-web/src/main/java/org/springframework/graphql/AbstractWebGraphQLRequestHandler.java index db5c72c3..f452f4d3 100644 --- a/spring-graphql-web/src/main/java/org/springframework/graphql/AbstractInterceptingGraphQLRequestHandler.java +++ b/spring-graphql-web/src/main/java/org/springframework/graphql/AbstractWebGraphQLRequestHandler.java @@ -24,10 +24,12 @@ import graphql.ExecutionResult; import reactor.core.publisher.Mono; /** - * Base class for {@link GraphQLRequestHandler} implementations that support a - * {@link WebInterceptor} chain. + * Base class for {@link GraphQLRequestHandler} implementations that supports + * customizations of request handling through a {@link WebInterceptor} chain. + * Sub-classes must implement {@link #handleInternal(ExecutionInput)} for the + * actual handling of the GraphQL query. */ -public abstract class AbstractInterceptingGraphQLRequestHandler implements GraphQLRequestHandler { +public abstract class AbstractWebGraphQLRequestHandler implements GraphQLRequestHandler { private final List interceptors = new ArrayList<>(); diff --git a/spring-graphql-web/src/main/java/org/springframework/graphql/DefaultGraphQLRequestHandler.java b/spring-graphql-web/src/main/java/org/springframework/graphql/DefaultWebGraphQLRequestHandler.java similarity index 78% rename from spring-graphql-web/src/main/java/org/springframework/graphql/DefaultGraphQLRequestHandler.java rename to spring-graphql-web/src/main/java/org/springframework/graphql/DefaultWebGraphQLRequestHandler.java index 984aae51..49871d7e 100644 --- a/spring-graphql-web/src/main/java/org/springframework/graphql/DefaultGraphQLRequestHandler.java +++ b/spring-graphql-web/src/main/java/org/springframework/graphql/DefaultWebGraphQLRequestHandler.java @@ -22,15 +22,15 @@ import graphql.ExecutionResult; import graphql.GraphQL; /** - * Default implementation that invokes {@link GraphQL} and supports a - * {@link WebInterceptor} chain for pre- and post-handling. + * Extension of {@link AbstractWebGraphQLRequestHandler} that simply delegates + * to {@link GraphQL}to execute the request. */ -public class DefaultGraphQLRequestHandler extends AbstractInterceptingGraphQLRequestHandler { +public class DefaultWebGraphQLRequestHandler extends AbstractWebGraphQLRequestHandler { private final GraphQL graphQL; - public DefaultGraphQLRequestHandler(GraphQL graphQL) { + public DefaultWebGraphQLRequestHandler(GraphQL graphQL) { this.graphQL = graphQL; } diff --git a/spring-graphql-web/src/main/java/org/springframework/graphql/GraphQLRequestHandler.java b/spring-graphql-web/src/main/java/org/springframework/graphql/GraphQLRequestHandler.java index 66971334..339dae7d 100644 --- a/spring-graphql-web/src/main/java/org/springframework/graphql/GraphQLRequestHandler.java +++ b/spring-graphql-web/src/main/java/org/springframework/graphql/GraphQLRequestHandler.java @@ -15,19 +15,20 @@ */ package org.springframework.graphql; +import graphql.ExecutionResult; import reactor.core.publisher.Mono; /** * Contract to handle a GraphQL request. */ @FunctionalInterface -public interface GraphQLRequestHandler { +public interface GraphQLRequestHandler { /** * Handle the request and return the result of execution. - * @param input the GraphQL query + * @param input the GraphQL query container * @return the execution result */ - Mono handle(WebInput input); + Mono handle(I input); } diff --git a/spring-graphql-web/src/main/java/org/springframework/graphql/RequestInput.java b/spring-graphql-web/src/main/java/org/springframework/graphql/RequestInput.java new file mode 100644 index 00000000..875032ae --- /dev/null +++ b/spring-graphql-web/src/main/java/org/springframework/graphql/RequestInput.java @@ -0,0 +1,104 @@ +/* + * Copyright 2002-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.graphql; + +import java.util.Collections; +import java.util.Map; + +import graphql.ExecutionInput; + +import org.springframework.lang.Nullable; +import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; +import org.springframework.web.server.ServerWebInputException; + +/** + * Container for a GraphQL request. + */ +public class RequestInput { + + protected final String query; + + @Nullable + protected final String operationName; + + protected final Map variables; + + + @SuppressWarnings("unchecked") + public RequestInput(Map body) { + Assert.notNull(body, "'body' is required'"); + this.query = getAndValidateQuery(body); + this.operationName = (String) body.get("operationName"); + this.variables = (body.get("variables") != null ? + (Map) body.get("variables") : Collections.emptyMap()); + } + + private static String getAndValidateQuery(Map body) { + String query = (String) body.get("query"); + if (!StringUtils.hasText(query)) { + throw new ServerWebInputException("Query is required"); + } + return query; + } + + /** + * Return the query name extracted from the request body. This is guaranteed + * to be a non-empty string, or otherwise the request is rejected via + * {@link ServerWebInputException} as a 400 error. + */ + public String query() { + return this.query; + } + + /** + * Return the query operation name extracted from the request body or + * {@code null} if not provided. + */ + @Nullable + public String operationName() { + return this.operationName; + } + + /** + * Return the query variables that can be referenced via $syntax extracted + * from the request body or a {@code null} if not provided. + */ + public Map variables() { + return this.variables; + } + + /** + * Create an {@link ExecutionInput} initialized with the {@link #query()}, + * {@link #operationName()}, and {@link #variables()}. + */ + public ExecutionInput toExecutionInput() { + return ExecutionInput.newExecutionInput() + .query(query()) + .operationName(operationName()) + .variables(variables()) + .build(); + } + + @Override + public String toString() { + return "Query='" + query() + "'" + + (operationName() != null ? ", Operation='" + operationName() + "'" : "") + + (!CollectionUtils.isEmpty(variables()) ? ", Variables=" + variables() : ""); + } + +} diff --git a/spring-graphql-web/src/main/java/org/springframework/graphql/WebInput.java b/spring-graphql-web/src/main/java/org/springframework/graphql/WebInput.java index 310ee8e5..4d0f8459 100644 --- a/spring-graphql-web/src/main/java/org/springframework/graphql/WebInput.java +++ b/spring-graphql-web/src/main/java/org/springframework/graphql/WebInput.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2020 the original author or authors. + * Copyright 2020-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,17 +16,10 @@ package org.springframework.graphql; import java.net.URI; -import java.util.Collections; import java.util.Map; -import graphql.ExecutionInput; - import org.springframework.http.HttpHeaders; -import org.springframework.lang.Nullable; import org.springframework.util.Assert; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; -import org.springframework.web.server.ServerWebInputException; import org.springframework.web.util.UriComponents; import org.springframework.web.util.UriComponentsBuilder; @@ -35,38 +28,19 @@ import org.springframework.web.util.UriComponentsBuilder; * {@link UriComponents URL} and the headers of the request, as well as the * query name, operation name, and variables from the request body. */ -public class WebInput { +public class WebInput extends RequestInput { private final UriComponents uri; private final HttpHeaders headers; - private final String query; - @Nullable - private final String operationName; - - private final Map variables; - - - @SuppressWarnings("unchecked") public WebInput(URI uri, HttpHeaders headers, Map body) { + super(body); Assert.notNull(uri, "URI is required'"); - Assert.notNull(body, "HttpHeaders is required'"); - Assert.notNull(body, "'body' is required'"); + Assert.notNull(headers, "HttpHeaders is required'"); this.uri = UriComponentsBuilder.fromUri(uri).build(true); this.headers = headers; - this.query = getAndValidateQuery(body); - this.operationName = (String) body.get("operationName"); - this.variables = (Map) (body.get("variables") != null ? body.get("variables"): Collections.emptyMap()); - } - - private static String getAndValidateQuery(Map body) { - String query = (String) body.get("query"); - if (!StringUtils.hasText(query)) { - throw new ServerWebInputException("Query is required"); - } - return query; } @@ -85,48 +59,4 @@ public class WebInput { return this.headers; } - /** - * Return the query name extracted from the request body. This is guaranteed - * to be a non-empty string, or otherwise the request is rejected via - * {@link ServerWebInputException} as a 400 error. - */ - public String query() { - return this.query; - } - - /** - * Return the query operation name extracted from the request body or - * {@code null} if not provided. - */ - @Nullable - public String operationName() { - return this.operationName; - } - - /** - * Return the query variables that can be referenced via $syntax extracted - * from the request body or a {@code null} if not provided. - */ - public Map variables() { - return this.variables; - } - - /** - * Create an {@link ExecutionInput} initialized with the {@link #query()}, - * {@link #operationName()}, and {@link #variables()}. - */ - public ExecutionInput toExecutionInput() { - return ExecutionInput.newExecutionInput() - .query(query()) - .operationName(operationName()) - .variables(variables()) - .build(); - } - - @Override - public String toString() { - return "Query='" + query() + "'" + - (operationName() != null ? ", Operation='" + operationName() + "'" : "") + - (!CollectionUtils.isEmpty(variables()) ? ", Variables=" + variables() : ""); - } } \ No newline at end of file diff --git a/spring-graphql-web/src/main/java/org/springframework/graphql/webflux/GraphQLHttpHandler.java b/spring-graphql-web/src/main/java/org/springframework/graphql/webflux/GraphQLHttpHandler.java index fb1ab4f8..fde5a2eb 100644 --- a/spring-graphql-web/src/main/java/org/springframework/graphql/webflux/GraphQLHttpHandler.java +++ b/spring-graphql-web/src/main/java/org/springframework/graphql/webflux/GraphQLHttpHandler.java @@ -24,6 +24,7 @@ import reactor.core.publisher.Mono; import org.springframework.core.ParameterizedTypeReference; import org.springframework.graphql.GraphQLRequestHandler; import org.springframework.graphql.WebInput; +import org.springframework.graphql.WebOutput; import org.springframework.util.Assert; import org.springframework.web.reactive.function.server.ServerRequest; import org.springframework.web.reactive.function.server.ServerResponse; @@ -39,14 +40,14 @@ public class GraphQLHttpHandler { new ParameterizedTypeReference>() {}; - private final GraphQLRequestHandler requestHandler; + private final GraphQLRequestHandler requestHandler; /** * Create a new instance. * @param requestHandler the handler to use for GraphQL query handling */ - public GraphQLHttpHandler(GraphQLRequestHandler requestHandler) { + public GraphQLHttpHandler(GraphQLRequestHandler requestHandler) { Assert.notNull(requestHandler, "GraphQLRequestHandler is required"); this.requestHandler = requestHandler; } diff --git a/spring-graphql-web/src/main/java/org/springframework/graphql/webflux/GraphQLWebSocketHandler.java b/spring-graphql-web/src/main/java/org/springframework/graphql/webflux/GraphQLWebSocketHandler.java index ae8f46f6..edfb8857 100644 --- a/spring-graphql-web/src/main/java/org/springframework/graphql/webflux/GraphQLWebSocketHandler.java +++ b/spring-graphql-web/src/main/java/org/springframework/graphql/webflux/GraphQLWebSocketHandler.java @@ -40,6 +40,7 @@ import org.springframework.core.codec.Encoder; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.graphql.GraphQLRequestHandler; +import org.springframework.graphql.WebInput; import org.springframework.graphql.WebOutput; import org.springframework.graphql.WebSocketMessageInput; import org.springframework.http.MediaType; @@ -72,7 +73,7 @@ public class GraphQLWebSocketHandler implements WebSocketHandler { ResolvableType.forType(new ParameterizedTypeReference>() {}); - private final GraphQLRequestHandler requestHandler; + private final GraphQLRequestHandler requestHandler; private final Decoder decoder; @@ -88,7 +89,7 @@ public class GraphQLWebSocketHandler implements WebSocketHandler { * @param connectionInitTimeout the time within which the {@code CONNECTION_INIT} * type message must be received. */ - public GraphQLWebSocketHandler(GraphQLRequestHandler requestHandler, + public GraphQLWebSocketHandler(GraphQLRequestHandler requestHandler, ServerCodecConfigurer configurer, Duration connectionInitTimeout) { Assert.notNull(requestHandler, "GraphQLRequestHandler is required"); diff --git a/spring-graphql-web/src/main/java/org/springframework/graphql/webmvc/GraphQLHttpHandler.java b/spring-graphql-web/src/main/java/org/springframework/graphql/webmvc/GraphQLHttpHandler.java index 84cf86bc..0c4be48b 100644 --- a/spring-graphql-web/src/main/java/org/springframework/graphql/webmvc/GraphQLHttpHandler.java +++ b/spring-graphql-web/src/main/java/org/springframework/graphql/webmvc/GraphQLHttpHandler.java @@ -27,6 +27,7 @@ import reactor.core.publisher.Mono; import org.springframework.core.ParameterizedTypeReference; import org.springframework.graphql.GraphQLRequestHandler; import org.springframework.graphql.WebInput; +import org.springframework.graphql.WebOutput; import org.springframework.util.Assert; import org.springframework.web.HttpMediaTypeNotSupportedException; import org.springframework.web.server.ServerWebInputException; @@ -45,14 +46,14 @@ public class GraphQLHttpHandler { new ParameterizedTypeReference>() {}; - private final GraphQLRequestHandler requestHandler; + private final GraphQLRequestHandler requestHandler; /** * Create a new instance. * @param requestHandler the handler to use for GraphQL query handling */ - public GraphQLHttpHandler(GraphQLRequestHandler requestHandler) { + public GraphQLHttpHandler(GraphQLRequestHandler requestHandler) { Assert.notNull(requestHandler, "GraphQLRequestHandler is required"); this.requestHandler = requestHandler; } diff --git a/spring-graphql-web/src/main/java/org/springframework/graphql/webmvc/GraphQLWebSocketHandler.java b/spring-graphql-web/src/main/java/org/springframework/graphql/webmvc/GraphQLWebSocketHandler.java index 0357d552..d20a74df 100644 --- a/spring-graphql-web/src/main/java/org/springframework/graphql/webmvc/GraphQLWebSocketHandler.java +++ b/spring-graphql-web/src/main/java/org/springframework/graphql/webmvc/GraphQLWebSocketHandler.java @@ -42,6 +42,7 @@ import reactor.core.scheduler.Scheduler; import reactor.core.scheduler.Schedulers; import org.springframework.graphql.GraphQLRequestHandler; +import org.springframework.graphql.WebInput; import org.springframework.graphql.WebOutput; import org.springframework.graphql.WebSocketMessageInput; import org.springframework.http.HttpHeaders; @@ -71,7 +72,7 @@ public class GraphQLWebSocketHandler extends TextWebSocketHandler implements Sub Arrays.asList("graphql-transport-ws", "subscriptions-transport-ws"); - private final GraphQLRequestHandler requestHandler; + private final GraphQLRequestHandler requestHandler; private final Duration initTimeoutDuration; @@ -88,7 +89,7 @@ public class GraphQLWebSocketHandler extends TextWebSocketHandler implements Sub * type message must be received. */ public GraphQLWebSocketHandler( - GraphQLRequestHandler requestHandler, HttpMessageConverter converter, + GraphQLRequestHandler requestHandler, HttpMessageConverter converter, Duration connectionInitTimeout) { Assert.notNull(converter, "HttpMessageConverter for JSON is required"); diff --git a/spring-graphql-web/src/test/java/org/springframework/graphql/DefaultGraphQLRequestHandlerTests.java b/spring-graphql-web/src/test/java/org/springframework/graphql/DefaultWebGraphQLRequestHandlerTests.java similarity index 94% rename from spring-graphql-web/src/test/java/org/springframework/graphql/DefaultGraphQLRequestHandlerTests.java rename to spring-graphql-web/src/test/java/org/springframework/graphql/DefaultWebGraphQLRequestHandlerTests.java index 6fe9f81d..a17e1cbe 100644 --- a/spring-graphql-web/src/test/java/org/springframework/graphql/DefaultGraphQLRequestHandlerTests.java +++ b/spring-graphql-web/src/test/java/org/springframework/graphql/DefaultWebGraphQLRequestHandlerTests.java @@ -40,9 +40,9 @@ import static graphql.schema.idl.TypeRuntimeWiring.newTypeWiring; import static org.assertj.core.api.Assertions.assertThat; /** - * Unit tests for {@link DefaultGraphQLRequestHandler}. + * Unit tests for {@link DefaultWebGraphQLRequestHandler}. */ -public class DefaultGraphQLRequestHandlerTests { +public class DefaultWebGraphQLRequestHandlerTests { @Test void testInterceptorInvocation() throws Exception { @@ -64,7 +64,7 @@ public class DefaultGraphQLRequestHandlerTests { Map body = mapper.reader().readValue("{\"query\": \"" + query + "\"}", Map.class); WebInput webInput = new WebInput(URI.create("/graphql"), new HttpHeaders(), body); - DefaultGraphQLRequestHandler requestHandler = new DefaultGraphQLRequestHandler(createGraphQL()); + DefaultWebGraphQLRequestHandler requestHandler = new DefaultWebGraphQLRequestHandler(createGraphQL()); requestHandler.setInterceptors(interceptors); WebOutput webOutput = requestHandler.handle(webInput).block(); diff --git a/spring-graphql-web/src/test/java/org/springframework/graphql/webflux/GraphQLWebSocketHandlerTests.java b/spring-graphql-web/src/test/java/org/springframework/graphql/webflux/GraphQLWebSocketHandlerTests.java index f327ff78..03edc449 100644 --- a/spring-graphql-web/src/test/java/org/springframework/graphql/webflux/GraphQLWebSocketHandlerTests.java +++ b/spring-graphql-web/src/test/java/org/springframework/graphql/webflux/GraphQLWebSocketHandlerTests.java @@ -42,7 +42,7 @@ import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.graphql.ConsumeOneAndNeverCompleteInterceptor; -import org.springframework.graphql.DefaultGraphQLRequestHandler; +import org.springframework.graphql.DefaultWebGraphQLRequestHandler; import org.springframework.graphql.GraphQLDataFetchers; import org.springframework.graphql.WebInterceptor; import org.springframework.http.HttpHeaders; @@ -280,7 +280,7 @@ public class GraphQLWebSocketHandlerTests { GraphQL graphQL = initGraphQL(); - DefaultGraphQLRequestHandler requestHandler = new DefaultGraphQLRequestHandler(graphQL); + DefaultWebGraphQLRequestHandler requestHandler = new DefaultWebGraphQLRequestHandler(graphQL); if (interceptors != null) { requestHandler.setInterceptors(interceptors); } diff --git a/spring-graphql-web/src/test/java/org/springframework/graphql/webmvc/GraphQLWebSocketHandlerTests.java b/spring-graphql-web/src/test/java/org/springframework/graphql/webmvc/GraphQLWebSocketHandlerTests.java index f36c5dcb..6448b6cd 100644 --- a/spring-graphql-web/src/test/java/org/springframework/graphql/webmvc/GraphQLWebSocketHandlerTests.java +++ b/spring-graphql-web/src/test/java/org/springframework/graphql/webmvc/GraphQLWebSocketHandlerTests.java @@ -37,7 +37,7 @@ import org.junit.jupiter.api.Test; import reactor.test.StepVerifier; import org.springframework.graphql.ConsumeOneAndNeverCompleteInterceptor; -import org.springframework.graphql.DefaultGraphQLRequestHandler; +import org.springframework.graphql.DefaultWebGraphQLRequestHandler; import org.springframework.graphql.GraphQLDataFetchers; import org.springframework.graphql.WebInterceptor; import org.springframework.http.HttpHeaders; @@ -264,7 +264,7 @@ public class GraphQLWebSocketHandlerTests { try { GraphQL graphQL = initGraphQL(); - DefaultGraphQLRequestHandler requestHandler = new DefaultGraphQLRequestHandler(graphQL); + DefaultWebGraphQLRequestHandler requestHandler = new DefaultWebGraphQLRequestHandler(graphQL); if (interceptors != null) { requestHandler.setInterceptors(interceptors); }