Interface GraphQlTransport
public interface GraphQlTransport
Contract for executing GraphQL requests over some transport.
- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev
-
Method Summary
Modifier and TypeMethodDescriptionstatic GraphQlResponse
createResponse
(Map<String, Object> responseMap) Factory method to createGraphQlResponse
from a GraphQL response map for use in transport implementations.reactor.core.publisher.Mono<GraphQlResponse>
execute
(GraphQlRequest request) Execute a request with a single response such as a "query" or "mutation".reactor.core.publisher.Flux<GraphQlResponse>
executeSubscription
(GraphQlRequest request) Execute a "subscription" request with a stream of responses.
-
Method Details
-
execute
Execute a request with a single response such as a "query" or "mutation".- Parameters:
request
- the request to execute- Returns:
- a
Mono
with theGraphQlResponse
for the response. TheMono
may end wth an error due to transport or other issues such as failures to encode the request or decode the response.
-
executeSubscription
Execute a "subscription" request with a stream of responses.- Parameters:
request
- the request to execute- Returns:
- a
Flux
ofGraphQlResponse
responses. 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.
-
createResponse
Factory method to createGraphQlResponse
from a GraphQL response map for use in transport implementations.- Parameters:
responseMap
- the GraphQL response map
-