Class 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.Object
    The GraphQL websocket controller handling GraphQL requests. Implementation of https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md
    Since:
    1.3
    • 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.
      void onOpen​(io.micronaut.websocket.WebSocketSession session, io.micronaut.http.HttpRequest request)
      Called when the connection is opened.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 - WebSocketSession
        request - 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 client
        session - 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 - WebSocketSession
        closeReason - 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 - WebSocketSession
        t - Throwable, the cause of the error
        Returns:
        Publisher