Class GraphQLWsController
- java.lang.Object
-
- io.micronaut.configuration.graphql.ws.GraphQLWsController
-
@ServerWebSocket(value="${graphql.graphql-ws.path:/graphql-ws}", subprotocols="graphql-ws") @Requires(property="graphql.graphql-ws.enabled", value="true", defaultValue="false") public class GraphQLWsController extends java.lang.ObjectThe GraphQL websocket controller handling GraphQL requests. Implementation of https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md- Since:
- 1.3
-
-
Constructor Summary
Constructors Constructor Description GraphQLWsController(GraphQLWsMessageHandler messageHandler, io.micronaut.configuration.graphql.ws.GraphQLWsState state, GraphQLJsonSerializer graphQLJsonSerializer)Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.reactivestreams.Publisher<GraphQLWsResponse>onClose(io.micronaut.websocket.WebSocketSession session, io.micronaut.websocket.CloseReason closeReason)Called when the websocket is closed.org.reactivestreams.Publisher<GraphQLWsResponse>onError(io.micronaut.websocket.WebSocketSession session, java.lang.Throwable t)Called when there is an error with the websocket, this probably means the connection is lost, but hasn't been properly closed.org.reactivestreams.Publisher<GraphQLWsResponse>onMessage(java.lang.String message, io.micronaut.websocket.WebSocketSession session)Called on every message received from the client.voidonOpen(io.micronaut.websocket.WebSocketSession session, io.micronaut.http.HttpRequest request)Called when the connection is opened.
-
-
-
Constructor Detail
-
GraphQLWsController
public GraphQLWsController(GraphQLWsMessageHandler messageHandler, io.micronaut.configuration.graphql.ws.GraphQLWsState state, GraphQLJsonSerializer graphQLJsonSerializer)
Default constructor.- Parameters:
messageHandler- theGraphQLWsMessageHandlerinstancestate- theGraphQLWsStateinstancegraphQLJsonSerializer- theGraphQLJsonSerializerinstance
-
-
Method Detail
-
onOpen
@OnOpen public void onOpen(io.micronaut.websocket.WebSocketSession session, io.micronaut.http.HttpRequest request)Called when the connection is opened. We store the original request, since it might be needed for the GraphQLInvocation.- Parameters:
session- WebSocketSessionrequest- HttpRequest
-
onMessage
@OnMessage public org.reactivestreams.Publisher<GraphQLWsResponse> onMessage(java.lang.String message, io.micronaut.websocket.WebSocketSession session)
Called on every message received from the client.- Parameters:
message- Message received from a clientsession- WebSocketSession- Returns:
- Publisher
-
onClose
@OnClose public org.reactivestreams.Publisher<GraphQLWsResponse> onClose(io.micronaut.websocket.WebSocketSession session, io.micronaut.websocket.CloseReason closeReason)
Called when the websocket is closed.- Parameters:
session- WebSocketSessioncloseReason- CloseReason- Returns:
- Publisher
-
onError
@OnError public org.reactivestreams.Publisher<GraphQLWsResponse> onError(io.micronaut.websocket.WebSocketSession session, java.lang.Throwable t)
Called when there is an error with the websocket, this probably means the connection is lost, but hasn't been properly closed.- Parameters:
session- WebSocketSessiont- Throwable, the cause of the error- Returns:
- Publisher
-
-