Skip to content

Commit 91e7f28

Browse files
committed
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
1 parent 67711f7 commit 91e7f28

File tree

43 files changed

+168
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+168
-164
lines changed

spring-graphql-docs/src/docs/asciidoc/client.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ response and the field:
183183
.onErrorResume(FieldAccessException.class, ex -> {
184184
ClientGraphQlResponse response = ex.getResponse();
185185
// ...
186-
GraphQlResponseField field = ex.getField();
186+
ResponseField field = ex.getField();
187187
// ...
188188
});
189189
----

spring-graphql-docs/src/docs/asciidoc/index.adoc

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ The Spring for GraphQL repository contains a WebFlux
118118

119119
<<web-http>> and <<web-websocket>> transport handlers delegate to a common Web
120120
interception chain for request execution. The chain consists of a sequence of
121-
`WebInterceptor` components, followed by a `GraphQlService` that invokes the GraphQL
122-
Java engine.
121+
`WebInterceptor` components, followed by a `ExecutionGraphQlService` that invokes
122+
GraphQL Java.
123123

124124
`WebInterceptor` is as a common contract to use in both Spring MVC and WebFlux
125125
applications. Use it to intercept requests, inspect HTTP request headers, or to register a
@@ -170,13 +170,12 @@ it contains, for the actual config.
170170
[[execution]]
171171
== Request Execution
172172

173-
`GraphQlService` is the main Spring abstraction to call GraphQL Java to execute
174-
requests. Underlying transports, such as the <<web-transports>>, delegate to `GraphQlService` to
175-
handle requests.
173+
`ExecutionGraphQlService` is the main Spring abstraction to call GraphQL Java to execute
174+
requests. Underlying transports, such as the <<web-transports>>, delegate to
175+
`ExecutionGraphQlService` to handle requests.
176176

177-
The main implementation, `ExecutionGraphQlService`, is a thin facade around the
178-
invocation of `graphql.GraphQL`. It is configured with a `GraphQlSource` for access to
179-
the `graphql.GraphQL` instance.
177+
The main implementation, `DefaultExecutionGraphQlService`, is configured with a
178+
`GraphQlSource` for access to the `graphql.GraphQL` instance to invoke.
180179

181180

182181

@@ -413,10 +412,10 @@ transport layer, such as from a WebFlux request handling, see
413412
[[execution-context]]
414413
=== Context Propagation
415414

416-
Spring for GraphQL provides support to transparently propagate context from the <<web-transports>>,
417-
through the GraphQL engine, and to `DataFetcher` and other components it invokes.
418-
This includes both `ThreadLocal` context from the Spring MVC request handling thread and
419-
Reactor `Context` from the WebFlux processing pipeline.
415+
Spring for GraphQL provides support to transparently propagate context from the
416+
<<web-transports>>, through GraphQL Java, and to `DataFetcher` and other components it
417+
invokes. This includes both `ThreadLocal` context from the Spring MVC request handling
418+
thread and Reactor `Context` from the WebFlux processing pipeline.
420419

421420

422421
[[execution-context-webmvc]]
@@ -427,7 +426,7 @@ the same thread as the Spring MVC handler, for example if an asynchronous
427426
<<web-interception, `WebInterceptor`>> or `DataFetcher` switches to a different thread.
428427

429428
Spring for GraphQL supports propagating `ThreadLocal` values from the Servlet container
430-
thread to the thread a `DataFetcher` and other components invoked by the GraphQL engine
429+
thread to the thread a `DataFetcher` and other components invoked by GraphQL Java to
431430
execute on. To do this, an application needs to create a `ThreadLocalAccessor` to extract
432431
`ThreadLocal` values of interest:
433432

