Shorten names of [Web|RSocket]GraphQlHandlerInterceptor
See gh-339
This commit is contained in:
@@ -118,16 +118,16 @@ The Spring for GraphQL repository contains a WebFlux
|
||||
|
||||
<<web-http>> and <<web-websocket>> transport handlers delegate to a common Web
|
||||
interception chain for request execution. The chain consists of a sequence of
|
||||
`WebGraphQlHandlerInterceptor` components, followed by a `ExecutionGraphQlService` that
|
||||
`WebGraphQlInterceptor` components, followed by a `ExecutionGraphQlService` that
|
||||
invokes GraphQL Java.
|
||||
|
||||
`WebGraphQlHandlerInterceptor` is as a common contract to use in both Spring MVC and
|
||||
`WebGraphQlInterceptor` is as a common contract to use in both Spring MVC and
|
||||
WebFlux applications. Use it to intercept requests, inspect HTTP request headers, or to
|
||||
register a transformation of the `graphql.ExecutionInput`:
|
||||
|
||||
[source,java,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
class MyInterceptor implements WebGraphQlHandlerInterceptor {
|
||||
class MyInterceptor implements WebGraphQlInterceptor {
|
||||
|
||||
@Override
|
||||
public Mono<WebGraphQlResponse> intercept(WebGraphQlRequest request, Chain chain) {
|
||||
@@ -140,12 +140,12 @@ class MyInterceptor implements WebGraphQlHandlerInterceptor {
|
||||
}
|
||||
----
|
||||
|
||||
Use `WebGraphQlHandlerInterceptor` also to intercept responses, add HTTP response headers,
|
||||
Use `WebGraphQlInterceptor` also to intercept responses, add HTTP response headers,
|
||||
or transform the `graphql.ExecutionResult`:
|
||||
|
||||
[source,java,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
class MyInterceptor implements WebGraphQlHandlerInterceptor {
|
||||
class MyInterceptor implements WebGraphQlInterceptor {
|
||||
|
||||
@Override
|
||||
public Mono<WebGraphQlResponse> intercept(WebGraphQlRequest request, Chain chain) {
|
||||
@@ -423,7 +423,7 @@ thread and Reactor `Context` from the WebFlux processing pipeline.
|
||||
|
||||
A `DataFetcher` and other components invoked by GraphQL Java may not always execute on
|
||||
the same thread as the Spring MVC handler, for example if an asynchronous
|
||||
<<web-interception, `WebGraphQlHandlerInterceptor`>> or `DataFetcher` switches to a
|
||||
<<web-interception, `WebGraphQlInterceptor`>> or `DataFetcher` switches to a
|
||||
different thread.
|
||||
|
||||
Spring for GraphQL supports propagating `ThreadLocal` values from the Servlet container
|
||||
@@ -468,7 +468,7 @@ Spring MVC application, see the
|
||||
|
||||
A <<execution-reactive-datafetcher>> can rely on access to Reactor context that
|
||||
originates from the WebFlux request handling chain. This includes Reactor context
|
||||
added by <<web-interception, WebGraphQlHandlerInterceptor>> components.
|
||||
added by <<web-interception, WebGraphQlInterceptor>> components.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ a client. However, in some cases it's useful to involve server side transport
|
||||
handling with given mock transport input.
|
||||
|
||||
The `WebGraphQlHandlerTester` extension lets you processes request through the
|
||||
`WebGraphQlHandlerInterceptor` chain before handing off to `ExecutionGraphQlService` for
|
||||
`WebGraphQlInterceptor` chain before handing off to `ExecutionGraphQlService` for
|
||||
request execution:
|
||||
|
||||
[source,java,indent=0,subs="verbatim,quotes"]
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.http.codec.CodecConfigurer;
|
||||
/**
|
||||
* Server-side tester, without a client, that executes requests through a
|
||||
* {@link WebGraphQlHandler}. Similar to {@link GraphQlServiceTester} but also
|
||||
* adding a web processing layer with a {@code WebGraphQlHandlerInterceptor}
|
||||
* adding a web processing layer with a {@code WebGraphQlInterceptor}
|
||||
* chain.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.springframework.graphql.web.WebGraphQlRequest;
|
||||
import org.springframework.graphql.web.TestWebSocketClient;
|
||||
import org.springframework.graphql.web.TestWebSocketConnection;
|
||||
import org.springframework.graphql.web.WebGraphQlHandler;
|
||||
import org.springframework.graphql.web.WebGraphQlHandlerInterceptor;
|
||||
import org.springframework.graphql.web.WebGraphQlInterceptor;
|
||||
import org.springframework.graphql.web.webflux.GraphQlHttpHandler;
|
||||
import org.springframework.graphql.web.webflux.GraphQlWebSocketHandler;
|
||||
import org.springframework.http.codec.ClientCodecConfigurer;
|
||||
@@ -60,7 +60,7 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r
|
||||
|
||||
/**
|
||||
* Tests for the builders of Web {@code GraphQlTester} extensions, using a
|
||||
* {@link WebGraphQlHandlerInterceptor} to capture the WebGraphQlRequest on the
|
||||
* {@link WebGraphQlInterceptor} to capture the WebGraphQlRequest on the
|
||||
* server side, and optionally returning a mock response, or an empty response.
|
||||
*
|
||||
* <ul>
|
||||
|
||||
@@ -25,7 +25,7 @@ import reactor.core.publisher.Mono;
|
||||
import org.springframework.graphql.ExecutionGraphQlService;
|
||||
import org.springframework.graphql.execution.ReactorContextManager;
|
||||
import org.springframework.graphql.execution.ThreadLocalAccessor;
|
||||
import org.springframework.graphql.web.WebGraphQlHandlerInterceptor.Chain;
|
||||
import org.springframework.graphql.web.WebGraphQlInterceptor.Chain;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -40,10 +40,10 @@ class DefaultWebGraphQlHandlerBuilder implements WebGraphQlHandler.Builder {
|
||||
|
||||
private final ExecutionGraphQlService service;
|
||||
|
||||
private final List<WebGraphQlHandlerInterceptor> interceptors = new ArrayList<>();
|
||||
private final List<WebGraphQlInterceptor> interceptors = new ArrayList<>();
|
||||
|
||||
@Nullable
|
||||
private WebSocketGraphQlHandlerInterceptor webSocketInterceptor;
|
||||
private WebSocketGraphQlInterceptor webSocketInterceptor;
|
||||
|
||||
@Nullable
|
||||
private List<ThreadLocalAccessor> accessors;
|
||||
@@ -56,17 +56,17 @@ class DefaultWebGraphQlHandlerBuilder implements WebGraphQlHandler.Builder {
|
||||
|
||||
|
||||
@Override
|
||||
public WebGraphQlHandler.Builder interceptor(WebGraphQlHandlerInterceptor... interceptors) {
|
||||
public WebGraphQlHandler.Builder interceptor(WebGraphQlInterceptor... interceptors) {
|
||||
return interceptors(Arrays.asList(interceptors));
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebGraphQlHandler.Builder interceptors(List<WebGraphQlHandlerInterceptor> interceptors) {
|
||||
public WebGraphQlHandler.Builder interceptors(List<WebGraphQlInterceptor> interceptors) {
|
||||
this.interceptors.addAll(interceptors);
|
||||
interceptors.forEach(interceptor -> {
|
||||
if (interceptor instanceof WebSocketGraphQlHandlerInterceptor) {
|
||||
if (interceptor instanceof WebSocketGraphQlInterceptor) {
|
||||
Assert.isNull(this.webSocketInterceptor, "There can be at most 1 WebSocketInterceptor");
|
||||
this.webSocketInterceptor = (WebSocketGraphQlHandlerInterceptor) interceptor;
|
||||
this.webSocketInterceptor = (WebSocketGraphQlInterceptor) interceptor;
|
||||
}
|
||||
});
|
||||
return this;
|
||||
@@ -92,7 +92,7 @@ class DefaultWebGraphQlHandlerBuilder implements WebGraphQlHandler.Builder {
|
||||
Chain endOfChain = request -> this.service.execute(request).map(WebGraphQlResponse::new);
|
||||
|
||||
Chain chain = this.interceptors.stream()
|
||||
.reduce(WebGraphQlHandlerInterceptor::andThen)
|
||||
.reduce(WebGraphQlInterceptor::andThen)
|
||||
.map(interceptor -> (Chain) (request) -> interceptor.intercept(request, endOfChain))
|
||||
.orElse(endOfChain);
|
||||
|
||||
@@ -111,9 +111,9 @@ class DefaultWebGraphQlHandlerBuilder implements WebGraphQlHandler.Builder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebSocketGraphQlHandlerInterceptor webSocketInterceptor() {
|
||||
public WebSocketGraphQlInterceptor webSocketInterceptor() {
|
||||
return (webSocketInterceptor != null ?
|
||||
webSocketInterceptor : new WebSocketGraphQlHandlerInterceptor() {});
|
||||
webSocketInterceptor : new WebSocketGraphQlInterceptor() {});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.graphql.ExecutionGraphQlResponse;
|
||||
import org.springframework.graphql.ExecutionGraphQlService;
|
||||
import org.springframework.graphql.web.RSocketGraphQlHandlerInterceptor.Chain;
|
||||
import org.springframework.graphql.web.RSocketGraphQlInterceptor.Chain;
|
||||
import org.springframework.util.AlternativeJdkIdGenerator;
|
||||
import org.springframework.util.IdGenerator;
|
||||
|
||||
@@ -78,13 +78,13 @@ public class GraphQlRSocketHandler {
|
||||
* followed by the given {@link ExecutionGraphQlService}.
|
||||
*/
|
||||
public GraphQlRSocketHandler(
|
||||
ExecutionGraphQlService service, List<RSocketGraphQlHandlerInterceptor> interceptors) {
|
||||
ExecutionGraphQlService service, List<RSocketGraphQlInterceptor> interceptors) {
|
||||
|
||||
Chain endOfChain = request -> service.execute(request).map(RSocketGraphQlResponse::new);
|
||||
|
||||
this.executionChain = (interceptors.isEmpty() ? endOfChain :
|
||||
interceptors.stream()
|
||||
.reduce(RSocketGraphQlHandlerInterceptor::andThen)
|
||||
.reduce(RSocketGraphQlInterceptor::andThen)
|
||||
.map(interceptor -> (Chain) request -> interceptor.intercept(request, endOfChain))
|
||||
.orElse(endOfChain));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.springframework.graphql.ExecutionGraphQlService;
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface RSocketGraphQlHandlerInterceptor {
|
||||
public interface RSocketGraphQlInterceptor {
|
||||
|
||||
/**
|
||||
* Intercept a request and delegate to the rest of the chain including other
|
||||
@@ -47,12 +47,12 @@ public interface RSocketGraphQlHandlerInterceptor {
|
||||
Mono<RSocketGraphQlResponse> intercept(RSocketGraphQlRequest request, Chain chain);
|
||||
|
||||
/**
|
||||
* Return a new {@link RSocketGraphQlHandlerInterceptor} that invokes the current
|
||||
* Return a new {@link RSocketGraphQlInterceptor} that invokes the current
|
||||
* interceptor first and then the one that is passed in.
|
||||
* @param nextInterceptor the interceptor to delegate to after the current
|
||||
* @return a new interceptor that chains the two
|
||||
*/
|
||||
default RSocketGraphQlHandlerInterceptor andThen(RSocketGraphQlHandlerInterceptor nextInterceptor) {
|
||||
default RSocketGraphQlInterceptor andThen(RSocketGraphQlInterceptor nextInterceptor) {
|
||||
return (request, chain) -> intercept(request, nextRequest -> nextInterceptor.intercept(nextRequest, chain));
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ public interface WebGraphQlHandler {
|
||||
|
||||
/**
|
||||
* Return the single interceptor of type
|
||||
* {@link WebSocketGraphQlHandlerInterceptor} among all the configured
|
||||
* {@link WebSocketGraphQlInterceptor} among all the configured
|
||||
* interceptors.
|
||||
*/
|
||||
WebSocketGraphQlHandlerInterceptor webSocketInterceptor();
|
||||
WebSocketGraphQlInterceptor webSocketInterceptor();
|
||||
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ public interface WebGraphQlHandler {
|
||||
|
||||
/**
|
||||
* Builder for a {@link WebGraphQlHandler} that executes a
|
||||
* {@link WebGraphQlHandlerInterceptor} chain followed by a
|
||||
* {@link WebGraphQlInterceptor} chain followed by a
|
||||
* {@link ExecutionGraphQlService}.
|
||||
*/
|
||||
interface Builder {
|
||||
@@ -71,22 +71,22 @@ public interface WebGraphQlHandler {
|
||||
* Configure interceptors to be invoked before the target
|
||||
* {@code GraphQlService}.
|
||||
* <p>One of the interceptors can be of type
|
||||
* {@link WebSocketGraphQlHandlerInterceptor} to handle data from the
|
||||
* {@link WebSocketGraphQlInterceptor} to handle data from the
|
||||
* first {@code ConnectionInit} message expected on a GraphQL over
|
||||
* WebSocket session, as well as the {@code Complete} message expected
|
||||
* at the end of a session.
|
||||
* @param interceptors the interceptors to add
|
||||
* @return this builder
|
||||
*/
|
||||
Builder interceptor(WebGraphQlHandlerInterceptor... interceptors);
|
||||
Builder interceptor(WebGraphQlInterceptor... interceptors);
|
||||
|
||||
/**
|
||||
* Alternative to {@link #interceptor(WebGraphQlHandlerInterceptor...)}
|
||||
* Alternative to {@link #interceptor(WebGraphQlInterceptor...)}
|
||||
* with a List.
|
||||
* @param interceptors the list of interceptors to add
|
||||
* @return this builder
|
||||
*/
|
||||
Builder interceptors(List<WebGraphQlHandlerInterceptor> interceptors);
|
||||
Builder interceptors(List<WebGraphQlInterceptor> interceptors);
|
||||
|
||||
/**
|
||||
* Configure accessors for ThreadLocal variables to use to extract
|
||||
|
||||
@@ -37,9 +37,9 @@ import org.springframework.graphql.ExecutionGraphQlService;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 1.0.0
|
||||
* @see WebSocketGraphQlHandlerInterceptor
|
||||
* @see WebSocketGraphQlInterceptor
|
||||
*/
|
||||
public interface WebGraphQlHandlerInterceptor {
|
||||
public interface WebGraphQlInterceptor {
|
||||
|
||||
/**
|
||||
* Intercept a request and delegate to the rest of the chain including other
|
||||
@@ -51,12 +51,12 @@ public interface WebGraphQlHandlerInterceptor {
|
||||
Mono<WebGraphQlResponse> intercept(WebGraphQlRequest request, Chain chain);
|
||||
|
||||
/**
|
||||
* Return a new {@link WebGraphQlHandlerInterceptor} that invokes the current
|
||||
* Return a new {@link WebGraphQlInterceptor} that invokes the current
|
||||
* interceptor first and then the one that is passed in.
|
||||
* @param nextInterceptor the interceptor to delegate to after the current
|
||||
* @return a new interceptor that chains the two
|
||||
*/
|
||||
default WebGraphQlHandlerInterceptor andThen(WebGraphQlHandlerInterceptor nextInterceptor) {
|
||||
default WebGraphQlInterceptor andThen(WebGraphQlInterceptor nextInterceptor) {
|
||||
return (request, chain) -> intercept(request, nextRequest -> nextInterceptor.intercept(nextRequest, chain));
|
||||
}
|
||||
|
||||
@@ -21,15 +21,15 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
|
||||
/**
|
||||
* An extension of {@link WebGraphQlHandlerInterceptor} with additional methods
|
||||
* An extension of {@link WebGraphQlInterceptor} with additional methods
|
||||
* to handle the start and end of a WebSocket connection. Only a single
|
||||
* interceptor of type {@link WebSocketGraphQlHandlerInterceptor} may be
|
||||
* interceptor of type {@link WebSocketGraphQlInterceptor} may be
|
||||
* declared.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface WebSocketGraphQlHandlerInterceptor extends WebGraphQlHandlerInterceptor {
|
||||
public interface WebSocketGraphQlInterceptor extends WebGraphQlInterceptor {
|
||||
|
||||
@Override
|
||||
default Mono<WebGraphQlResponse> intercept(WebGraphQlRequest request, Chain chain) {
|
||||
@@ -19,7 +19,7 @@
|
||||
* WebSocket. Handlers are provided for use in ether
|
||||
* {@link org.springframework.graphql.web.webmvc Spring WebMvc} or
|
||||
* {@link org.springframework.graphql.web.webflux Spring WebFlux} with a common
|
||||
* {@link org.springframework.graphql.web.WebGraphQlHandlerInterceptor interception}
|
||||
* {@link org.springframework.graphql.web.WebGraphQlInterceptor interception}
|
||||
* model that allows applications to customize the request and response.
|
||||
*/
|
||||
@NonNullApi
|
||||
|
||||
@@ -35,7 +35,7 @@ import reactor.core.publisher.Mono;
|
||||
import org.springframework.graphql.web.WebGraphQlRequest;
|
||||
import org.springframework.graphql.web.WebGraphQlHandler;
|
||||
import org.springframework.graphql.web.WebGraphQlResponse;
|
||||
import org.springframework.graphql.web.WebSocketGraphQlHandlerInterceptor;
|
||||
import org.springframework.graphql.web.WebSocketGraphQlInterceptor;
|
||||
import org.springframework.graphql.web.support.GraphQlMessage;
|
||||
import org.springframework.http.codec.CodecConfigurer;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -63,7 +63,7 @@ public class GraphQlWebSocketHandler implements WebSocketHandler {
|
||||
|
||||
private final WebGraphQlHandler graphQlHandler;
|
||||
|
||||
private final WebSocketGraphQlHandlerInterceptor webSocketInterceptor;
|
||||
private final WebSocketGraphQlInterceptor webSocketInterceptor;
|
||||
|
||||
private final CodecDelegate codecDelegate;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ import reactor.core.scheduler.Schedulers;
|
||||
import org.springframework.graphql.web.WebGraphQlHandler;
|
||||
import org.springframework.graphql.web.WebGraphQlRequest;
|
||||
import org.springframework.graphql.web.WebGraphQlResponse;
|
||||
import org.springframework.graphql.web.WebSocketGraphQlHandlerInterceptor;
|
||||
import org.springframework.graphql.web.WebSocketGraphQlInterceptor;
|
||||
import org.springframework.graphql.web.support.GraphQlMessage;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpInputMessage;
|
||||
@@ -81,7 +81,7 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
|
||||
|
||||
private final WebGraphQlHandler graphQlHandler;
|
||||
|
||||
private final WebSocketGraphQlHandlerInterceptor webSocketInterceptor;
|
||||
private final WebSocketGraphQlInterceptor webSocketInterceptor;
|
||||
|
||||
private final Duration initTimeoutDuration;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.springframework.graphql.web.WebGraphQlRequest;
|
||||
import org.springframework.graphql.web.TestWebSocketClient;
|
||||
import org.springframework.graphql.web.TestWebSocketConnection;
|
||||
import org.springframework.graphql.web.WebGraphQlHandler;
|
||||
import org.springframework.graphql.web.WebGraphQlHandlerInterceptor;
|
||||
import org.springframework.graphql.web.WebGraphQlInterceptor;
|
||||
import org.springframework.graphql.web.webflux.GraphQlHttpHandler;
|
||||
import org.springframework.graphql.web.webflux.GraphQlWebSocketHandler;
|
||||
import org.springframework.http.codec.ClientCodecConfigurer;
|
||||
@@ -63,7 +63,7 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r
|
||||
|
||||
/**
|
||||
* Tests for the builders of Web {@code GraphQlClient} extensions, using a
|
||||
* {@link WebGraphQlHandlerInterceptor} to capture the WebInput on the server
|
||||
* {@link WebGraphQlInterceptor} to capture the WebInput on the server
|
||||
* side, and optionally returning a mock response, or an empty response.
|
||||
*
|
||||
* <ul>
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public class ConsumeOneAndNeverCompleteInterceptor implements WebGraphQlHandlerInterceptor {
|
||||
public class ConsumeOneAndNeverCompleteInterceptor implements WebGraphQlInterceptor {
|
||||
|
||||
@Override
|
||||
public Mono<WebGraphQlResponse> intercept(WebGraphQlRequest request, Chain chain) {
|
||||
|
||||
@@ -35,9 +35,9 @@ import org.springframework.http.HttpHeaders;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Unit tests for a {@link WebGraphQlHandlerInterceptor} chain.
|
||||
* Unit tests for a {@link WebGraphQlInterceptor} chain.
|
||||
*/
|
||||
public class WebGraphQlHandlerInterceptorTests {
|
||||
public class WebGraphQlInterceptorTests {
|
||||
|
||||
private static final WebGraphQlRequest webRequest = new WebGraphQlRequest(
|
||||
URI.create("http://abc.org"), new HttpHeaders(), Collections.singletonMap("query", "{ notUsed }"), "1", null);
|
||||
@@ -98,7 +98,7 @@ public class WebGraphQlHandlerInterceptorTests {
|
||||
ExecutionResultImpl.newExecutionResult().build()));
|
||||
}
|
||||
|
||||
private static class OrderInterceptor implements WebGraphQlHandlerInterceptor {
|
||||
private static class OrderInterceptor implements WebGraphQlInterceptor {
|
||||
|
||||
private final StringBuilder sb;
|
||||
|
||||
@@ -64,7 +64,7 @@ public abstract class WebSocketHandlerTestSupport {
|
||||
"}";
|
||||
|
||||
|
||||
protected WebGraphQlHandler initHandler(WebGraphQlHandlerInterceptor... interceptors) {
|
||||
protected WebGraphQlHandler initHandler(WebGraphQlInterceptor... interceptors) {
|
||||
return GraphQlSetup.schemaResource(BookSource.schema)
|
||||
.queryFetcher("bookById", environment -> {
|
||||
Long id = Long.parseLong(environment.getArgument("id"));
|
||||
|
||||
@@ -39,9 +39,9 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.graphql.GraphQlSetup;
|
||||
import org.springframework.graphql.web.ConsumeOneAndNeverCompleteInterceptor;
|
||||
import org.springframework.graphql.web.WebGraphQlHandler;
|
||||
import org.springframework.graphql.web.WebGraphQlHandlerInterceptor;
|
||||
import org.springframework.graphql.web.WebGraphQlInterceptor;
|
||||
import org.springframework.graphql.web.WebSocketHandlerTestSupport;
|
||||
import org.springframework.graphql.web.WebSocketGraphQlHandlerInterceptor;
|
||||
import org.springframework.graphql.web.WebSocketGraphQlInterceptor;
|
||||
import org.springframework.graphql.web.support.GraphQlMessage;
|
||||
import org.springframework.graphql.web.support.GraphQlMessageType;
|
||||
import org.springframework.http.codec.ServerCodecConfigurer;
|
||||
@@ -149,7 +149,7 @@ public class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
|
||||
void connectionInitHandling() {
|
||||
TestWebSocketSession session = handle(
|
||||
Flux.just(toWebSocketMessage("{\"type\":\"connection_init\",\"payload\":{\"key\":\"A\"}}")),
|
||||
new WebSocketGraphQlHandlerInterceptor() {
|
||||
new WebSocketGraphQlInterceptor() {
|
||||
|
||||
@Override
|
||||
public Mono<Object> handleConnectionInitialization(String sessionId, Map<String, Object> payload) {
|
||||
@@ -189,7 +189,7 @@ public class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
|
||||
|
||||
TestWebSocketSession session = handle(
|
||||
Flux.just(toWebSocketMessage("{\"type\":\"connection_init\",\"payload\":{\"key\":\"A\"}}")),
|
||||
new WebSocketGraphQlHandlerInterceptor() {
|
||||
new WebSocketGraphQlInterceptor() {
|
||||
|
||||
@Override
|
||||
public void handleConnectionClosed(String sessionId, int status, Map<String, Object> payload) {
|
||||
@@ -209,7 +209,7 @@ public class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
|
||||
void connectionInitRejected() {
|
||||
TestWebSocketSession session = handle(
|
||||
Flux.just(toWebSocketMessage("{\"type\":\"connection_init\"}")),
|
||||
new WebSocketGraphQlHandlerInterceptor() {
|
||||
new WebSocketGraphQlInterceptor() {
|
||||
|
||||
@Override
|
||||
public Mono<Object> handleConnectionInitialization(String sessionId, Map<String, Object> payload) {
|
||||
@@ -363,7 +363,7 @@ public class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
|
||||
.verify(TIMEOUT);
|
||||
}
|
||||
|
||||
private TestWebSocketSession handle(Flux<WebSocketMessage> input, WebGraphQlHandlerInterceptor... interceptors) {
|
||||
private TestWebSocketSession handle(Flux<WebSocketMessage> input, WebGraphQlInterceptor... interceptors) {
|
||||
GraphQlWebSocketHandler handler = new GraphQlWebSocketHandler(
|
||||
initHandler(interceptors),
|
||||
ServerCodecConfigurer.create(),
|
||||
|
||||
@@ -37,9 +37,9 @@ import reactor.test.StepVerifier;
|
||||
import org.springframework.graphql.GraphQlSetup;
|
||||
import org.springframework.graphql.web.ConsumeOneAndNeverCompleteInterceptor;
|
||||
import org.springframework.graphql.web.WebGraphQlHandler;
|
||||
import org.springframework.graphql.web.WebGraphQlHandlerInterceptor;
|
||||
import org.springframework.graphql.web.WebGraphQlInterceptor;
|
||||
import org.springframework.graphql.web.WebSocketHandlerTestSupport;
|
||||
import org.springframework.graphql.web.WebSocketGraphQlHandlerInterceptor;
|
||||
import org.springframework.graphql.web.WebSocketGraphQlInterceptor;
|
||||
import org.springframework.graphql.web.support.GraphQlMessage;
|
||||
import org.springframework.graphql.web.support.GraphQlMessageType;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -148,7 +148,7 @@ public class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
|
||||
@Test
|
||||
void connectionInitHandling() throws Exception {
|
||||
|
||||
WebSocketGraphQlHandlerInterceptor interceptor = new WebSocketGraphQlHandlerInterceptor() {
|
||||
WebSocketGraphQlInterceptor interceptor = new WebSocketGraphQlInterceptor() {
|
||||
|
||||
@Override
|
||||
public Mono<Object> handleConnectionInitialization(String sessionId, Map<String, Object> payload) {
|
||||
@@ -192,7 +192,7 @@ public class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
|
||||
CloseStatus closeStatus = CloseStatus.PROTOCOL_ERROR;
|
||||
AtomicBoolean called = new AtomicBoolean();
|
||||
|
||||
WebSocketGraphQlHandlerInterceptor interceptor = new WebSocketGraphQlHandlerInterceptor() {
|
||||
WebSocketGraphQlInterceptor interceptor = new WebSocketGraphQlInterceptor() {
|
||||
|
||||
@Override
|
||||
public void handleConnectionClosed(String sessionId, int status, Map<String, Object> payload) {
|
||||
@@ -219,7 +219,7 @@ public class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
|
||||
@Test
|
||||
void connectionInitRejected() throws Exception {
|
||||
|
||||
WebSocketGraphQlHandlerInterceptor interceptor = new WebSocketGraphQlHandlerInterceptor() {
|
||||
WebSocketGraphQlInterceptor interceptor = new WebSocketGraphQlInterceptor() {
|
||||
|
||||
@Override
|
||||
public Mono<Object> handleConnectionInitialization(String sessionId, Map<String, Object> payload) {
|
||||
@@ -378,7 +378,7 @@ public class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
|
||||
}
|
||||
}
|
||||
|
||||
private GraphQlWebSocketHandler initWebSocketHandler(WebGraphQlHandlerInterceptor... interceptors) {
|
||||
private GraphQlWebSocketHandler initWebSocketHandler(WebGraphQlInterceptor... interceptors) {
|
||||
try {
|
||||
return new GraphQlWebSocketHandler(initHandler(interceptors), converter, Duration.ofSeconds(60));
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.graphql.execution.RuntimeWiringConfigurer;
|
||||
import org.springframework.graphql.execution.ThreadLocalAccessor;
|
||||
import org.springframework.graphql.web.WebGraphQlHandler;
|
||||
import org.springframework.graphql.web.WebGraphQlSetup;
|
||||
import org.springframework.graphql.web.WebGraphQlHandlerInterceptor;
|
||||
import org.springframework.graphql.web.WebGraphQlInterceptor;
|
||||
|
||||
/**
|
||||
* Workflow for GraphQL tests setup that starts with {@link GraphQlSource.Builder}
|
||||
@@ -53,7 +53,7 @@ public class GraphQlSetup implements GraphQlServiceSetup {
|
||||
|
||||
private final List<DataLoaderRegistrar> dataLoaderRegistrars = new ArrayList<>();
|
||||
|
||||
private final List<WebGraphQlHandlerInterceptor> interceptors = new ArrayList<>();
|
||||
private final List<WebGraphQlInterceptor> interceptors = new ArrayList<>();
|
||||
|
||||
private final List<ThreadLocalAccessor> accessors = new ArrayList<>();
|
||||
|
||||
@@ -134,7 +134,7 @@ public class GraphQlSetup implements GraphQlServiceSetup {
|
||||
|
||||
// WebGraphQlSetup...
|
||||
|
||||
public WebGraphQlSetup interceptor(WebGraphQlHandlerInterceptor... interceptors) {
|
||||
public WebGraphQlSetup interceptor(WebGraphQlInterceptor... interceptors) {
|
||||
this.interceptors.addAll(Arrays.asList(interceptors));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.graphql.execution.ThreadLocalAccessor;
|
||||
*/
|
||||
public interface WebGraphQlSetup {
|
||||
|
||||
WebGraphQlSetup interceptor(WebGraphQlHandlerInterceptor... interceptors);
|
||||
WebGraphQlSetup interceptor(WebGraphQlInterceptor... interceptors);
|
||||
|
||||
WebGraphQlSetup threadLocalAccessor(ThreadLocalAccessor... accessors);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user