From 91e7f285fa15772b6e4741640df0d4eb932c6d12 Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Sun, 20 Mar 2022 20:47:15 +0000 Subject: [PATCH] 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 --- .../src/docs/asciidoc/client.adoc | 2 +- .../src/docs/asciidoc/index.adoc | 29 +++++++++---------- .../src/docs/asciidoc/testing.adoc | 4 +-- .../test/tester/AbstractDirectTransport.java | 4 +-- .../tester/AbstractGraphQlTesterBuilder.java | 6 ++-- .../tester/DefaultGraphQlServiceTester.java | 8 ++--- .../test/tester/DefaultGraphQlTester.java | 28 +++++++++--------- .../test/tester/GraphQlServiceTester.java | 8 ++--- .../test/tester/GraphQlServiceTransport.java | 10 +++---- .../graphql/test/tester/GraphQlTester.java | 10 +++---- .../tester/GraphQlTesterBuilderTests.java | 4 +-- .../test/tester/GraphQlTesterTestSupport.java | 4 +-- .../test/tester/GraphQlTesterTests.java | 4 +-- ...vice.java => ExecutionGraphQlService.java} | 2 +- .../graphql/GraphQlResponse.java | 8 ++--- ...lResponseError.java => ResponseError.java} | 2 +- ...lResponseField.java => ResponseField.java} | 8 ++--- .../graphql/client/ClientGraphQlResponse.java | 2 +- ...nseField.java => ClientResponseField.java} | 6 ++-- .../client/DefaultClientGraphQlResponse.java | 4 +-- ...d.java => DefaultClientResponseField.java} | 16 +++++----- .../graphql/client/DefaultGraphQlClient.java | 12 ++++---- .../graphql/client/FieldAccessException.java | 11 +++---- .../graphql/client/GraphQlClient.java | 9 +++--- .../graphql/client/MapGraphQlResponse.java | 12 ++++---- .../client/SubscriptionErrorException.java | 8 ++--- .../client/WebSocketGraphQlTransport.java | 4 +-- ...va => DefaultExecutionGraphQlService.java} | 8 ++--- .../support/AbstractGraphQlResponse.java | 24 +++++++-------- .../DefaultExecutionGraphQlResponse.java | 6 ++-- .../web/DefaultWebGraphQlHandlerBuilder.java | 6 ++-- .../graphql/web/WebGraphQlHandler.java | 8 ++--- .../graphql/web/WebInterceptor.java | 3 +- .../graphql/web/WebInterceptorChain.java | 4 ++- .../DefaultGraphQlClientResponseTests.java | 10 +++---- .../graphql/client/GraphQlClientTests.java | 6 ++-- .../MockWebSocketGraphQlTransportTests.java | 8 ++--- .../support/BatchMappingTestSupport.java | 4 +-- .../support/SchemaMappingInvocationTests.java | 4 +-- ...gPrincipalMethodArgumentResolverTests.java | 2 +- .../graphql/execution/BatchLoadingTests.java | 4 +-- .../graphql/GraphQlServiceSetup.java | 4 +-- .../springframework/graphql/GraphQlSetup.java | 6 ++-- 43 files changed, 168 insertions(+), 164 deletions(-) rename spring-graphql/src/main/java/org/springframework/graphql/{GraphQlService.java => ExecutionGraphQlService.java} (96%) rename spring-graphql/src/main/java/org/springframework/graphql/{GraphQlResponseError.java => ResponseError.java} (98%) rename spring-graphql/src/main/java/org/springframework/graphql/{GraphQlResponseField.java => ResponseField.java} (95%) rename spring-graphql/src/main/java/org/springframework/graphql/client/{ClientGraphQlResponseField.java => ClientResponseField.java} (89%) rename spring-graphql/src/main/java/org/springframework/graphql/client/{DefaultClientGraphQlResponseField.java => DefaultClientResponseField.java} (85%) rename spring-graphql/src/main/java/org/springframework/graphql/execution/{ExecutionGraphQlService.java => DefaultExecutionGraphQlService.java} (92%) diff --git a/spring-graphql-docs/src/docs/asciidoc/client.adoc b/spring-graphql-docs/src/docs/asciidoc/client.adoc index b1a0eeb0..014c4820 100644 --- a/spring-graphql-docs/src/docs/asciidoc/client.adoc +++ b/spring-graphql-docs/src/docs/asciidoc/client.adoc @@ -183,7 +183,7 @@ response and the field: .onErrorResume(FieldAccessException.class, ex -> { ClientGraphQlResponse response = ex.getResponse(); // ... - GraphQlResponseField field = ex.getField(); + ResponseField field = ex.getField(); // ... }); ---- diff --git a/spring-graphql-docs/src/docs/asciidoc/index.adoc b/spring-graphql-docs/src/docs/asciidoc/index.adoc index 2c726a1b..fb2be3a7 100644 --- a/spring-graphql-docs/src/docs/asciidoc/index.adoc +++ b/spring-graphql-docs/src/docs/asciidoc/index.adoc @@ -118,8 +118,8 @@ The Spring for GraphQL repository contains a WebFlux <> and <> 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 <>, delegate to `GraphQlService` to -handle requests. +`ExecutionGraphQlService` is the main Spring abstraction to call GraphQL Java to execute +requests. Underlying transports, such as the <>, 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 <>, -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 +<>, 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 <> 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` argument, to obtain all argument values. The name attribute on `@Argument` must not be set. diff --git a/spring-graphql-docs/src/docs/asciidoc/testing.adoc b/spring-graphql-docs/src/docs/asciidoc/testing.adoc index 9144d596..39e987c9 100644 --- a/spring-graphql-docs/src/docs/asciidoc/testing.adoc +++ b/spring-graphql-docs/src/docs/asciidoc/testing.adoc @@ -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"] ---- diff --git a/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/AbstractDirectTransport.java b/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/AbstractDirectTransport.java index e4a05702..0c802b8a 100644 --- a/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/AbstractDirectTransport.java +++ b/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/AbstractDirectTransport.java @@ -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 errors = response.getErrors(); + List errors = response.getErrors(); AssertionErrors.assertTrue("Subscription errors: " + errors, CollectionUtils.isEmpty(errors)); return Flux.from((Publisher) data).map(executionResult -> diff --git a/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/AbstractGraphQlTesterBuilder.java b/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/AbstractGraphQlTesterBuilder.java index b326cd6c..608d1737 100644 --- a/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/AbstractGraphQlTesterBuilder.java +++ b/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/AbstractGraphQlTesterBuilder.java @@ -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 errorFilter; + private Predicate errorFilter; private DocumentSource documentSource = new CachingDocumentSource(new ResourceDocumentSource()); @@ -67,7 +67,7 @@ public abstract class AbstractGraphQlTesterBuilder predicate) { + public B errorFilter(Predicate predicate) { this.errorFilter = (this.errorFilter != null ? errorFilter.and(predicate) : predicate); return self(); } diff --git a/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultGraphQlServiceTester.java b/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultGraphQlServiceTester.java index 7b670221..caeaa367 100644 --- a/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultGraphQlServiceTester.java +++ b/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultGraphQlServiceTester.java @@ -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> extends AbstractGraphQlTesterBuilder implements GraphQlServiceTester.Builder { - private final GraphQlService service; + private final ExecutionGraphQlService service; - Builder(GraphQlService service) { + Builder(ExecutionGraphQlService service) { Assert.notNull(service, "GraphQlService is required"); this.service = service; } diff --git a/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultGraphQlTester.java b/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultGraphQlTester.java index 5011a9e8..ee98ee85 100644 --- a/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultGraphQlTester.java +++ b/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultGraphQlTester.java @@ -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 errorFilter; + private final Predicate 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 errorFilter, + GraphQlTransport transport, @Nullable Predicate errorFilter, Configuration jsonPathConfig, DocumentSource documentSource, Duration timeout, Consumer> builderInitializer) { @@ -210,15 +210,15 @@ final class DefaultGraphQlTester implements GraphQlTester { private final Supplier jsonContent; - private final List errors; + private final List errors; - private final List unexpectedErrors; + private final List unexpectedErrors; private final Consumer assertDecorator; private ResponseDelegate( - GraphQlResponse response, @Nullable Predicate errorFilter, + GraphQlResponse response, @Nullable Predicate errorFilter, Consumer 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 predicate) { + boolean filterErrors(Predicate 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 predicate) { + void expectErrors(Predicate predicate) { boolean filtered = filterErrors(predicate); this.assertDecorator.accept(() -> AssertionErrors.assertTrue("No matching errors.", filtered)); } - void consumeErrors(Consumer> consumer) { + void consumeErrors(Consumer> 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 errorFilter, + GraphQlResponse response, @Nullable Predicate errorFilter, Consumer 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 predicate) { + public Errors filter(Predicate predicate) { this.delegate.filterErrors(predicate); return this; } @Override - public Errors expect(Predicate predicate) { + public Errors expect(Predicate predicate) { this.delegate.expectErrors(predicate); return this; } @@ -330,7 +330,7 @@ final class DefaultGraphQlTester implements GraphQlTester { } @Override - public Traversable satisfy(Consumer> consumer) { + public Traversable satisfy(Consumer> consumer) { this.delegate.consumeErrors(consumer); return this; } diff --git a/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlServiceTester.java b/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlServiceTester.java index d95c21c4..889621f6 100644 --- a/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlServiceTester.java +++ b/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlServiceTester.java @@ -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); } diff --git a/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlServiceTransport.java b/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlServiceTransport.java index 51a3b6bf..f55a195f 100644 --- a/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlServiceTransport.java +++ b/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlServiceTransport.java @@ -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; } diff --git a/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlTester.java b/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlTester.java index 1e4eb028..5fbed6af 100644 --- a/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlTester.java +++ b/spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlTester.java @@ -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 predicate); + B errorFilter(Predicate 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 errorPredicate); + Errors filter(Predicate 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 errorPredicate); + Errors expect(Predicate 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> errorsConsumer); + Traversable satisfy(Consumer> errorsConsumer); } diff --git a/spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/GraphQlTesterBuilderTests.java b/spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/GraphQlTesterBuilderTests.java index 7de80353..51781c11 100644 --- a/spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/GraphQlTesterBuilderTests.java +++ b/spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/GraphQlTesterBuilderTests.java @@ -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 */ diff --git a/spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/GraphQlTesterTestSupport.java b/spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/GraphQlTesterTestSupport.java index bf48a4c9..0d788a0f 100644 --- a/spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/GraphQlTesterTestSupport.java +++ b/spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/GraphQlTesterTestSupport.java @@ -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 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); diff --git a/spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/GraphQlTesterTests.java b/spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/GraphQlTesterTests.java index 68e46f7a..c9adb946 100644 --- a/spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/GraphQlTesterTests.java +++ b/spring-graphql-test/src/test/java/org/springframework/graphql/test/tester/GraphQlTesterTests.java @@ -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 */ diff --git a/spring-graphql/src/main/java/org/springframework/graphql/GraphQlService.java b/spring-graphql/src/main/java/org/springframework/graphql/ExecutionGraphQlService.java similarity index 96% rename from spring-graphql/src/main/java/org/springframework/graphql/GraphQlService.java rename to spring-graphql/src/main/java/org/springframework/graphql/ExecutionGraphQlService.java index 738dc53f..932352ac 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/GraphQlService.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/ExecutionGraphQlService.java @@ -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. diff --git a/spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponse.java b/spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponse.java index 11291576..fc809930 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponse.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponse.java @@ -58,12 +58,12 @@ public interface GraphQlResponse { * Return errors included in the response. *

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}. *

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 getErrors(); + List getErrors(); /** * Navigate to the given path under the "data" key of the response map where @@ -78,10 +78,10 @@ public interface GraphQlResponse { * * @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. diff --git a/spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponseError.java b/spring-graphql/src/main/java/org/springframework/graphql/ResponseError.java similarity index 98% rename from spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponseError.java rename to spring-graphql/src/main/java/org/springframework/graphql/ResponseError.java index e6c13b25..b30898ff 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponseError.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/ResponseError.java @@ -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 diff --git a/spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponseField.java b/spring-graphql/src/main/java/org/springframework/graphql/ResponseField.java similarity index 95% rename from spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponseField.java rename to spring-graphql/src/main/java/org/springframework/graphql/ResponseField.java index f830cd1f..c7ec8dce 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/GraphQlResponseField.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/ResponseField.java @@ -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 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 does not have a value, there should be only one * field error, and in that case it is better to use {@link #getError()}. */ - List getErrors(); + List getErrors(); } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/client/ClientGraphQlResponse.java b/spring-graphql/src/main/java/org/springframework/graphql/client/ClientGraphQlResponse.java index 962c011c..b986f260 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/client/ClientGraphQlResponse.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/client/ClientGraphQlResponse.java @@ -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. diff --git a/spring-graphql/src/main/java/org/springframework/graphql/client/ClientGraphQlResponseField.java b/spring-graphql/src/main/java/org/springframework/graphql/client/ClientResponseField.java similarity index 89% rename from spring-graphql/src/main/java/org/springframework/graphql/client/ClientGraphQlResponseField.java rename to spring-graphql/src/main/java/org/springframework/graphql/client/ClientResponseField.java index fb9ba227..99921591 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/client/ClientGraphQlResponseField.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/client/ClientResponseField.java @@ -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. diff --git a/spring-graphql/src/main/java/org/springframework/graphql/client/DefaultClientGraphQlResponse.java b/spring-graphql/src/main/java/org/springframework/graphql/client/DefaultClientGraphQlResponse.java index 7da9f122..76807ae4 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/client/DefaultClientGraphQlResponse.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/client/DefaultClientGraphQlResponse.java @@ -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 diff --git a/spring-graphql/src/main/java/org/springframework/graphql/client/DefaultClientGraphQlResponseField.java b/spring-graphql/src/main/java/org/springframework/graphql/client/DefaultClientResponseField.java similarity index 85% rename from spring-graphql/src/main/java/org/springframework/graphql/client/DefaultClientGraphQlResponseField.java rename to spring-graphql/src/main/java/org/springframework/graphql/client/DefaultClientResponseField.java index 58178d66..337417f2 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/client/DefaultClientGraphQlResponseField.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/client/DefaultClientResponseField.java @@ -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 getErrors() { + public List getErrors() { return this.field.getErrors(); } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/client/DefaultGraphQlClient.java b/spring-graphql/src/main/java/org/springframework/graphql/client/DefaultGraphQlClient.java index 486060b2..6a5a9db9 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/client/DefaultGraphQlClient.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/client/DefaultGraphQlClient.java @@ -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 Mono> toEntityList(Class 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 Mono> toEntityList(ParameterizedTypeReference 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 Flux> toEntityList(Class 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 Flux> toEntityList(ParameterizedTypeReference elementType) { return this.responseFlux.map(response -> { - ClientGraphQlResponseField field = getValidField(response); + ClientResponseField field = getValidField(response); return (field != null ? field.toEntityList(elementType) : Collections.emptyList()); }); } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/client/FieldAccessException.java b/spring-graphql/src/main/java/org/springframework/graphql/client/FieldAccessException.java index 9f695f63..a074c309 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/client/FieldAccessException.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/client/FieldAccessException.java @@ -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; } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/client/GraphQlClient.java b/spring-graphql/src/main/java/org/springframework/graphql/client/GraphQlClient.java index a453180a..96026737 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/client/GraphQlClient.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/client/GraphQlClient.java @@ -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() */ Mono toEntity(Class 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() */ Mono> toEntityList(Class 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() */ Flux toEntity(Class 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() */ Flux> toEntityList(Class elementType); diff --git a/spring-graphql/src/main/java/org/springframework/graphql/client/MapGraphQlResponse.java b/spring-graphql/src/main/java/org/springframework/graphql/client/MapGraphQlResponse.java index 8ecd5ab1..f04e80ad 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/client/MapGraphQlResponse.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/client/MapGraphQlResponse.java @@ -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 responseMap; - private final List errors; + private final List errors; MapGraphQlResponse(Map responseMap) { @@ -58,7 +58,7 @@ class MapGraphQlResponse extends AbstractGraphQlResponse implements GraphQlRespo } @SuppressWarnings("unchecked") - private static List wrapErrors(Map map) { + private static List wrapErrors(Map map) { List> errors = (List>) 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 getErrors() { + public List 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 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()) && diff --git a/spring-graphql/src/main/java/org/springframework/graphql/client/SubscriptionErrorException.java b/spring-graphql/src/main/java/org/springframework/graphql/client/SubscriptionErrorException.java index f17c0b84..775ad801 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/client/SubscriptionErrorException.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/client/SubscriptionErrorException.java @@ -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 errors; + private final List errors; /** * Constructor with the request details and the errors listed in the payload * of the {@code "errors"} message. */ - public SubscriptionErrorException(GraphQlRequest request, List errors) { + public SubscriptionErrorException(GraphQlRequest request, List 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 getErrors() { + public List getErrors() { return this.errors; } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/client/WebSocketGraphQlTransport.java b/spring-graphql/src/main/java/org/springframework/graphql/client/WebSocketGraphQlTransport.java index 127ba608..384ddd94 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/client/WebSocketGraphQlTransport.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/client/WebSocketGraphQlTransport.java @@ -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 errors = response.getErrors(); + List errors = response.getErrors(); Exception ex = new SubscriptionErrorException(subscriptionState.request(), errors); emitResult = subscriptionState.sink().tryEmitError(ex); } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/execution/ExecutionGraphQlService.java b/spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultExecutionGraphQlService.java similarity index 92% rename from spring-graphql/src/main/java/org/springframework/graphql/execution/ExecutionGraphQlService.java rename to spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultExecutionGraphQlService.java index 61e0fbdd..6186397a 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/execution/ExecutionGraphQlService.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultExecutionGraphQlService.java @@ -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 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); diff --git a/spring-graphql/src/main/java/org/springframework/graphql/support/AbstractGraphQlResponse.java b/spring-graphql/src/main/java/org/springframework/graphql/support/AbstractGraphQlResponse.java index f01dbef9..965779a6 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/support/AbstractGraphQlResponse.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/support/AbstractGraphQlResponse.java @@ -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 fieldErrors; + private final List 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 initFieldErrors(String path, GraphQlResponse response) { + private static List 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 getErrors() { + public List getErrors() { return this.fieldErrors; } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/support/DefaultExecutionGraphQlResponse.java b/spring-graphql/src/main/java/org/springframework/graphql/support/DefaultExecutionGraphQlResponse.java index ca3b670c..e2d2195d 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/support/DefaultExecutionGraphQlResponse.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/support/DefaultExecutionGraphQlResponse.java @@ -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 getErrors() { + public List 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; diff --git a/spring-graphql/src/main/java/org/springframework/graphql/web/DefaultWebGraphQlHandlerBuilder.java b/spring-graphql/src/main/java/org/springframework/graphql/web/DefaultWebGraphQlHandlerBuilder.java index 34ec8a4c..ca184aa2 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/web/DefaultWebGraphQlHandlerBuilder.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/web/DefaultWebGraphQlHandlerBuilder.java @@ -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 interceptors = new ArrayList<>(); @@ -48,7 +48,7 @@ class DefaultWebGraphQlHandlerBuilder implements WebGraphQlHandler.Builder { private List accessors; - DefaultWebGraphQlHandlerBuilder(GraphQlService service) { + DefaultWebGraphQlHandlerBuilder(ExecutionGraphQlService service) { Assert.notNull(service, "GraphQlService is required"); this.service = service; } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/web/WebGraphQlHandler.java b/spring-graphql/src/main/java/org/springframework/graphql/web/WebGraphQlHandler.java index 5dc9fe9f..46d9e9e8 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/web/WebGraphQlHandler.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/web/WebGraphQlHandler.java @@ -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 { diff --git a/spring-graphql/src/main/java/org/springframework/graphql/web/WebInterceptor.java b/spring-graphql/src/main/java/org/springframework/graphql/web/WebInterceptor.java index 3dec5b48..d6c187ae 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/web/WebInterceptor.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/web/WebInterceptor.java @@ -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}. diff --git a/spring-graphql/src/main/java/org/springframework/graphql/web/WebInterceptorChain.java b/spring-graphql/src/main/java/org/springframework/graphql/web/WebInterceptorChain.java index 415f9bed..34ddc18a 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/web/WebInterceptorChain.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/web/WebInterceptorChain.java @@ -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}. diff --git a/spring-graphql/src/test/java/org/springframework/graphql/client/DefaultGraphQlClientResponseTests.java b/spring-graphql/src/test/java/org/springframework/graphql/client/DefaultGraphQlClientResponseTests.java index e00a1687..9e9f7c35 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/client/DefaultGraphQlClientResponseTests.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/client/DefaultGraphQlClientResponseTests.java @@ -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 errors = field.getErrors(); + ClientResponseField field = getField(path, error0, error1, error2, error3); + List 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); diff --git a/spring-graphql/src/test/java/org/springframework/graphql/client/GraphQlClientTests.java b/spring-graphql/src/test/java/org/springframework/graphql/client/GraphQlClientTests.java index dc88f66c..68ef608a 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/client/GraphQlClientTests.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/client/GraphQlClientTests.java @@ -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"); diff --git a/spring-graphql/src/test/java/org/springframework/graphql/client/MockWebSocketGraphQlTransportTests.java b/spring-graphql/src/test/java/org/springframework/graphql/client/MockWebSocketGraphQlTransportTests.java index 665b9eb8..fd858e91 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/client/MockWebSocketGraphQlTransportTests.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/client/MockWebSocketGraphQlTransportTests.java @@ -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 errors = ((SubscriptionErrorException) actualEx).getErrors(); - assertThat(errors).extracting(GraphQlResponseError::getMessage).containsExactly("boo"); + List errors = ((SubscriptionErrorException) actualEx).getErrors(); + assertThat(errors).extracting(ResponseError::getMessage).containsExactly("boo"); }) .verify(TIMEOUT); diff --git a/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/BatchMappingTestSupport.java b/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/BatchMappingTestSupport.java index 398cf95c..a63e9b00 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/BatchMappingTestSupport.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/BatchMappingTestSupport.java @@ -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(); diff --git a/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/SchemaMappingInvocationTests.java b/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/SchemaMappingInvocationTests.java index 0cd2137e..07e01b60 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/SchemaMappingInvocationTests.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/SchemaMappingInvocationTests.java @@ -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(); diff --git a/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/SchemaMappingPrincipalMethodArgumentResolverTests.java b/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/SchemaMappingPrincipalMethodArgumentResolverTests.java index acdaea77..0490fb9c 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/SchemaMappingPrincipalMethodArgumentResolverTests.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/data/method/annotation/support/SchemaMappingPrincipalMethodArgumentResolverTests.java @@ -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; diff --git a/spring-graphql/src/test/java/org/springframework/graphql/execution/BatchLoadingTests.java b/spring-graphql/src/test/java/org/springframework/graphql/execution/BatchLoadingTests.java index d383f52e..2c75bf93 100644 --- a/spring-graphql/src/test/java/org/springframework/graphql/execution/BatchLoadingTests.java +++ b/spring-graphql/src/test/java/org/springframework/graphql/execution/BatchLoadingTests.java @@ -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 criteria = env.getArgument("criteria"); String authorName = (String) criteria.get("author"); diff --git a/spring-graphql/src/testFixtures/java/org/springframework/graphql/GraphQlServiceSetup.java b/spring-graphql/src/testFixtures/java/org/springframework/graphql/GraphQlServiceSetup.java index ca8af98e..8a3c027c 100644 --- a/spring-graphql/src/testFixtures/java/org/springframework/graphql/GraphQlServiceSetup.java +++ b/spring-graphql/src/testFixtures/java/org/springframework/graphql/GraphQlServiceSetup.java @@ -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(); } diff --git a/spring-graphql/src/testFixtures/java/org/springframework/graphql/GraphQlSetup.java b/spring-graphql/src/testFixtures/java/org/springframework/graphql/GraphQlSetup.java index 7c82e958..b3c08aa2 100644 --- a/spring-graphql/src/testFixtures/java/org/springframework/graphql/GraphQlSetup.java +++ b/spring-graphql/src/testFixtures/java/org/springframework/graphql/GraphQlSetup.java @@ -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; }