Class GraphQlRSocketHandler
java.lang.Object
org.springframework.graphql.server.GraphQlRSocketHandler
Handler for GraphQL over RSocket requests.
This class can be extended or wrapped from an @Controller in order
to re-declare handle(Map) and handleSubscription(Map) with
@MessageMapping
annotations including the GraphQL endpoint route.
@Controller
private static class GraphQlRSocketController {
private final GraphQlRSocketHandler handler;
GraphQlRSocketController(GraphQlRSocketHandler handler) {
this.handler = handler;
}
@MessageMapping("graphql")
public Mono<Map<String, Object>> handle(Map<String, Object> payload) {
return this.handler.handle(payload);
}
@MessageMapping("graphql")
public Flux<Map<String, Object>> handleSubscription(Map<String, Object> payload) {
return this.handler.handleSubscription(payload);
}
}
- Since:
- 1.0.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
ConstructorsConstructorDescriptionGraphQlRSocketHandler(ExecutionGraphQlService graphQlService, List<RSocketGraphQlInterceptor> interceptors, Encoder<?> jsonEncoder) Create a new instance that handles requests through a chain of interceptors followed by the givenExecutionGraphQlService. -
Method Summary
-
Constructor Details
-
GraphQlRSocketHandler
public GraphQlRSocketHandler(ExecutionGraphQlService graphQlService, List<RSocketGraphQlInterceptor> interceptors, Encoder<?> jsonEncoder) Create a new instance that handles requests through a chain of interceptors followed by the givenExecutionGraphQlService.- Parameters:
graphQlService- the service that will execute the requestinterceptors- interceptors to form the processing chainjsonEncoder- a JSON encoder for serializing aGraphQLErrorlist for a failed subscription
-
-
Method Details
-
handle
Handle aRequest-Responseinteraction. For queries and mutations.- Parameters:
payload- the decoded GraphQL request payload
-
handleSubscription
public reactor.core.publisher.Flux<Map<String,Object>> handleSubscription(Map<String, Object> payload) Handle aRequest-Streaminteraction. For subscriptions.- Parameters:
payload- the decoded GraphQL request payload
-