Polishing client and tester reference docs

Also minor fix for WebSocket client subsections that appeared
incorrectly nested under RSocket.

See gh-368
This commit is contained in:
rstoyanchev
2022-05-04 12:58:44 +01:00
parent 85ad5bbfb4
commit 5348129dc5
2 changed files with 80 additions and 66 deletions

View File

@@ -14,16 +14,22 @@ WebSocket, and RSocket.
[[client-graphqlclient]]
== `GraphQlClient`
`GraphQlClient` defines a common workflow for executing GraphQL requests and
subscriptions that is independent of and agnostic to the underlying transport. To create
an instance, you'll need to start from either the <<client-httpgraphqlclient,
HttpGraphQlClient>> or the <<client-websocketgraphqlclient,WebSocketGraphQlClient>>
extensions.
`GraphQlClient` is a contract that declares a common workflow for GraphQL requests that is
independent of the underlying transport. That means requests are executed with the same API
no matter what the underlying transport, and anything transport specific is configured at
build time.
Each `GraphQlClient` extension provides a transport specific `Builder`. There is also a
shared, base <<client-graphqlclient-builder>> in `GraphQlClient` with common options for
all extensions.
To create a `GraphQlClient` you need one of the following extensions:
- <<client-httpgraphqlclient, HttpGraphQlClient>>
- <<client-websocketgraphqlclient, WebSocketGraphQlClient>>
- <<client-rsocketgraphqlclient, RSocketGraphQlClient>>
Each defines a `Builder` with options relevant to the transport. All builders extend
from a common, base GraphQlClient <<client-graphqlclient-builder, `Builder`>> with options
relevant to all extensions.
Once you have a `GraphQlClient` you can begin to make <<client-requests, requests>>.
[[client-httpgraphqlclient]]
@@ -39,14 +45,10 @@ WebClient webClient = ... ;
HttpGraphQlClient graphQlClient = HttpGraphQlClient.create(webClient);
----
The `HttpGraphQlClient` extension is nothing but a `GraphQlClient` with a specialized
builder. Once created, it exposes the same workflow for request execution that is
independent of the underlying transport.
This means you can only configure HTTP request details at build time, and
those apply to all requests through that client instance. To change HTTP request
details, use `mutate()` on an existing `HttpGraphQlClient` to create another
instance with different configuration:
Once `HttpGraphQlClient` is created, you can begin to
<<client-requests, execute requests>> using the same API, independent of the underlying
transport. If you need to change any transport specific details, use `mutate()` on an
existing `HttpGraphQlClient` to create a new instance with customized settings:
[source,java,indent=0,subs="verbatim,quotes"]
----
@@ -83,9 +85,10 @@ from Spring WebFlux to execute GraphQL requests over WebSocket:
WebSocketGraphQlClient graphQlClient = WebSocketGraphQlClient.builder(url, client).build();
----
Once created, `WebSocketGraphQlClient` exposes the same transport agnostic workflow for
request execution as any `GrahQlClient`. To change any transport details, use `mutate()`
on an existing `WebSocketGraphQlClient` to create another with different configuration:
Once `WebSocketGraphQlClient` is created, you can begin to
<<client-requests, execute requests>> using the same API, independent of the underlying
transport. If you need to change any transport specific details, use `mutate()` on an
existing `WebSocketGraphQlClient` to create a new instance with customized settings:
[source,java,indent=0,subs="verbatim,quotes"]
----
@@ -107,27 +110,6 @@ on an existing `WebSocketGraphQlClient` to create another with different configu
----
[[client-rsocketgraphqlclient]]
=== RSocket
`RSocketGraphQlClient` uses
{spring-framework-ref-docs}/web-reactive.html#rsocket-requester[RSocketRequester]
to execute GraphQL requests over RSocket requests.
[source,java,indent=0,subs="verbatim,quotes"]
----
RSocketGraphQlClient graphQlClient =
RSocketGraphQlClient.builder()
.websocket(URI.create("http://localhost:8080/graphql"))
.build();
----
Once created, `RSocketGraphQlClient` exposes the same transport agnostic workflow for
request execution as any `GrahQlClient`.
[[client-websocketgraphqlclient-connection]]
==== Connection
@@ -144,7 +126,6 @@ stopped client rejects new requests. Use `start()` to re-establish the connectio
allow requests again.
[[client-websocketgraphqlclient-interceptor]]
==== Interceptor
@@ -179,6 +160,27 @@ can be at most one interceptor of type `WebSocketGraphQlClientInterceptor`.
[[client-rsocketgraphqlclient]]
=== RSocket
`RSocketGraphQlClient` uses
{spring-framework-ref-docs}/web-reactive.html#rsocket-requester[RSocketRequester]
to execute GraphQL requests over RSocket requests.
[source,java,indent=0,subs="verbatim,quotes"]
----
RSocketGraphQlClient graphQlClient =
RSocketGraphQlClient.builder()
.websocket(URI.create("http://localhost:8080/graphql"))
.build();
----
Once `RSocketGraphQlClient` is created, you can begin to
<<client-requests, execute requests>> using the same API, independent of the underlying
transport.
[[client-graphqlclient-builder]]
=== Builder

