Interface GraphQlClient.RequestSpec
- Enclosing interface:
- GraphQlClient
public static interface GraphQlClient.RequestSpec
Declare options to gather input for a GraphQL request and execute it.
-
Method Summary
Modifier and TypeMethodDescriptionSet a client request attribute.attributes
(Consumer<Map<String, Object>> attributesConsumer) Manipulate the client request attributes.reactor.core.publisher.Mono<ClientGraphQlResponse>
execute()
Execute request with a single response, e.g.reactor.core.publisher.Flux<ClientGraphQlResponse>
Execute a "subscription" request and return a stream of responses.Execute request with a single response, e.g.Add a value for a protocol extension.extensions
(Map<String, Object> extensions) Add all given protocol extensions.operationName
(String operationName) Set the name of the operation in thedocument
to execute, if the document contains multiple operations.Shortcut forexecute()
with a field path to decode from.retrieveSubscription
(String path) Shortcut forexecuteSubscription()
with a field path to decode from for each result.retrieveSync
(String path) Shortcut forexecuteSync()
with a field path to decode from.Add a value for a variable defined by the operation.Add all given values for variables defined by the operation.
-
Method Details
-
operationName
Set the name of the operation in thedocument
to execute, if the document contains multiple operations.- Parameters:
operationName
- the operation name- Returns:
- this request spec
-
variable
Add a value for a variable defined by the operation.- Parameters:
name
- the variable namevalue
- the variable value- Returns:
- this request spec
-
variables
Add all given values for variables defined by the operation.- Parameters:
variables
- the variable values- Returns:
- this request spec
-
extension
Add a value for a protocol extension.- Parameters:
name
- the protocol extension namevalue
- the extension value- Returns:
- this request spec
-
extensions
Add all given protocol extensions.- Parameters:
extensions
- the protocol extensions- Returns:
- this request spec
-
attribute
Set a client request attribute.This is purely for client side request processing, i.e. available throughout the
GraphQlClientInterceptor
chain but not sent.- Parameters:
name
- the name of the attributevalue
- the attribute value- Returns:
- this builder
-
attributes
Manipulate the client request attributes. The map provided to the consumer is "live", so the consumer can inspect and modify attributes accordingly.- Parameters:
attributesConsumer
- consumer to customize attributes with- Returns:
- this builder
-
retrieveSync
Shortcut forexecuteSync()
with a field path to decode from.If you want to decode the full data instead, use:
client.document("..").executeSync()
- Parameters:
path
- the field path- Returns:
- a spec with decoding options
- Throws:
FieldAccessException
- if the field has any field errors, including errors at, above or below the field path.- Since:
- 1.3.0
-
retrieve
Shortcut forexecute()
with a field path to decode from.If you want to decode the full data instead, use:
client.document("..").execute().map(response -> ...)
- Parameters:
path
- the field path- Returns:
- a spec with decoding options
- Throws:
FieldAccessException
- if the field has any field errors, including errors at, above or below the field path.
-
retrieveSubscription
Shortcut forexecuteSubscription()
with a field path to decode from for each result.If you want to decode the full data, use:
client.document("..").executeSubscription().map(response -> ...)
- Parameters:
path
- the field path- Returns:
- a spec with decoding options
-
executeSync
ClientGraphQlResponse executeSync()Execute request with a single response, e.g. "query" or "mutation", and return a response for further options.- Returns:
- a
ClientGraphQlResponse
for further decoding of the response. - Throws:
GraphQlTransportException
- in case of errors due to transport or other issues related to encoding and decoding the request and response.- Since:
- 1.3.0
-
execute
reactor.core.publisher.Mono<ClientGraphQlResponse> execute()Execute request with a single response, e.g. "query" or "mutation", and return a response for further options.- Returns:
- a
Mono
with aClientGraphQlResponse
for further decoding of the response. TheMono
may end with an error due to transport level issues.
-
executeSubscription
reactor.core.publisher.Flux<ClientGraphQlResponse> executeSubscription()Execute a "subscription" request and return a stream of responses.- Returns:
- a
Flux
with responses that provide further options for decoding of each response. TheFlux
may terminate as follows:- Completes if the subscription completes before the connection is closed.
SubscriptionErrorException
if the subscription ends with an error.WebSocketDisconnectedException
if the connection is closed or lost before the stream terminates.- Exception for connection and GraphQL session initialization issues.
The
Flux
may be cancelled to notify the server to end the subscription stream.
-