@@ -558,7 +557,7 @@ public class MyConfig {
558557
The Spring Boot starter declares a `BatchLoaderRegistry` bean that you can inject into
559558
your configuration, as shown above, or into any component such as a controller in order
560559
register batch loading functions. In turn the `BatchLoaderRegistry` is injected into
561-
`ExecutionGraphQlService` where it ensures `DataLoader` registrations per request.
560+
`DefaultExecutionGraphQlService` where it ensures `DataLoader` registrations per request.
562561

563562
By default, the `DataLoader` name is based on the class name of the target entity.
564563
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
12021201

12031202
TIP: The `@Argument` annotation does not have a "required" flag, nor the option to
12041203
specify a default value. Both of these can be specified at the GraphQL schema level and
1205-
are enforced by the GraphQL Engine.
1204+
are enforced by GraphQL Java.
12061205

12071206
You can use `@Argument` on a `Map<String, Object>` argument, to obtain all argument
12081207
values. The name attribute on `@Argument` must not be set.

spring-graphql-docs/src/docs/asciidoc/testing.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ connection closed, e.g. after a test runs.
179179

180180
Many times it's enough to test GraphQL requests on the server side, without the use of a
181181
client to send requests over a transport protocol. To test directly against a
182-
`GraphQlService`, use the `GraphQlServiceTester` extension:
182+
`ExecutionGraphQlService`, use the `GraphQlServiceTester` extension:
183183

184184
[source,java,indent=0,subs="verbatim,quotes"]
185185
----
@@ -197,7 +197,7 @@ a client. However, in some cases it's useful to involve server side transport
197197
handling with given mock transport input.
198198

199199
The `WebGraphQlHandlerTester` extension lets you processes request through the
200-
`WebInterceptor` chain before handing off to `GraphQlService` for request execution:
200+
`WebInterceptor` chain before handing off to `ExecutionGraphQlService` for request execution:
201201

202202
[source,java,indent=0,subs="verbatim,quotes"]
203203
----

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/AbstractDirectTransport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.springframework.graphql.ExecutionGraphQlResponse;
2828
import org.springframework.graphql.GraphQlRequest;
2929
import org.springframework.graphql.GraphQlResponse;
30-
import org.springframework.graphql.GraphQlResponseError;
30+
import org.springframework.graphql.ResponseError;
3131
import org.springframework.graphql.support.DefaultExecutionGraphQlRequest;
3232
import org.springframework.graphql.support.DefaultExecutionGraphQlResponse;
3333
import org.springframework.graphql.client.GraphQlTransport;
@@ -61,7 +61,7 @@ public Flux<GraphQlResponse> executeSubscription(GraphQlRequest request) {
6161
Object data = response.getData();
6262
AssertionErrors.assertTrue("Not a Publisher: " + data, data instanceof Publisher);
6363

64-
List<GraphQlResponseError> errors = response.getErrors();
64+
List<ResponseError> errors = response.getErrors();
6565
AssertionErrors.assertTrue("Subscription errors: " + errors, CollectionUtils.isEmpty(errors));
6666

6767
return Flux.from((Publisher<ExecutionResult>) data).map(executionResult ->

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/AbstractGraphQlTesterBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;
2626
import com.jayway.jsonpath.spi.mapper.MappingProvider;
2727

28-
import org.springframework.graphql.GraphQlResponseError;
28+
import org.springframework.graphql.ResponseError;
2929
import org.springframework.graphql.client.AbstractGraphQlClientBuilder;
3030
import org.springframework.graphql.client.GraphQlTransport;
3131
import org.springframework.graphql.support.CachingDocumentSource;
@@ -57,7 +57,7 @@ public abstract class AbstractGraphQlTesterBuilder<B extends AbstractGraphQlTest
5757

5858

5959
@Nullable
60-
private Predicate<GraphQlResponseError> errorFilter;
60+
private Predicate<ResponseError> errorFilter;
6161

6262
private DocumentSource documentSource = new CachingDocumentSource(new ResourceDocumentSource());
6363

@@ -67,7 +67,7 @@ public abstract class AbstractGraphQlTesterBuilder<B extends AbstractGraphQlTest
6767

6868

6969
@Override
70-
public B errorFilter(Predicate<GraphQlResponseError> predicate) {
70+
public B errorFilter(Predicate<ResponseError> predicate) {
7171
this.errorFilter = (this.errorFilter != null ? errorFilter.and(predicate) : predicate);
7272
return self();
7373
}

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultGraphQlServiceTester.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
import java.util.function.Consumer;
2121

22-
import org.springframework.graphql.GraphQlService;
22+
import org.springframework.graphql.ExecutionGraphQlService;
2323
import org.springframework.util.Assert;
2424

2525

2626
/**
27-
* Default {@link GraphQlServiceTester} that uses a {@link GraphQlService} for
27+
* Default {@link GraphQlServiceTester} that uses a {@link ExecutionGraphQlService} for
2828
* request execution.
2929
*
3030
* @author Rossen Stoyanchev
@@ -64,9 +64,9 @@ public Builder<?> mutate() {
6464
static class Builder<B extends Builder<B>> extends AbstractGraphQlTesterBuilder<B>
6565
implements GraphQlServiceTester.Builder<B> {
6666

67-
private final GraphQlService service;
67+
private final ExecutionGraphQlService service;
6868

69-
Builder(GraphQlService service) {
69+
Builder(ExecutionGraphQlService service) {
7070
Assert.notNull(service, "GraphQlService is required");
7171
this.service = service;
7272
}

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/DefaultGraphQlTester.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import org.springframework.graphql.support.DefaultGraphQlRequest;
3838
import org.springframework.graphql.GraphQlRequest;
3939
import org.springframework.graphql.GraphQlResponse;
40-
import org.springframework.graphql.GraphQlResponseError;
40+
import org.springframework.graphql.ResponseError;
4141
import org.springframework.graphql.client.GraphQlTransport;
4242
import org.springframework.graphql.support.DocumentSource;
4343
import org.springframework.lang.Nullable;
@@ -62,7 +62,7 @@ final class DefaultGraphQlTester implements GraphQlTester {
6262
private final GraphQlTransport transport;
6363

6464
@Nullable
65-
private final Predicate<GraphQlResponseError> errorFilter;
65+
private final Predicate<ResponseError> errorFilter;
6666

6767
private final Configuration jsonPathConfig;
6868

@@ -77,7 +77,7 @@ final class DefaultGraphQlTester implements GraphQlTester {
7777
* Package private constructor for use from {@link AbstractGraphQlTesterBuilder}.
7878
*/
7979
DefaultGraphQlTester(
80-
GraphQlTransport transport, @Nullable Predicate<GraphQlResponseError> errorFilter,
80+
GraphQlTransport transport, @Nullable Predicate<ResponseError> errorFilter,
8181
Configuration jsonPathConfig, DocumentSource documentSource, Duration timeout,
8282
Consumer<AbstractGraphQlTesterBuilder<?>> builderInitializer) {
8383

@@ -210,15 +210,15 @@ private final static class ResponseDelegate {
210210

211211
private final Supplier<String> jsonContent;
212212

213-
private final List<GraphQlResponseError> errors;
213+
private final List<ResponseError> errors;
214214

215-
private final List<GraphQlResponseError> unexpectedErrors;
215+
private final List<ResponseError> unexpectedErrors;
216216

217217
private final Consumer<Runnable> assertDecorator;
218218

219219

220220
private ResponseDelegate(
221-
GraphQlResponse response, @Nullable Predicate<GraphQlResponseError> errorFilter,
221+
GraphQlResponse response, @Nullable Predicate<ResponseError> errorFilter,
222222
Consumer<Runnable> assertDecorator, Configuration jsonPathConfig) {
223223

224224
this.jsonDoc = JsonPath.parse(response.toMap(), jsonPathConfig);
@@ -254,9 +254,9 @@ void doAssert(Runnable task) {
254254
this.assertDecorator.accept(task);
255255
}
256256

257-
boolean filterErrors(Predicate<GraphQlResponseError> predicate) {
257+
boolean filterErrors(Predicate<ResponseError> predicate) {
258258
boolean filtered = false;
259-
for (GraphQlResponseError error : this.errors) {
259+
for (ResponseError error : this.errors) {
260260
if (predicate.test(error)) {
261261
this.unexpectedErrors.remove(error);
262262
filtered = true;
@@ -265,12 +265,12 @@ boolean filterErrors(Predicate<GraphQlResponseError> predicate) {
265265
return filtered;
266266
}
267267

268-
void expectErrors(Predicate<GraphQlResponseError> predicate) {
268+
void expectErrors(Predicate<ResponseError> predicate) {
269269
boolean filtered = filterErrors(predicate);
270270
this.assertDecorator.accept(() -> AssertionErrors.assertTrue("No matching errors.", filtered));
271271
}
272272

273-
void consumeErrors(Consumer<List<GraphQlResponseError>> consumer) {
273+
void consumeErrors(Consumer<List<ResponseError>> consumer) {
274274
filterErrors(error -> true);
275275
consumer.accept(this.errors);
276276
}
@@ -294,7 +294,7 @@ private static final class DefaultResponse implements Response, Errors {
294294
private final ResponseDelegate delegate;
295295

296296
private DefaultResponse(
297-
GraphQlResponse response, @Nullable Predicate<GraphQlResponseError> errorFilter,
297+
GraphQlResponse response, @Nullable Predicate<ResponseError> errorFilter,
298298
Consumer<Runnable> assertDecorator, Configuration jsonPathConfig) {
299299

300300
this.delegate = new ResponseDelegate(response, errorFilter, assertDecorator, jsonPathConfig);
@@ -312,13 +312,13 @@ public Errors errors() {
312312
}
313313

314314
@Override
315-
public Errors filter(Predicate<GraphQlResponseError> predicate) {
315+
public Errors filter(Predicate<ResponseError> predicate) {
316316
this.delegate.filterErrors(predicate);
317317
return this;
318318
}
319319

320320
@Override
321-
public Errors expect(Predicate<GraphQlResponseError> predicate) {
321+
public Errors expect(Predicate<ResponseError> predicate) {
322322
this.delegate.expectErrors(predicate);
323323
return this;
324324
}
@@ -330,7 +330,7 @@ public Traversable verify() {
330330
}
331331

332332
@Override
333-
public Traversable satisfy(Consumer<List<GraphQlResponseError>> consumer) {
333+
public Traversable satisfy(Consumer<List<ResponseError>> consumer) {
334334
this.delegate.consumeErrors(consumer);
335335
return this;
336336
}

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlServiceTester.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
package org.springframework.graphql.test.tester;
1818

19-
import org.springframework.graphql.GraphQlService;
19+
import org.springframework.graphql.ExecutionGraphQlService;
2020

2121
/**
22-
* {@link GraphQlTester} that executes requests through a {@link GraphQlService}
22+
* {@link GraphQlTester} that executes requests through a {@link ExecutionGraphQlService}
2323
* Use it for server-side tests, without a client.
2424
*
2525
* @author Rossen Stoyanchev
@@ -35,14 +35,14 @@ public interface GraphQlServiceTester extends GraphQlTester {
3535
/**
3636
* Create a {@link GraphQlServiceTester} instance.
3737
*/
38-
static GraphQlServiceTester create(GraphQlService service) {
38+
static GraphQlServiceTester create(ExecutionGraphQlService service) {
3939
return builder(service).build();
4040
}
4141

4242
/**
4343
* Return a builder for {@link GraphQlServiceTester}.
4444
*/
45-
static GraphQlServiceTester.Builder<?> builder(GraphQlService service) {
45+
static GraphQlServiceTester.Builder<?> builder(ExecutionGraphQlService service) {
4646
return new DefaultGraphQlServiceTester.Builder<>(service);
4747
}
4848

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlServiceTransport.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,28 @@
2121

2222
import org.springframework.graphql.ExecutionGraphQlRequest;
2323
import org.springframework.graphql.ExecutionGraphQlResponse;
24-
import org.springframework.graphql.GraphQlService;
24+
import org.springframework.graphql.ExecutionGraphQlService;
2525
import org.springframework.util.Assert;
2626

2727

2828
/**
29-
* {@code GraphQlTransport} that calls directly a {@link GraphQlService}.
29+
* {@code GraphQlTransport} that calls directly a {@link ExecutionGraphQlService}.
3030
*
3131
* @author Rossen Stoyanchev
3232
* @since 1.0.0
3333
*/
3434
final class GraphQlServiceTransport extends AbstractDirectTransport {
3535

36-
private final GraphQlService graphQlService;
36+
private final ExecutionGraphQlService graphQlService;
3737

3838

39-
GraphQlServiceTransport(GraphQlService graphQlService) {
39+
GraphQlServiceTransport(ExecutionGraphQlService graphQlService) {
4040
Assert.notNull(graphQlService, "GraphQlService is required");
4141
this.graphQlService = graphQlService;
4242
}
4343

4444

45-
public GraphQlService getGraphQlService() {
45+
public ExecutionGraphQlService getGraphQlService() {
4646
return this.graphQlService;
4747
}
4848

spring-graphql-test/src/main/java/org/springframework/graphql/test/tester/GraphQlTester.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import reactor.core.publisher.Flux;
2525

2626
import org.springframework.core.ParameterizedTypeReference;
27-
import org.springframework.graphql.GraphQlResponseError;
27+
import org.springframework.graphql.ResponseError;
2828
import org.springframework.graphql.client.GraphQlTransport;
2929
import org.springframework.graphql.support.DocumentSource;
3030
import org.springframework.graphql.support.ResourceDocumentSource;
@@ -103,7 +103,7 @@ interface Builder<B extends Builder<B>> {
103103
* @param predicate the error filter to add
104104
* @return the same builder instance
105105
*/
106-
B errorFilter(Predicate<GraphQlResponseError> predicate);
106+
B errorFilter(Predicate<ResponseError> predicate);
107107

108108
/**
109109
* Configure a {@link DocumentSource} for use with
@@ -448,7 +448,7 @@ interface Errors {
448448
* @param errorPredicate the error filter to add
449449
* @return the same spec to add more filters before {@link #verify()}
450450
*/
451-
Errors filter(Predicate<GraphQlResponseError> errorPredicate);
451+
Errors filter(Predicate<ResponseError> errorPredicate);
452452

453453
/**
454454
* Use this to declare errors that are expected.
@@ -461,7 +461,7 @@ interface Errors {
461461
* @param errorPredicate the predicate for the expected error
462462
* @return the same spec to add more filters or expected errors
463463
*/
464-
Errors expect(Predicate<GraphQlResponseError> errorPredicate);
464+
Errors expect(Predicate<ResponseError> errorPredicate);
465465

466466
/**
467467
* Verify there are either no errors or that there no unexpected errors that have
@@ -477,7 +477,7 @@ interface Errors {
477477
* @param errorsConsumer to inspect errors with
478478
* @return a spec to switch to a data path
479479
*/
480-
Traversable satisfy(Consumer<List<GraphQlResponseError>> errorsConsumer);
480+
Traversable satisfy(Consumer<List<ResponseError>> errorsConsumer);
481481

482482
}
483483

0 commit comments

Comments
 (0)