Class GraphQlWebSocketHandler

  • All Implemented Interfaces:
    org.springframework.web.socket.SubProtocolCapable, org.springframework.web.socket.WebSocketHandler

    public class GraphQlWebSocketHandler
    extends org.springframework.web.socket.handler.TextWebSocketHandler
    implements org.springframework.web.socket.SubProtocolCapable
    WebSocketHandler for GraphQL based on GraphQL Over WebSocket Protocol and for use on a Servlet container with spring-websocket.
    Since:
    1.0.0
    Author:
    Rossen Stoyanchev
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int BUFFER_SIZE_LIMIT
      Size of the buffer (number of bytes), where subscription messages are stored, if they can't be stored immediately
      static int SEND_TIME_LIMIT
      Maximum allowed duration (milliseconds) to send a message for a subscription, when the web socket is busy
    • Constructor Summary

      Constructors 
      Constructor Description
      GraphQlWebSocketHandler​(graphql.schema.GraphQLSchema graphQLSchema)
      Create a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void afterConnectionClosed​(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.CloseStatus closeStatus)  
      void afterConnectionEstablished​(org.springframework.web.socket.WebSocketSession session)  
      java.util.List<java.lang.String> getSubProtocols()  
      protected void handleTextMessage​(org.springframework.web.socket.WebSocketSession sessionParam, org.springframework.web.socket.TextMessage message)  
      void handleTransportError​(org.springframework.web.socket.WebSocketSession session, java.lang.Throwable exception)  
      boolean supportsPartialMessages()  
      • Methods inherited from class org.springframework.web.socket.handler.TextWebSocketHandler

        handleBinaryMessage
      • Methods inherited from class org.springframework.web.socket.handler.AbstractWebSocketHandler

        handleMessage, handlePongMessage
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SEND_TIME_LIMIT

        public static final int SEND_TIME_LIMIT
        Maximum allowed duration (milliseconds) to send a message for a subscription, when the web socket is busy
        See Also:
        ConcurrentWebSocketSessionDecorator(WebSocketSession, int, int, org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator.OverflowStrategy), Constant Field Values
      • BUFFER_SIZE_LIMIT

        public static final int BUFFER_SIZE_LIMIT
        Size of the buffer (number of bytes), where subscription messages are stored, if they can't be stored immediately
        See Also:
        ConcurrentWebSocketSessionDecorator, Constant Field Values
    • Constructor Detail

      • GraphQlWebSocketHandler

        public GraphQlWebSocketHandler​(graphql.schema.GraphQLSchema graphQLSchema)
        Create a new instance.
    • Method Detail

      • getSubProtocols

        public java.util.List<java.lang.String> getSubProtocols()
        Specified by:
        getSubProtocols in interface org.springframework.web.socket.SubProtocolCapable
      • afterConnectionEstablished

        public void afterConnectionEstablished​(org.springframework.web.socket.WebSocketSession session)
        Specified by:
        afterConnectionEstablished in interface org.springframework.web.socket.WebSocketHandler
        Overrides:
        afterConnectionEstablished in class org.springframework.web.socket.handler.AbstractWebSocketHandler
      • handleTextMessage

        protected void handleTextMessage​(org.springframework.web.socket.WebSocketSession sessionParam,
                                         org.springframework.web.socket.TextMessage message)
                                  throws java.lang.Exception
        Overrides:
        handleTextMessage in class org.springframework.web.socket.handler.AbstractWebSocketHandler
        Throws:
        java.lang.Exception
      • handleTransportError

        public void handleTransportError​(org.springframework.web.socket.WebSocketSession session,
                                         java.lang.Throwable exception)
        Specified by:
        handleTransportError in interface org.springframework.web.socket.WebSocketHandler
        Overrides:
        handleTransportError in class org.springframework.web.socket.handler.AbstractWebSocketHandler
      • afterConnectionClosed

        public void afterConnectionClosed​(org.springframework.web.socket.WebSocketSession session,
                                          org.springframework.web.socket.CloseStatus closeStatus)
        Specified by:
        afterConnectionClosed in interface org.springframework.web.socket.WebSocketHandler
        Overrides:
        afterConnectionClosed in class org.springframework.web.socket.handler.AbstractWebSocketHandler
      • supportsPartialMessages

        public boolean supportsPartialMessages()
        Specified by:
        supportsPartialMessages in interface org.springframework.web.socket.WebSocketHandler
        Overrides:
        supportsPartialMessages in class org.springframework.web.socket.handler.AbstractWebSocketHandler