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 Object
The GraphQL websocket controller handling GraphQL requests.
Implementation of https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md
- Since:
- 1.3
- Author:
- Gerard Klijs
-
Constructor Summary
ConstructorsConstructorDescriptionGraphQLWsController
(GraphQLWsMessageHandler messageHandler, io.micronaut.configuration.graphql.ws.GraphQLWsState state, GraphQLJsonSerializer graphQLJsonSerializer) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionorg.reactivestreams.Publisher<GraphQLWsResponse>
onClose
(io.micronaut.websocket.WebSocketSession session, io.micronaut.websocket.CloseReason closeReason) Called when the websocket is closed.org.reactivestreams.Publisher<GraphQLWsResponse>
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>
Called on every message received from the client.void
onOpen
(io.micronaut.websocket.WebSocketSession session, io.micronaut.http.HttpRequest request) Called when the connection is opened.
-
Constructor Details
-
GraphQLWsController
public GraphQLWsController(GraphQLWsMessageHandler messageHandler, io.micronaut.configuration.graphql.ws.GraphQLWsState state, GraphQLJsonSerializer graphQLJsonSerializer) Default constructor.- Parameters:
messageHandler
- theGraphQLWsMessageHandler
instancestate
- theGraphQLWsState
instancegraphQLJsonSerializer
- theGraphQLJsonSerializer
instance
-
-
Method Details
-
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(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, 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
-