1
- include::attributes.adoc[]
2
-
3
-
4
-
5
-
6
1
[[client]]
7
2
= Client
8
3
@@ -11,7 +6,7 @@ WebSocket, and RSocket.
11
6
12
7
13
8
14
- [[client- graphqlclient]]
9
+ [[client. graphqlclient]]
15
10
== `GraphQlClient`
16
11
17
12
`GraphQlClient` is a contract that declares a common workflow for GraphQL requests that is
@@ -21,18 +16,18 @@ build time.
21
16
22
17
To create a `GraphQlClient` you need one of the following extensions:
23
18
24
- - <<client- httpgraphqlclient, HttpGraphQlClient>>
25
- - <<client- websocketgraphqlclient, WebSocketGraphQlClient>>
26
- - <<client- rsocketgraphqlclient, RSocketGraphQlClient>>
19
+ - <<client. httpgraphqlclient, HttpGraphQlClient>>
20
+ - <<client. websocketgraphqlclient, WebSocketGraphQlClient>>
21
+ - <<client. rsocketgraphqlclient, RSocketGraphQlClient>>
27
22
28
23
Each defines a `Builder` with options relevant to the transport. All builders extend
29
- from a common, base GraphQlClient <<client- graphqlclient- builder, `Builder`>> with options
24
+ from a common, base GraphQlClient <<client. graphqlclient. builder, `Builder`>> with options
30
25
relevant to all extensions.
31
26
32
- Once you have a `GraphQlClient` you can begin to make <<client- requests, requests>>.
27
+ Once you have a `GraphQlClient` you can begin to make <<client. requests, requests>>.
33
28
34
29
35
- [[client- httpgraphqlclient]]
30
+ [[client. httpgraphqlclient]]
36
31
=== HTTP
37
32
38
33
`HttpGraphQlClient` uses
@@ -46,7 +41,7 @@ HttpGraphQlClient graphQlClient = HttpGraphQlClient.create(webClient);
46
41
----
47
42
48
43
Once `HttpGraphQlClient` is created, you can begin to
49
- <<client- requests, execute requests>> using the same API, independent of the underlying
44
+ <<client. requests, execute requests>> using the same API, independent of the underlying
50
45
transport. If you need to change any transport specific details, use `mutate()` on an
51
46
existing `HttpGraphQlClient` to create a new instance with customized settings:
52
47
@@ -70,7 +65,7 @@ existing `HttpGraphQlClient` to create a new instance with customized settings:
70
65
71
66
72
67
73
- [[client- websocketgraphqlclient]]
68
+ [[client. websocketgraphqlclient]]
74
69
=== WebSocket
75
70
76
71
`WebSocketGraphQlClient` executes GraphQL requests over a shared WebSocket connection.
@@ -102,7 +97,7 @@ single, shared connection for all requests to that server. Each client instance
102
97
establishes its own connection and that is typically not the intent for a single server.
103
98
104
99
Once `WebSocketGraphQlClient` is created, you can begin to
105
- <<client- requests, execute requests>> using the same API, independent of the underlying
100
+ <<client. requests, execute requests>> using the same API, independent of the underlying
106
101
transport. If you need to change any transport specific details, use `mutate()` on an
107
102
existing `WebSocketGraphQlClient` to create a new instance with customized settings:
108
103
@@ -126,7 +121,7 @@ existing `WebSocketGraphQlClient` to create a new instance with customized setti
126
121
----
127
122
128
123
129
- [[client- websocketgraphqlclient- interceptor]]
124
+ [[client. websocketgraphqlclient. interceptor]]
130
125
==== Interceptor
131
126
132
127
The https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md[GraphQL over WebSocket]
@@ -154,13 +149,13 @@ For WebSocket transport specific interception, you can create a
154
149
}
155
150
----
156
151
157
- <<client- interception,Register>> the above interceptor as any other
152
+ <<client. interception,Register>> the above interceptor as any other
158
153
`GraphQlClientInterceptor` and use it also to intercept GraphQL requests, but note there
159
154
can be at most one interceptor of type `WebSocketGraphQlClientInterceptor`.
160
155
161
156
162
157
163
- [[client- rsocketgraphqlclient]]
158
+ [[client. rsocketgraphqlclient]]
164
159
=== RSocket
165
160
166
161
`RSocketGraphQlClient` uses
@@ -192,33 +187,33 @@ single, shared session for all requests to that server. Each client instance
192
187
establishes its own connection and that is typically not the intent for a single server.
193
188
194
189
Once `RSocketGraphQlClient` is created, you can begin to
195
- <<client- requests, execute requests>> using the same API, independent of the underlying
190
+ <<client. requests, execute requests>> using the same API, independent of the underlying
196
191
transport.
197
192
198
193
199
194
200
- [[client- graphqlclient- builder]]
195
+ [[client. graphqlclient. builder]]
201
196
=== Builder
202
197
203
198
`GraphQlClient` defines a parent `Builder` with common configuration options for the
204
199
builders of all extensions. Currently, it has lets you configure:
205
200
206
201
- `DocumentSource` strategy to load the document for a request from a file
207
- - <<client- interception>> of executed requests
202
+ - <<client. interception>> of executed requests
208
203
209
204
210
205
211
206
212
- [[client- requests]]
207
+ [[client. requests]]
213
208
== Requests
214
209
215
- Once you have a <<client- graphqlclient>>, you can begin to perform requests via
216
- <<client- requests- retrieve, retrieve()>> or <<client- requests- execute, execute()>>
210
+ Once you have a <<client. graphqlclient>>, you can begin to perform requests via
211
+ <<client. requests. retrieve, retrieve()>> or <<client. requests. execute, execute()>>
217
212
where the former is only a shortcut for the latter.
218
213
219
214
220
215
221
- [[client- requests- retrieve]]
216
+ [[client. requests. retrieve]]
222
217
=== Retrieve
223
218
224
219
The below retrieves and decodes the data for a query:
@@ -244,7 +239,7 @@ The below retrieves and decodes the data for a query:
244
239
245
240
The input document is a `String` that could be a literal or produced through a code
246
241
generated request object. You can also define documents in files and use a
247
- <<client- requests- document-source>> to resole them by file name.
242
+ <<client. requests. document-source>> to resole them by file name.
248
243
249
244
The path is relative to the "data" key and uses a simple dot (".") separated notation
250
245
for nested fields with optional array indices for list elements, e.g. `"project.name"`
@@ -269,10 +264,10 @@ response and the field:
269
264
270
265
271
266
272
- [[client- requests- execute]]
267
+ [[client. requests. execute]]
273
268
=== Execute
274
269
275
- <<client- requests- retrieve>> is only a shortcut to decode from a single path in the
270
+ <<client. requests. retrieve>> is only a shortcut to decode from a single path in the
276
271
response map. For more control, use the `execute` method and handle the response:
277
272
278
273
For example:
@@ -307,7 +302,7 @@ For example:
307
302
308
303
309
304
310
- [[client- requests- document-source]]
305
+ [[client. requests. document-source]]
311
306
=== Document Source
312
307
313
308
The document for a request is a `String` that may be defined in a local variable or
@@ -346,26 +341,26 @@ You can then:
346
341
347
342
The "JS GraphQL" plugin for IntelliJ supports GraphQL query files with code completion.
348
343
349
- You can use the `GraphQlClient` <<client- graphqlclient- builder>> to customize the
344
+ You can use the `GraphQlClient` <<client. graphqlclient. builder>> to customize the
350
345
`DocumentSource` for loading documents by names.
351
346
352
347
353
348
354
349
355
- [[client- subscriptions]]
350
+ [[client. subscriptions]]
356
351
== Subscription Requests
357
352
358
353
`GraphQlClient` can execute subscriptions over transports that support it. Currently, only
359
354
the WebSocket transport supports GraphQL streams, so you'll need to create a
360
- <<client- websocketgraphqlclient,WebSocketGraphQlClient>>.
355
+ <<client. websocketgraphqlclient,WebSocketGraphQlClient>>.
361
356
362
357
363
358
364
- [[client- subscriptions- retrieve]]
359
+ [[client. subscriptions. retrieve]]
365
360
=== Retrieve
366
361
367
362
To start a subscription stream, use `retrieveSubscription` which is similar to
368
- <<client- requests- retrieve,retrieve>> for a single response but returning a stream of
363
+ <<client. requests. retrieve,retrieve>> for a single response but returning a stream of
369
364
responses, each decoded to some data:
370
365
371
366
[source,java,indent=0,subs="verbatim,quotes"]
@@ -389,10 +384,10 @@ the connection and start the subscription again.
389
384
390
385
391
386
392
- [[client- subscriptions- execute]]
387
+ [[client. subscriptions. execute]]
393
388
=== Execute
394
389
395
- <<client- subscriptions- retrieve>> is only a shortcut to decode from a single path in each
390
+ <<client. subscriptions. retrieve>> is only a shortcut to decode from a single path in each
396
391
response map. For more control, use the `executeSubscription` method and handle each
397
392
response directly:
398
393
@@ -422,7 +417,7 @@ response directly:
422
417
423
418
424
419
425
- [[client- interception]]
420
+ [[client. interception]]
426
421
== Interception
427
422
428
423
You create a `GraphQlClientInterceptor` to intercept all requests through a client:
0 commit comments