Class GraphQLReactiveWebSocketHandler<R,T>
java.lang.Object
com.graphql_java_generator.client.GraphQLReactiveWebSocketHandler<R,T>
- Type Parameters:
R- The class that is generated from the subscription definition in the GraphQL schema. It contains one attribute, for each available subscription. In the incoming messages, the data JSON field of the GraphQL server response is of this type. So it is needed to decode the received JSON.T- The type that must be returned by the query or mutation: it's the class that maps to the GraphQL type returned by this subscription. In other words, it's the java type that matches the field in the subscription GraphQL type, for this subscribed subscription.
- All Implemented Interfaces:
org.springframework.web.reactive.socket.WebSocketHandler
public class GraphQLReactiveWebSocketHandler<R,T>
extends java.lang.Object
implements org.springframework.web.reactive.socket.WebSocketHandler
This class implements the Web Socket, as needed by the Spring Web Socket implementation.
- Author:
- etienne-sf
-
Constructor Summary
Constructors Constructor Description GraphQLReactiveWebSocketHandler(java.lang.String request, java.lang.String subscriptionName, SubscriptionCallback<T> subscriptionCallback, java.lang.Class<R> subscriptionType, java.lang.Class<T> messsageType, GraphQLObjectMapper objectMapper) -
Method Summary
Modifier and Type Method Description org.springframework.web.reactive.socket.WebSocketSessiongetSession()reactor.core.publisher.Mono<java.lang.Void>handle(org.springframework.web.reactive.socket.WebSocketSession session)voidonComplete()voidonError(java.lang.Throwable t)voidonNext(org.springframework.web.reactive.socket.WebSocketMessage message)The callback that will receive the messages from the web socket.voidonSubscribe(org.reactivestreams.Subscription s)
-
Constructor Details
-
GraphQLReactiveWebSocketHandler
public GraphQLReactiveWebSocketHandler(java.lang.String request, java.lang.String subscriptionName, SubscriptionCallback<T> subscriptionCallback, java.lang.Class<R> subscriptionType, java.lang.Class<T> messsageType, GraphQLObjectMapper objectMapper)
-
-
Method Details
-
handle
public reactor.core.publisher.Mono<java.lang.Void> handle(org.springframework.web.reactive.socket.WebSocketSession session)- Specified by:
handlein interfaceorg.springframework.web.reactive.socket.WebSocketHandler
-
getSession
public org.springframework.web.reactive.socket.WebSocketSession getSession() -
onNext
public void onNext(org.springframework.web.reactive.socket.WebSocketMessage message)The callback that will receive the messages from the web socket. It will map these JSON messages to the relevant java class, and call the application callback with this java objects- Parameters:
message- The received JSON message
-
onError
public void onError(java.lang.Throwable t) -
onComplete
public void onComplete() -
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription s)
-