View File

@@ -39,19 +39,26 @@ dependencies {
[[testing-graphqltester]]
== `GraphQlTester`
`GraphQlTester` defines a common workflow for testing GraphQL requests. It is
independent of and agnostic to the underlying transport. To create an instance, you'll
need to choose a specific `GraphQlTester` extension as a starting point.
`GraphQlTester` is a contract that declares a common workflow for testing GraphQL
requests that is independent of the underlying transport. That means requests are tested
with the same API no matter what the underlying transport, and anything transport
specific is configured at build time.
To test with a client sending requests over a transport, use one of the
<<testing-httpgraphqltester>>, <<testing-websocketgraphqltester>>, or
<<testing-rsocketgraphqltester>> extensions. To test the server without client,
use the<<testing-graphqlservicetester>> or <<testing-webgraphqltester>>
extensions.
To create a `GraphQlTester` that performs requests through a client, you need one of the
following extensions:
Each `GraphQlTester` extension provides a transport specific `Builder`. There is also a
shared, base <<testing-graphqltester-builder>> in `GraphQlTester` with common options
for all extensions.
- <<testing-httpgraphqltester, HttpGraphQlTester>>
- <<testing-websocketgraphqltester, WebSocketGraphQlTester>>
- <<testing-rsocketgraphqltester, RSocketGraphQlTester>>
To create a `GraphQlTester` that performs tests on the server side, without a client:
- <<testing-graphqlservicetester, ExecutionGraphQlServiceTester>>
- <<testing-webgraphqltester, WebGraphQlServiceTester>>
Each defines a `Builder` with options relevant to the transport. All builders extend
from a common, base GraphQlTester <<testing-graphqltester-builder, `Builder`>> with
options relevant to all extensions.
@@ -106,14 +113,10 @@ Or to test against a live server running on a port:
HttpGraphQlTester tester = HttpGraphQlTester.create(client);
----
The `HttpGraphQlTester` extension is nothing but a `GraphQlTester` with a specialized
builder. Once created, it exposes the same workflow for testing requests that is
independent of the underlying transport.
This means you can only configure HTTP request details at build time, and
those apply to all requests through that Tester instance. To change HTTP request
details, use `mutate()` on an existing `HttpGraphQlTester` to create another
instance with different configuration:
Once `HttpGraphQlTester` is created, you can begin to
<<testing-requests, execute requests>> using the same API, independent of the underlying
transport. If you need to change any transport specific details, use `mutate()` on an
existing `HttpSocketGraphQlTester` to create a new instance with customized settings:
[source,java,indent=0,subs="verbatim,quotes"]
----
@@ -148,9 +151,11 @@ from Spring WebFlux to execute GraphQL requests over WebSocket:
WebSocketGraphQlTester tester = WebSocketGraphQlTester.builder(url, client).build();
----
Once created, `WebSocketGraphQlTester` exposes the same transport agnostic workflow for
request execution as any `GraphQlTester`. To change any transport details, use `mutate()`
on an existing `WebSocketGraphQlTester` to create another with different configuration:
Once `WebSocketGraphQlTester` is created, you can begin to
<<testing-requests, execute requests>> using the same API, independent of the underlying
transport. If you need to change any transport specific details, use `mutate()` on an
existing `WebSocketGraphQlTester` to create a new instance with customized settings:
[source,java,indent=0,subs="verbatim,quotes"]
----
@@ -188,9 +193,9 @@ requests over RSocket:
.build();
----
Once created, `RSocketGraphQlTester` exposes the same transport agnostic workflow for
request execution as any `GraphQlTester`.
Once `RSocketGraphQlTester` is created, you can begin to
<<testing-requests, execute requests>> using the same API, independent of the underlying
transport.
[[testing-graphqlservicetester]]
@@ -206,6 +211,9 @@ client to send requests over a transport protocol. To test directly against a
ExecutionGraphQlServiceTester tester = ExecutionGraphQlServiceTester.create(service);
----
Once `ExecutionGraphQlServiceTester` is created, you can begin to
<<testing-requests, execute requests>> using the same API, independent of the underlying
transport.
[[testing-webgraphqltester]]
@@ -236,6 +244,10 @@ The builder for this extension allows you to define HTTP request details:
.build();
----
Once `WebGraphQlServiceTester` is created, you can begin to
<<testing-requests, execute requests>> using the same API, independent of the underlying
transport.
[[testing-graphqltester-builder]]