Shorten GraphQlResponse[Field|Error] and rename GraphQlService

Rename GraphQlService to ExecutionGraphQlService following the renaming
of the request and response to ExecutionGraphQl[Request|Response].

See gh-332
This commit is contained in:
rstoyanchev
2022-03-20 20:47:15 +00:00
parent 67711f7331
commit 91e7f285fa
43 changed files with 168 additions and 164 deletions

View File

@@ -183,7 +183,7 @@ response and the field:
.onErrorResume(FieldAccessException.class, ex -> {
ClientGraphQlResponse response = ex.getResponse();
// ...
GraphQlResponseField field = ex.getField();
ResponseField field = ex.getField();
// ...
});
----

View File

@@ -118,8 +118,8 @@ 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
`WebInterceptor` components, followed by a `GraphQlService` that invokes the GraphQL
Java engine.
`WebInterceptor` components, followed by a `ExecutionGraphQlService` that invokes
GraphQL Java.
`WebInterceptor` 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
@@ -170,13 +170,12 @@ it contains, for the actual config.
[[execution]]
== Request Execution
`GraphQlService` is the main Spring abstraction to call GraphQL Java to execute
requests. Underlying transports, such as the <<web-transports>>, delegate to `GraphQlService` to
handle requests.
`ExecutionGraphQlService` is the main Spring abstraction to call GraphQL Java to execute
requests. Underlying transports, such as the <<web-transports>>, delegate to
`ExecutionGraphQlService` to handle requests.
The main implementation, `ExecutionGraphQlService`, is a thin facade around the
invocation of `graphql.GraphQL`. It is configured with a `GraphQlSource` for access to
the `graphql.GraphQL` instance.
The main implementation, `DefaultExecutionGraphQlService`, is configured with a
`GraphQlSource` for access to the `graphql.GraphQL` instance to invoke.
@@ -413,10 +412,10 @@ transport layer, such as from a WebFlux request handling, see
[[execution-context]]
=== Context Propagation
Spring for GraphQL provides support to transparently propagate context from the <<web-transports>>,
through the GraphQL engine, and to `DataFetcher` and other components it invokes.
This includes both `ThreadLocal` context from the Spring MVC request handling thread and
Reactor `Context` from the WebFlux processing pipeline.
Spring for GraphQL provides support to transparently propagate context from the
<<web-transports>>, through GraphQL Java, and to `DataFetcher` and other components it
invokes. This includes both `ThreadLocal` context from the Spring MVC request handling
thread and Reactor `Context` from the WebFlux processing pipeline.
[[execution-context-webmvc]]
@@ -427,7 +426,7 @@ the same thread as the Spring MVC handler, for example if an asynchronous
<<web-interception, `WebInterceptor`>> or `DataFetcher` switches to a different thread.
Spring for GraphQL supports propagating `ThreadLocal` values from the Servlet container
thread to the thread a `DataFetcher` and other components invoked by the GraphQL engine
thread to the thread a `DataFetcher` and other components invoked by GraphQL Java to
execute on. To do this, an application needs to create a `ThreadLocalAccessor` to extract
`ThreadLocal` values of interest:
@@ -558,7 +557,7 @@ public class MyConfig {
The Spring Boot starter declares a `BatchLoaderRegistry` bean that you can inject into
your configuration, as shown above, or into any component such as a controller in order
register batch loading functions. In turn the `BatchLoaderRegistry` is injected into
`ExecutionGraphQlService` where it ensures `DataLoader` registrations per request.
`DefaultExecutionGraphQlService` where it ensures `DataLoader` registrations per request.
By default, the `DataLoader` name is based on the class name of the target entity.
This allows an `@SchemaMapping` method to declare a
@@ -1202,7 +1201,7 @@ If needed, you can customize the name through the annotation, e.g. `@Argument("b
TIP: The `@Argument` annotation does not have a "required" flag, nor the option to
specify a default value. Both of these can be specified at the GraphQL schema level and
are enforced by the GraphQL Engine.
are enforced by GraphQL Java.
You can use `@Argument` on a `Map<String, Object>` argument, to obtain all argument
values. The name attribute on `@Argument` must not be set.

View File

@@ -179,7 +179,7 @@ connection closed, e.g. after a test runs.
Many times it's enough to test GraphQL requests on the server side, without the use of a
client to send requests over a transport protocol. To test directly against a
`GraphQlService`, use the `GraphQlServiceTester` extension:
`ExecutionGraphQlService`, use the `GraphQlServiceTester` extension:
[source,java,indent=0,subs="verbatim,quotes"]
----
@@ -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
`WebInterceptor` chain before handing off to `GraphQlService` for request execution:
`WebInterceptor` chain before handing off to `ExecutionGraphQlService` for request execution:
[source,java,indent=0,subs="verbatim,quotes"]
----

View File

@@ -27,7 +27,7 @@ import org.springframework.graphql.ExecutionGraphQlRequest;
import org.springframework.graphql.ExecutionGraphQlResponse;
import org.springframework.graphql.GraphQlRequest;
import org.springframework.graphql.GraphQlResponse;
import org.springframework.graphql.GraphQlResponseError;
import org.springframework.graphql.ResponseError;
import org.springframework.graphql.support.DefaultExecutionGraphQlRequest;
import org.springframework.graphql.support.DefaultExecutionGraphQlResponse;
import org.springframework.graphql.client.GraphQlTransport;
@@ -61,7 +61,7 @@ abstract class AbstractDirectTransport implements GraphQlTransport {
Object data = response.getData();
AssertionErrors.assertTrue("Not a Publisher: " + data, data instanceof Publisher);
List<GraphQlResponseError> errors = response.getErrors();
List<ResponseError> errors = response.getErrors();
AssertionErrors.assertTrue("Subscription errors: " + errors, CollectionUtils.isEmpty(errors));
return Flux.from((Publisher<ExecutionResult>) data).map(executionResult ->

View File

@@ -25,7 +25,7 @@ import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;
import com.jayway.jsonpath.spi.mapper.MappingProvider;
import org.springframework.graphql.GraphQlResponseError;
import org.springframework.graphql.ResponseError;
import org.springframework.graphql.client.AbstractGraphQlClientBuilder;
import org.springframework.graphql.client.GraphQlTransport;
import org.springframework.graphql.support.CachingDocumentSource;
@@ -57,7 +57,7 @@ public abstract class AbstractGraphQlTesterBuilder<B extends AbstractGraphQlTest
@Nullable
private Predicate<GraphQlResponseError> errorFilter;
private Predicate<ResponseError> errorFilter;
private DocumentSource documentSource = new CachingDocumentSource(new ResourceDocumentSource());
@@ -67,7 +67,7 @@ public abstract class AbstractGraphQlTesterBuilder<B extends AbstractGraphQlTest
@Override
public B errorFilter(Predicate<GraphQlResponseError> predicate) {
public B errorFilter(Predicate<ResponseError> predicate) {
this.errorFilter = (this.errorFilter != null ? errorFilter.and(predicate) : predicate);
return self();
}

View File

@@ -19,12 +19,12 @@ package org.springframework.graphql.test.tester;
import java.util.function.Consumer;
import org.springframework.graphql.GraphQlService;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.util.Assert;
/**
* Default {@link GraphQlServiceTester} that uses a {@link GraphQlService} for
* Default {@link GraphQlServiceTester} that uses a {@link ExecutionGraphQlService} for
* request execution.
*
* @author Rossen Stoyanchev
@@ -64,9 +64,9 @@ final class DefaultGraphQlServiceTester extends AbstractDelegatingGraphQlTester
static class Builder<B extends Builder<B>> extends AbstractGraphQlTesterBuilder<B>
implements GraphQlServiceTester.Builder<B> {
private final GraphQlService service;
private final ExecutionGraphQlService service;
Builder(GraphQlService service) {
Builder(ExecutionGraphQlService service) {
Assert.notNull(service, "GraphQlService is required");
this.service = service;
}

View File

@@ -37,7 +37,7 @@ import org.springframework.core.ResolvableType;
import org.springframework.graphql.support.DefaultGraphQlRequest;
import org.springframework.graphql.GraphQlRequest;
import org.springframework.graphql.GraphQlResponse;
import org.springframework.graphql.GraphQlResponseError;
import org.springframework.graphql.ResponseError;
import org.springframework.graphql.client.GraphQlTransport;
import org.springframework.graphql.support.DocumentSource;
import org.springframework.lang.Nullable;
@@ -62,7 +62,7 @@ final class DefaultGraphQlTester implements GraphQlTester {
private final GraphQlTransport transport;
@Nullable
private final Predicate<GraphQlResponseError> errorFilter;
private final Predicate<ResponseError> errorFilter;
private final Configuration jsonPathConfig;
@@ -77,7 +77,7 @@ final class DefaultGraphQlTester implements GraphQlTester {
* Package private constructor for use from {@link AbstractGraphQlTesterBuilder}.
*/
DefaultGraphQlTester(
GraphQlTransport transport, @Nullable Predicate<GraphQlResponseError> errorFilter,
GraphQlTransport transport, @Nullable Predicate<ResponseError> errorFilter,
Configuration jsonPathConfig, DocumentSource documentSource, Duration timeout,
Consumer<AbstractGraphQlTesterBuilder<?>> builderInitializer) {
@@ -210,15 +210,15 @@ final class DefaultGraphQlTester implements GraphQlTester {
private final Supplier<String> jsonContent;
private final List<GraphQlResponseError> errors;
private final List<ResponseError> errors;
private final List<GraphQlResponseError> unexpectedErrors;
private final List<ResponseError> unexpectedErrors;
private final Consumer<Runnable> assertDecorator;
private ResponseDelegate(
GraphQlResponse response, @Nullable Predicate<GraphQlResponseError> errorFilter,
GraphQlResponse response, @Nullable Predicate<ResponseError> errorFilter,
Consumer<Runnable> assertDecorator, Configuration jsonPathConfig) {
this.jsonDoc = JsonPath.parse(response.toMap(), jsonPathConfig);
@@ -254,9 +254,9 @@ final class DefaultGraphQlTester implements GraphQlTester {
this.assertDecorator.accept(task);
}
boolean filterErrors(Predicate<GraphQlResponseError> predicate) {
boolean filterErrors(Predicate<ResponseError> predicate) {
boolean filtered = false;
for (GraphQlResponseError error : this.errors) {
for (ResponseError error : this.errors) {
if (predicate.test(error)) {
this.unexpectedErrors.remove(error);
filtered = true;
@@ -265,12 +265,12 @@ final class DefaultGraphQlTester implements GraphQlTester {
return filtered;
}
void expectErrors(Predicate<GraphQlResponseError> predicate) {
void expectErrors(Predicate<ResponseError> predicate) {
boolean filtered = filterErrors(predicate);
this.assertDecorator.accept(() -> AssertionErrors.assertTrue("No matching errors.", filtered));
}
void consumeErrors(Consumer<List<GraphQlResponseError>> consumer) {
void consumeErrors(Consumer<List<ResponseError>> consumer) {
filterErrors(error -> true);
consumer.accept(this.errors);
}
@@ -294,7 +294,7 @@ final class DefaultGraphQlTester implements GraphQlTester {
private final ResponseDelegate delegate;
private DefaultResponse(
GraphQlResponse response, @Nullable Predicate<GraphQlResponseError> errorFilter,
GraphQlResponse response, @Nullable Predicate<ResponseError> errorFilter,
Consumer<Runnable> assertDecorator, Configuration jsonPathConfig) {
this.delegate = new ResponseDelegate(response, errorFilter, assertDecorator, jsonPathConfig);
@@ -312,13 +312,13 @@ final class DefaultGraphQlTester implements GraphQlTester {
}
@Override
public Errors filter(Predicate<GraphQlResponseError> predicate) {
public Errors filter(Predicate<ResponseError> predicate) {
this.delegate.filterErrors(predicate);
return this;
}
@Override
public Errors expect(Predicate<GraphQlResponseError> predicate) {
public Errors expect(Predicate<ResponseError> predicate) {
this.delegate.expectErrors(predicate);
return this;
}
@@ -330,7 +330,7 @@ final class DefaultGraphQlTester implements GraphQlTester {
}
@Override
public Traversable satisfy(Consumer<List<GraphQlResponseError>> consumer) {
public Traversable satisfy(Consumer<List<ResponseError>> consumer) {
this.delegate.consumeErrors(consumer);
return this;
}

View File

@@ -16,10 +16,10 @@
package org.springframework.graphql.test.tester;
import org.springframework.graphql.GraphQlService;
import org.springframework.graphql.ExecutionGraphQlService;
/**
* {@link GraphQlTester} that executes requests through a {@link GraphQlService}
* {@link GraphQlTester} that executes requests through a {@link ExecutionGraphQlService}
* Use it for server-side tests, without a client.
*
* @author Rossen Stoyanchev
@@ -35,14 +35,14 @@ public interface GraphQlServiceTester extends GraphQlTester {
/**
* Create a {@link GraphQlServiceTester} instance.
*/
static GraphQlServiceTester create(GraphQlService service) {
static GraphQlServiceTester create(ExecutionGraphQlService service) {
return builder(service).build();
}
/**
* Return a builder for {@link GraphQlServiceTester}.
*/
static GraphQlServiceTester.Builder<?> builder(GraphQlService service) {
static GraphQlServiceTester.Builder<?> builder(ExecutionGraphQlService service) {
return new DefaultGraphQlServiceTester.Builder<>(service);
}

View File

@@ -21,28 +21,28 @@ import reactor.core.publisher.Mono;
import org.springframework.graphql.ExecutionGraphQlRequest;
import org.springframework.graphql.ExecutionGraphQlResponse;
import org.springframework.graphql.GraphQlService;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.util.Assert;
/**
* {@code GraphQlTransport} that calls directly a {@link GraphQlService}.
* {@code GraphQlTransport} that calls directly a {@link ExecutionGraphQlService}.
*
* @author Rossen Stoyanchev
* @since 1.0.0
*/
final class GraphQlServiceTransport extends AbstractDirectTransport {
private final GraphQlService graphQlService;
private final ExecutionGraphQlService graphQlService;
GraphQlServiceTransport(GraphQlService graphQlService) {
GraphQlServiceTransport(ExecutionGraphQlService graphQlService) {
Assert.notNull(graphQlService, "GraphQlService is required");
this.graphQlService = graphQlService;
}
public GraphQlService getGraphQlService() {
public ExecutionGraphQlService getGraphQlService() {
return this.graphQlService;
}

View File

@@ -24,7 +24,7 @@ import java.util.function.Predicate;
import reactor.core.publisher.Flux;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.graphql.GraphQlResponseError;
import org.springframework.graphql.ResponseError;
import org.springframework.graphql.client.GraphQlTransport;
import org.springframework.graphql.support.DocumentSource;
import org.springframework.graphql.support.ResourceDocumentSource;
@@ -103,7 +103,7 @@ public interface GraphQlTester {
* @param predicate the error filter to add
* @return the same builder instance
*/
B errorFilter(Predicate<GraphQlResponseError> predicate);
B errorFilter(Predicate<ResponseError> predicate);
/**
* Configure a {@link DocumentSource} for use with
@@ -448,7 +448,7 @@ public interface GraphQlTester {
* @param errorPredicate the error filter to add
* @return the same spec to add more filters before {@link #verify()}
*/
Errors filter(Predicate<GraphQlResponseError> errorPredicate);
Errors filter(Predicate<ResponseError> errorPredicate);
/**
* Use this to declare errors that are expected.
@@ -461,7 +461,7 @@ public interface GraphQlTester {
* @param errorPredicate the predicate for the expected error
* @return the same spec to add more filters or expected errors
*/
Errors expect(Predicate<GraphQlResponseError> errorPredicate);
Errors expect(Predicate<ResponseError> errorPredicate);
/**
* Verify there are either no errors or that there no unexpected errors that have
@@ -477,7 +477,7 @@ public interface GraphQlTester {
* @param errorsConsumer to inspect errors with
* @return a spec to switch to a data path
*/
Traversable satisfy(Consumer<List<GraphQlResponseError>> errorsConsumer);
Traversable satisfy(Consumer<List<ResponseError>> errorsConsumer);
}

View File

@@ -20,13 +20,13 @@ import graphql.GraphqlErrorBuilder;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;
import org.springframework.graphql.GraphQlService;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.graphql.support.DocumentSource;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link GraphQlTester} builder with a mock {@link GraphQlService}.
* Tests for {@link GraphQlTester} builder with a mock {@link ExecutionGraphQlService}.
*
* @author Rossen Stoyanchev
*/

View File

@@ -30,7 +30,7 @@ import org.mockito.ArgumentCaptor;
import reactor.core.publisher.Mono;
import org.springframework.graphql.ExecutionGraphQlRequest;
import org.springframework.graphql.GraphQlService;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.graphql.support.DefaultExecutionGraphQlResponse;
import static org.mockito.BDDMockito.given;
@@ -48,7 +48,7 @@ public class GraphQlTesterTestSupport {
private final ArgumentCaptor<ExecutionGraphQlRequest> requestCaptor = ArgumentCaptor.forClass(ExecutionGraphQlRequest.class);
private final GraphQlService graphQlService = mock(GraphQlService.class);
private final ExecutionGraphQlService graphQlService = mock(ExecutionGraphQlService.class);
private final GraphQlTester.Builder<?> graphQlTesterBuilder = GraphQlServiceTester.builder(this.graphQlService);

View File

@@ -27,13 +27,13 @@ import org.junit.jupiter.api.Test;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.graphql.ExecutionGraphQlRequest;
import org.springframework.graphql.GraphQlService;
import org.springframework.graphql.ExecutionGraphQlService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* Tests for {@link GraphQlTester} with a mock {@link GraphQlService}.
* Tests for {@link GraphQlTester} with a mock {@link ExecutionGraphQlService}.
*
* @author Rossen Stoyanchev
*/

View File

@@ -24,7 +24,7 @@ import reactor.core.publisher.Mono;
* @author Rossen Stoyanchev
* @since 1.0.0
*/
public interface GraphQlService {
public interface ExecutionGraphQlService {
/**
* Execute the request and return the response.

View File

@@ -58,12 +58,12 @@ public interface GraphQlResponse {
* Return errors included in the response.
* <p>A response that is not {@link #isValid() valid} contains "request
* errors". Those are errors that apply to the request as a whole, and have
* an empty error {@link GraphQlResponseError#getPath() path}.
* an empty error {@link ResponseError#getPath() path}.
* <p>A response that is valid may still be partial and contain "field
* errors". Those are errors associated with a specific field through their
* error path.
*/
List<GraphQlResponseError> getErrors();
List<ResponseError> getErrors();
/**
* Navigate to the given path under the "data" key of the response map where
@@ -78,10 +78,10 @@ public interface GraphQlResponse {
* </pre>
* @param path relative to the "data" key
* @return representation for the field with further options to inspect or
* decode its value; use {@link GraphQlResponseField#hasValue()} to check if
* decode its value; use {@link ResponseField#hasValue()} to check if
* the field actually exists and has a value.
*/
GraphQlResponseField field(String path);
ResponseField field(String path);
/**
* Return implementor specific, protocol extensions, if any.

View File

@@ -14,7 +14,7 @@ import org.springframework.lang.Nullable;
* @author Rossen Stoyanchev
* @since 1.0
*/
public interface GraphQlResponseError {
public interface ResponseError {
/**
* Return the message with a description of the error intended for the

View File

@@ -29,7 +29,7 @@ import org.springframework.lang.Nullable;
* @author Rossen Stoyanchev
* @since 1.0.0
*/
public interface GraphQlResponseField {
public interface ResponseField {
/**
* Whether the field has a value.
@@ -51,7 +51,7 @@ public interface GraphQlResponseField {
/**
* Return a parsed representation of the field path, in the format described
* for error paths in Section 7.1.2, "Response Format" of the GraphQL spec.
* @see GraphQlResponseError#getParsedPath()
* @see ResponseError#getParsedPath()
*/
List<Object> getParsedPath();
@@ -85,7 +85,7 @@ public interface GraphQlResponseField {
* error with the same path as the field path
*/
@Nullable
GraphQlResponseError getError();
ResponseError getError();
/**
* Return all field errors including errors above, at, and below this field.
@@ -94,6 +94,6 @@ public interface GraphQlResponseField {
* field <strong>does not have</strong> a value, there should be only one
* field error, and in that case it is better to use {@link #getError()}.
*/
List<GraphQlResponseError> getErrors();
List<ResponseError> getErrors();
}

View File

@@ -38,7 +38,7 @@ public interface ClientGraphQlResponse extends GraphQlResponse {
/**
* {@inheritDoc}
*/
ClientGraphQlResponseField field(String path);
ClientResponseField field(String path);
/**
* Decode the full response map to the given target type.

View File

@@ -20,15 +20,15 @@ package org.springframework.graphql.client;
import java.util.List;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.graphql.GraphQlResponseField;
import org.springframework.graphql.ResponseField;
/**
* Extends {@link GraphQlResponseField} to add options for decoding the field value.
* Extends {@link ResponseField} to add options for decoding the field value.
*
* @author Rossen Stoyanchev
* @since 1.0.0
*/
public interface ClientGraphQlResponseField extends GraphQlResponseField {
public interface ClientResponseField extends ResponseField {
/**
* Decode the field to an entity of the given type.

View File

@@ -64,8 +64,8 @@ final class DefaultClientGraphQlResponse extends MapGraphQlResponse implements C
@Override
public ClientGraphQlResponseField field(String path) {
return new DefaultClientGraphQlResponseField(this, super.field(path));
public ClientResponseField field(String path) {
return new DefaultClientResponseField(this, super.field(path));
}
@Override

View File

@@ -27,28 +27,28 @@ import org.springframework.core.codec.Encoder;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferFactory;
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.graphql.GraphQlResponseError;
import org.springframework.graphql.GraphQlResponseField;
import org.springframework.graphql.ResponseError;
import org.springframework.graphql.ResponseField;
import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;
/**
* Default implementation of {@link ClientGraphQlResponseField} that wraps the
* Default implementation of {@link ClientResponseField} that wraps the
* field from {@link org.springframework.graphql.GraphQlResponse} and adds
* support for decoding.
*
* @author Rossen Stoyanchev
* @since 1.0.0
*/
final class DefaultClientGraphQlResponseField implements ClientGraphQlResponseField {
final class DefaultClientResponseField implements ClientResponseField {
private final DefaultClientGraphQlResponse response;
private final GraphQlResponseField field;
private final ResponseField field;
DefaultClientGraphQlResponseField(DefaultClientGraphQlResponse response, GraphQlResponseField field) {
DefaultClientResponseField(DefaultClientGraphQlResponse response, ResponseField field) {
this.response = response;
this.field = field;
}
@@ -75,12 +75,12 @@ final class DefaultClientGraphQlResponseField implements ClientGraphQlResponseFi
}
@Override
public GraphQlResponseError getError() {
public ResponseError getError() {
return this.field.getError();
}
@Override
public List<GraphQlResponseError> getErrors() {
public List<ResponseError> getErrors() {
return this.field.getErrors();
}

View File

@@ -204,8 +204,8 @@ final class DefaultGraphQlClient implements GraphQlClient {
* @throws FieldAccessException for invalid response or failed field
*/
@Nullable
protected ClientGraphQlResponseField getValidField(ClientGraphQlResponse response) {
ClientGraphQlResponseField field = response.field(this.path);
protected ClientResponseField getValidField(ClientGraphQlResponse response) {
ClientResponseField field = response.field(this.path);
if (!response.isValid() || field.getError() != null) {
throw new FieldAccessException(response, field);
}
@@ -237,7 +237,7 @@ final class DefaultGraphQlClient implements GraphQlClient {
@Override
public <D> Mono<List<D>> toEntityList(Class<D> elementType) {
return this.responseMono.map(response -> {
ClientGraphQlResponseField field = getValidField(response);
ClientResponseField field = getValidField(response);
return (field != null ? field.toEntityList(elementType) : Collections.emptyList());
});
}
@@ -245,7 +245,7 @@ final class DefaultGraphQlClient implements GraphQlClient {
@Override
public <D> Mono<List<D>> toEntityList(ParameterizedTypeReference<D> elementType) {
return this.responseMono.map(response -> {
ClientGraphQlResponseField field = getValidField(response);
ClientResponseField field = getValidField(response);
return (field != null ? field.toEntityList(elementType) : Collections.emptyList());
});
}
@@ -275,7 +275,7 @@ final class DefaultGraphQlClient implements GraphQlClient {
@Override
public <D> Flux<List<D>> toEntityList(Class<D> elementType) {
return this.responseFlux.map(response -> {
ClientGraphQlResponseField field = getValidField(response);
ClientResponseField field = getValidField(response);
return (field != null ? field.toEntityList(elementType) : Collections.emptyList());
});
}
@@ -283,7 +283,7 @@ final class DefaultGraphQlClient implements GraphQlClient {
@Override
public <D> Flux<List<D>> toEntityList(ParameterizedTypeReference<D> elementType) {
return this.responseFlux.map(response -> {
ClientGraphQlResponseField field = getValidField(response);
ClientResponseField field = getValidField(response);
return (field != null ? field.toEntityList(elementType) : Collections.emptyList());
});
}

View File

@@ -18,12 +18,13 @@ package org.springframework.graphql.client;
import org.springframework.graphql.GraphQlResponse;
import org.springframework.graphql.ResponseField;
/**
* An exception raised on an attempt to decode data from a
* {@link GraphQlResponse#isValid() failed response} or a field is not present,
* or has no value, checked via
* {@link org.springframework.graphql.GraphQlResponseField#hasValue()}.
* {@link ResponseField#hasValue()}.
*
* @author Rossen Stoyanchev
* @since 1.0.0
@@ -33,19 +34,19 @@ public class FieldAccessException extends GraphQlClientException {
private final ClientGraphQlResponse response;
private final ClientGraphQlResponseField field;
private final ClientResponseField field;
/**
* Constructor with the request and response, and the accessed field.
*/
public FieldAccessException(ClientGraphQlResponse response, ClientGraphQlResponseField field) {
public FieldAccessException(ClientGraphQlResponse response, ClientResponseField field) {
super(initDefaultMessage(field), null, response.getRequest());
this.response = response;
this.field = field;
}
private static String initDefaultMessage(ClientGraphQlResponseField field) {
private static String initDefaultMessage(ClientResponseField field) {
return "Invalid field '" + field.getPath() + "', errors: " + field.getErrors();
}
@@ -60,7 +61,7 @@ public class FieldAccessException extends GraphQlClientException {
/**
* Return the field that needed to be accessed.
*/
public ClientGraphQlResponseField getField() {
public ClientResponseField getField() {
return this.field;
}

View File

@@ -23,6 +23,7 @@ import reactor.core.publisher.Mono;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.graphql.GraphQlResponse;
import org.springframework.graphql.ResponseField;
import org.springframework.graphql.support.DocumentSource;
import org.springframework.graphql.support.ResourceDocumentSource;
import org.springframework.lang.Nullable;
@@ -185,7 +186,7 @@ public interface GraphQlClient {
* the field is {@code null} without errors, or ends with
* {@link FieldAccessException} for an invalid response or a failed field
* @see GraphQlResponse#isValid()
* @see org.springframework.graphql.GraphQlResponseField#getError()
* @see ResponseField#getError()
*/
<D> Mono<D> toEntity(Class<D> entityType);
@@ -201,7 +202,7 @@ public interface GraphQlClient {
* empty list, or ends with {@link FieldAccessException} if the target
* field is not present or has no value.
* @see GraphQlResponse#isValid()
* @see org.springframework.graphql.GraphQlResponseField#getError()
* @see ResponseField#getError()
*/
<D> Mono<List<D>> toEntityList(Class<D> elementType);
@@ -226,7 +227,7 @@ public interface GraphQlClient {
* {@link FieldAccessException} for an invalid response or a failed field.
* May also end with a {@link GraphQlTransportException}.
* @see GraphQlResponse#isValid()
* @see org.springframework.graphql.GraphQlResponseField#getError()
* @see ResponseField#getError()
*/
<D> Flux<D> toEntity(Class<D> entityType);
@@ -243,7 +244,7 @@ public interface GraphQlClient {
* {@link FieldAccessException} for an invalid response or a failed field.
* May also end with a {@link GraphQlTransportException}.
* @see GraphQlResponse#isValid()
* @see org.springframework.graphql.GraphQlResponseField#getError()
* @see ResponseField#getError()
*/
<D> Flux<List<D>> toEntityList(Class<D> elementType);

View File

@@ -26,7 +26,7 @@ import graphql.GraphQLError;
import graphql.language.SourceLocation;
import org.springframework.graphql.GraphQlResponse;
import org.springframework.graphql.GraphQlResponseError;
import org.springframework.graphql.ResponseError;
import org.springframework.graphql.support.AbstractGraphQlResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@@ -42,7 +42,7 @@ class MapGraphQlResponse extends AbstractGraphQlResponse implements GraphQlRespo
private final Map<String, Object> responseMap;
private final List<GraphQlResponseError> errors;
private final List<ResponseError> errors;
MapGraphQlResponse(Map<String, Object> responseMap) {
@@ -58,7 +58,7 @@ class MapGraphQlResponse extends AbstractGraphQlResponse implements GraphQlRespo
}
@SuppressWarnings("unchecked")
private static List<GraphQlResponseError> wrapErrors(Map<String, Object> map) {
private static List<ResponseError> wrapErrors(Map<String, Object> map) {
List<Map<String, Object>> errors = (List<Map<String, Object>>) map.get("errors");
errors = (errors != null ? errors : Collections.emptyList());
return errors.stream().map(Error::new).collect(Collectors.toList());
@@ -71,7 +71,7 @@ class MapGraphQlResponse extends AbstractGraphQlResponse implements GraphQlRespo
}
@Override
public List<GraphQlResponseError> getErrors() {
public List<ResponseError> getErrors() {
return this.errors;
}
@@ -112,7 +112,7 @@ class MapGraphQlResponse extends AbstractGraphQlResponse implements GraphQlRespo
/**
* {@link GraphQLError} that wraps a deserialized the GraphQL response map.
*/
private static final class Error implements GraphQlResponseError {
private static final class Error implements ResponseError {
private final Map<String, Object> errorMap;
@@ -189,7 +189,7 @@ class MapGraphQlResponse extends AbstractGraphQlResponse implements GraphQlRespo
if (o == null || this.getClass() != o.getClass()) {
return false;
}
GraphQlResponseError other = (GraphQlResponseError) o;
ResponseError other = (ResponseError) o;
return (ObjectUtils.nullSafeEquals(getMessage(), other.getMessage()) &&
ObjectUtils.nullSafeEquals(getLocations(), other.getLocations()) &&
ObjectUtils.nullSafeEquals(getParsedPath(), other.getParsedPath()) &&

View File

@@ -19,7 +19,7 @@ package org.springframework.graphql.client;
import java.util.List;
import org.springframework.graphql.GraphQlRequest;
import org.springframework.graphql.GraphQlResponseError;
import org.springframework.graphql.ResponseError;
/**
* WebSocket {@link GraphQlTransportException} raised when a subscription
@@ -32,14 +32,14 @@ import org.springframework.graphql.GraphQlResponseError;
@SuppressWarnings("serial")
public class SubscriptionErrorException extends GraphQlTransportException {
private final List<GraphQlResponseError> errors;
private final List<ResponseError> errors;
/**
* Constructor with the request details and the errors listed in the payload
* of the {@code "errors"} message.
*/
public SubscriptionErrorException(GraphQlRequest request, List<GraphQlResponseError> errors) {
public SubscriptionErrorException(GraphQlRequest request, List<ResponseError> errors) {
super("GraphQL subscription completed with an \"error\" message, " +
"with the following errors: " + errors, null, request);
this.errors = errors;
@@ -49,7 +49,7 @@ public class SubscriptionErrorException extends GraphQlTransportException {
/**
* Return the errors contained in the GraphQL over WebSocket "errors" message.
*/
public List<GraphQlResponseError> getErrors() {
public List<ResponseError> getErrors() {
return this.errors;
}

View File

@@ -33,7 +33,7 @@ import reactor.core.publisher.Sinks;
import org.springframework.graphql.GraphQlRequest;
import org.springframework.graphql.GraphQlResponse;
import org.springframework.graphql.GraphQlResponseError;
import org.springframework.graphql.ResponseError;
import org.springframework.graphql.web.support.GraphQlMessage;
import org.springframework.graphql.web.support.GraphQlMessageType;
import org.springframework.http.HttpHeaders;
@@ -514,7 +514,7 @@ final class WebSocketGraphQlTransport implements GraphQlTransport {
emitResult = responseState.sink().tryEmitValue(response);
}
else {
List<GraphQlResponseError> errors = response.getErrors();
List<ResponseError> errors = response.getErrors();
Exception ex = new SubscriptionErrorException(subscriptionState.request(), errors);
emitResult = subscriptionState.sink().tryEmitError(ex);
}

View File

@@ -29,17 +29,17 @@ import reactor.core.publisher.Mono;
import org.springframework.graphql.ExecutionGraphQlRequest;
import org.springframework.graphql.ExecutionGraphQlResponse;
import org.springframework.graphql.GraphQlService;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.graphql.support.DefaultExecutionGraphQlResponse;
/**
* {@link GraphQlService} that uses a {@link GraphQlSource} to obtain a
* {@link ExecutionGraphQlService} that uses a {@link GraphQlSource} to obtain a
* {@link GraphQL} instance and perform query execution.
*
* @author Rossen Stoyanchev
* @since 1.0.0
*/
public class ExecutionGraphQlService implements GraphQlService {
public class DefaultExecutionGraphQlService implements ExecutionGraphQlService {
private static final BiFunction<ExecutionInput, ExecutionInput.Builder, ExecutionInput> RESET_EXECUTION_ID_CONFIGURER =
(executionInput, builder) -> builder.executionId(null).build();
@@ -52,7 +52,7 @@ public class ExecutionGraphQlService implements GraphQlService {
private final boolean isDefaultExecutionIdProvider;
public ExecutionGraphQlService(GraphQlSource graphQlSource) {
public DefaultExecutionGraphQlService(GraphQlSource graphQlSource) {
this.graphQlSource = graphQlSource;
this.isDefaultExecutionIdProvider =
(graphQlSource.graphQl().getIdProvider() == ExecutionIdProvider.DEFAULT_EXECUTION_ID_PROVIDER);

View File

@@ -24,8 +24,8 @@ import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.graphql.GraphQlResponse;
import org.springframework.graphql.GraphQlResponseError;
import org.springframework.graphql.GraphQlResponseField;
import org.springframework.graphql.ResponseError;
import org.springframework.graphql.ResponseField;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -33,7 +33,7 @@ import org.springframework.util.StringUtils;
/**
* Base class for {@link GraphQlResponse} that pre-implements the ability to
* access a {@link GraphQlResponseField}.
* access a {@link ResponseField}.
*
* @author Rossen Stoyanchev
* @since 1.0.0
@@ -42,15 +42,15 @@ public abstract class AbstractGraphQlResponse implements GraphQlResponse {
@Override
public GraphQlResponseField field(String path) {
return new DefaultGraphQlResponseField(this, path);
public ResponseField field(String path) {
return new DefaultResponseField(this, path);
}
/**
* Default implementation of {@link GraphQlResponseField}.
* Default implementation of {@link ResponseField}.
*/
private static class DefaultGraphQlResponseField implements GraphQlResponseField {
private static class DefaultResponseField implements ResponseField {
private final GraphQlResponse response;
@@ -61,10 +61,10 @@ public abstract class AbstractGraphQlResponse implements GraphQlResponse {
@Nullable
private final Object value;
private final List<GraphQlResponseError> fieldErrors;
private final List<ResponseError> fieldErrors;
DefaultGraphQlResponseField(GraphQlResponse response, String path) {
DefaultResponseField(GraphQlResponse response, String path) {
this.response = response;
this.path = path;
this.parsedPath = parsePath(path);
@@ -137,7 +137,7 @@ public abstract class AbstractGraphQlResponse implements GraphQlResponse {
* @param path the field path to match
* @return errors whose path starts with the dataPath
*/
private static List<GraphQlResponseError> initFieldErrors(String path, GraphQlResponse response) {
private static List<ResponseError> initFieldErrors(String path, GraphQlResponse response) {
if (path.isEmpty() || response.getErrors().isEmpty()) {
return Collections.emptyList();
}
@@ -172,7 +172,7 @@ public abstract class AbstractGraphQlResponse implements GraphQlResponse {
}
@Override
public GraphQlResponseError getError() {
public ResponseError getError() {
if (!hasValue()) {
if (!this.fieldErrors.isEmpty()) {
return this.fieldErrors.get(0);
@@ -186,7 +186,7 @@ public abstract class AbstractGraphQlResponse implements GraphQlResponse {
}
@Override
public List<GraphQlResponseError> getErrors() {
public List<ResponseError> getErrors() {
return this.fieldErrors;
}

View File

@@ -28,7 +28,7 @@ import graphql.language.SourceLocation;
import org.springframework.graphql.ExecutionGraphQlResponse;
import org.springframework.graphql.GraphQlResponse;
import org.springframework.graphql.GraphQlResponseError;
import org.springframework.graphql.ResponseError;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@@ -87,7 +87,7 @@ public class DefaultExecutionGraphQlResponse extends AbstractGraphQlResponse imp
}
@Override
public List<GraphQlResponseError> getErrors() {
public List<ResponseError> getErrors() {
return this.result.getErrors().stream().map(Error::new).collect(Collectors.toList());
}
@@ -110,7 +110,7 @@ public class DefaultExecutionGraphQlResponse extends AbstractGraphQlResponse imp
/**
* {@link GraphQLError} that wraps a {@link GraphQLError}.
*/
private static class Error implements GraphQlResponseError {
private static class Error implements ResponseError {
private final GraphQLError delegate;

View File

@@ -22,7 +22,7 @@ import java.util.List;
import reactor.core.publisher.Mono;
import org.springframework.graphql.GraphQlService;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.graphql.execution.ReactorContextManager;
import org.springframework.graphql.execution.ThreadLocalAccessor;
import org.springframework.lang.Nullable;
@@ -37,7 +37,7 @@ import org.springframework.util.CollectionUtils;
*/
class DefaultWebGraphQlHandlerBuilder implements WebGraphQlHandler.Builder {
private final GraphQlService service;
private final ExecutionGraphQlService service;
private final List<WebInterceptor> interceptors = new ArrayList<>();
@@ -48,7 +48,7 @@ class DefaultWebGraphQlHandlerBuilder implements WebGraphQlHandler.Builder {
private List<ThreadLocalAccessor> accessors;
DefaultWebGraphQlHandlerBuilder(GraphQlService service) {
DefaultWebGraphQlHandlerBuilder(ExecutionGraphQlService service) {
Assert.notNull(service, "GraphQlService is required");
this.service = service;
}

View File

@@ -20,7 +20,7 @@ import java.util.List;
import reactor.core.publisher.Mono;
import org.springframework.graphql.GraphQlService;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.graphql.execution.ThreadLocalAccessor;
@@ -50,18 +50,18 @@ public interface WebGraphQlHandler {
/**
* Provides access to a builder to create a {@link WebGraphQlHandler} instance.
* @param graphQlService the {@link GraphQlService} to use for actual execution of the
* @param graphQlService the {@link ExecutionGraphQlService} to use for actual execution of the
* request.
* @return a builder for a WebGraphQlHandler
*/
static Builder builder(GraphQlService graphQlService) {
static Builder builder(ExecutionGraphQlService graphQlService) {
return new DefaultWebGraphQlHandlerBuilder(graphQlService);
}
/**
* Builder for a {@link WebGraphQlHandler} that executes a
* {@link WebInterceptor} chain followed by a {@link GraphQlService}.
* {@link WebInterceptor} chain followed by a {@link ExecutionGraphQlService}.
*/
interface Builder {

View File

@@ -21,6 +21,7 @@ import graphql.ExecutionResult;
import reactor.core.publisher.Mono;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.util.Assert;
/**
@@ -43,7 +44,7 @@ public interface WebInterceptor {
/**
* Intercept a request and delegate to the rest of the chain that consists
* of other interceptors followed by a
* {@link org.springframework.graphql.GraphQlService} that executes the
* {@link ExecutionGraphQlService} that executes the
* request through the GraphQL Java.
* @param request provides access to GraphQL request and allows customization
* of the {@link ExecutionInput} for {@link graphql.GraphQL}.

View File

@@ -18,6 +18,8 @@ package org.springframework.graphql.web;
import graphql.ExecutionInput;
import reactor.core.publisher.Mono;
import org.springframework.graphql.ExecutionGraphQlService;
/**
* Allows a {@link WebInterceptor} to invoke the rest of the chain.
*
@@ -28,7 +30,7 @@ public interface WebInterceptorChain {
/**
* Delegate to the rest of the chain that consists of other interceptors
* followed by a {@link org.springframework.graphql.GraphQlService} that
* followed by a {@link ExecutionGraphQlService} that
* executes the request through the GraphQL Java.
* @param request provides access to GraphQL request and allows customizing
* the {@link ExecutionInput} for {@link graphql.GraphQL}.

View File

@@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.graphql.support.DefaultGraphQlRequest;
import org.springframework.graphql.GraphQlResponseError;
import org.springframework.graphql.ResponseError;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.lang.Nullable;
@@ -127,8 +127,8 @@ public class DefaultGraphQlClientResponseTests {
GraphQLError error2 = createError("/me/friends", "fail-me-friends");
GraphQLError error3 = createError("/me/friends[0]/name", "fail-me-friends-name");
ClientGraphQlResponseField field = getField(path, error0, error1, error2, error3);
List<GraphQlResponseError> errors = field.getErrors();
ClientResponseField field = getField(path, error0, error1, error2, error3);
List<ResponseError> errors = field.getErrors();
assertThat(errors).hasSize(3);
assertThat(errors.get(0).getPath()).isEqualTo("me");
@@ -144,13 +144,13 @@ public class DefaultGraphQlClientResponseTests {
return builder.build();
}
private ClientGraphQlResponseField getField(String path, String dataJson) throws Exception {
private ClientResponseField getField(String path, String dataJson) throws Exception {
Map<?, ?> dataMap = mapper.readValue(dataJson, Map.class);
ClientGraphQlResponse response = creatResponse(Collections.singletonMap("data", dataMap));
return response.field(path);
}
private ClientGraphQlResponseField getField(String path, GraphQLError... errors) {
private ClientResponseField getField(String path, GraphQLError... errors) {
List<?> list = Arrays.stream(errors).map(GraphQLError::toSpecification).collect(Collectors.toList());
ClientGraphQlResponse response = creatResponse(Collections.singletonMap("errors", list));
return response.field(path);

View File

@@ -189,7 +189,7 @@ public class GraphQlClientTests extends GraphQlClientTestSupport {
.as("Partial response with field errors should be considered valid")
.isTrue();
ClientGraphQlResponseField field = response.field("me");
ClientResponseField field = response.field("me");
assertThat(field.hasValue()).isTrue();
assertThat(field.getErrors()).hasSize(1);
assertThat(field.getErrors().get(0).getParsedPath()).containsExactly("me", "name");
@@ -197,7 +197,7 @@ public class GraphQlClientTests extends GraphQlClientTestSupport {
.as("Decoding with nested field error should not be precluded")
.isNotNull();
ClientGraphQlResponseField nameField = response.field("me.name");
ClientResponseField nameField = response.field("me.name");
assertThat(nameField.hasValue()).isFalse();
assertThat(nameField.getError()).isNotNull();
assertThat(nameField.getError().getParsedPath()).containsExactly("me", "name");
@@ -205,7 +205,7 @@ public class GraphQlClientTests extends GraphQlClientTestSupport {
.as("Decoding field null with direct field error should be rejected")
.isInstanceOf(FieldAccessException.class);
ClientGraphQlResponseField nonExistingField = response.field("me.name.other");
ClientResponseField nonExistingField = response.field("me.name.other");
assertThat(nonExistingField.hasValue()).isFalse();
assertThat(nameField.getError()).isNotNull();
assertThat(nameField.getError().getParsedPath()).containsExactly("me", "name");

View File

@@ -34,7 +34,7 @@ import reactor.test.StepVerifier;
import org.springframework.graphql.support.DefaultGraphQlRequest;
import org.springframework.graphql.GraphQlRequest;
import org.springframework.graphql.GraphQlResponse;
import org.springframework.graphql.GraphQlResponseError;
import org.springframework.graphql.ResponseError;
import org.springframework.graphql.web.TestWebSocketClient;
import org.springframework.graphql.web.TestWebSocketConnection;
import org.springframework.graphql.web.support.GraphQlMessage;
@@ -111,7 +111,7 @@ public class MockWebSocketGraphQlTransportTests {
StepVerifier.create(this.transport.execute(request))
.consumeNextWith(result -> {
assertThat(result.isValid()).isFalse();
assertThat(result.getErrors()).extracting(GraphQlResponseError::getMessage).containsExactly("boo");
assertThat(result.getErrors()).extracting(ResponseError::getMessage).containsExactly("boo");
})
.expectComplete()
.verify(TIMEOUT);
@@ -129,8 +129,8 @@ public class MockWebSocketGraphQlTransportTests {
StepVerifier.create(this.transport.executeSubscription(request))
.expectNext(this.response1)
.expectErrorSatisfies(actualEx -> {
List<GraphQlResponseError> errors = ((SubscriptionErrorException) actualEx).getErrors();
assertThat(errors).extracting(GraphQlResponseError::getMessage).containsExactly("boo");
List<ResponseError> errors = ((SubscriptionErrorException) actualEx).getErrors();
assertThat(errors).extracting(ResponseError::getMessage).containsExactly("boo");
})
.verify(TIMEOUT);

View File

@@ -28,7 +28,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.graphql.GraphQlService;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.graphql.GraphQlSetup;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.graphql.execution.BatchLoaderRegistry;
@@ -79,7 +79,7 @@ public class BatchMappingTestSupport {
"}";
protected GraphQlService createGraphQlService(CourseController controller) {
protected ExecutionGraphQlService createGraphQlService(CourseController controller) {
BatchLoaderRegistry registry = new DefaultBatchLoaderRegistry();
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();

View File

@@ -35,7 +35,7 @@ import org.springframework.graphql.BookCriteria;
import org.springframework.graphql.BookSource;
import org.springframework.graphql.ExecutionGraphQlRequest;
import org.springframework.graphql.ExecutionGraphQlResponse;
import org.springframework.graphql.GraphQlService;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.graphql.GraphQlSetup;
import org.springframework.graphql.ResponseHelper;
import org.springframework.graphql.TestExecutionRequest;
@@ -205,7 +205,7 @@ public class SchemaMappingInvocationTests {
}
private GraphQlService graphQlService() {
private ExecutionGraphQlService graphQlService() {
BatchLoaderRegistry registry = new DefaultBatchLoaderRegistry();
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();

View File

@@ -32,12 +32,12 @@ import reactor.util.context.Context;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.MethodParameter;
import org.springframework.graphql.ExecutionGraphQlResponse;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.graphql.ResponseHelper;
import org.springframework.graphql.GraphQlSetup;
import org.springframework.graphql.TestExecutionRequest;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.graphql.data.method.annotation.SubscriptionMapping;
import org.springframework.graphql.execution.ExecutionGraphQlService;
import org.springframework.graphql.execution.ReactorContextManager;
import org.springframework.graphql.execution.SecurityContextThreadLocalAccessor;
import org.springframework.lang.Nullable;

View File

@@ -29,7 +29,7 @@ import org.springframework.graphql.Book;
import org.springframework.graphql.BookSource;
import org.springframework.graphql.ExecutionGraphQlResponse;
import org.springframework.graphql.ResponseHelper;
import org.springframework.graphql.GraphQlService;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.graphql.GraphQlSetup;
import org.springframework.graphql.TestExecutionRequest;
@@ -60,7 +60,7 @@ public class BatchLoadingTests {
this.registry.forTypePair(Long.class, Author.class)
.registerBatchLoader((ids, env) -> Flux.fromIterable(ids).map(BookSource::getAuthor));
GraphQlService service = GraphQlSetup.schemaResource(BookSource.schema)
ExecutionGraphQlService service = GraphQlSetup.schemaResource(BookSource.schema)
.queryFetcher("booksByCriteria", env -> {
Map<String, Object> criteria = env.getArgument("criteria");
String authorName = (String) criteria.get("author");

View File

@@ -19,7 +19,7 @@ import org.springframework.graphql.execution.DataLoaderRegistrar;
import org.springframework.graphql.web.WebGraphQlSetup;
/**
* Workflow that results in the creation of a {@link GraphQlService} or a
* Workflow that results in the creation of a {@link ExecutionGraphQlService} or a
* {@link org.springframework.graphql.web.WebGraphQlHandler}.
*
* @author Rossen Stoyanchev
@@ -28,6 +28,6 @@ public interface GraphQlServiceSetup extends WebGraphQlSetup {
GraphQlServiceSetup dataLoaders(DataLoaderRegistrar... registrars);
GraphQlService toGraphQlService();
ExecutionGraphQlService toGraphQlService();
}

View File

@@ -31,7 +31,7 @@ import org.springframework.core.io.Resource;
import org.springframework.graphql.data.method.annotation.support.AnnotatedControllerConfigurer;
import org.springframework.graphql.execution.DataFetcherExceptionResolver;
import org.springframework.graphql.execution.DataLoaderRegistrar;
import org.springframework.graphql.execution.ExecutionGraphQlService;
import org.springframework.graphql.execution.DefaultExecutionGraphQlService;
import org.springframework.graphql.execution.GraphQlSource;
import org.springframework.graphql.execution.RuntimeWiringConfigurer;
import org.springframework.graphql.execution.ThreadLocalAccessor;
@@ -42,7 +42,7 @@ import org.springframework.graphql.web.WebInterceptor;
/**
* Workflow for GraphQL tests setup that starts with {@link GraphQlSource.Builder}
* related input, and then optionally moving on to the creation of a
* {@link GraphQlService} or a {@link WebGraphQlHandler}.
* {@link ExecutionGraphQlService} or a {@link WebGraphQlHandler}.
*
* @author Rossen Stoyanchev
*/
@@ -126,7 +126,7 @@ public class GraphQlSetup implements GraphQlServiceSetup {
public ExecutionGraphQlService toGraphQlService() {
GraphQlSource source = graphQlSourceBuilder.build();
ExecutionGraphQlService service = new ExecutionGraphQlService(source);
DefaultExecutionGraphQlService service = new DefaultExecutionGraphQlService(source);
this.dataLoaderRegistrars.forEach(service::addDataLoaderRegistrar);
return service;
}