Package org.mockserver.mock.action.http
Class GraphQLSubscriptionHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.websocketx.WebSocketFrame>
org.mockserver.mock.action.http.GraphQLSubscriptionHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
public class GraphQLSubscriptionHandler
extends io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.websocketx.WebSocketFrame>
Handles the graphql-transport-ws
protocol over an already-established WebSocket connection.
Installed after the WebSocket handshake when the negotiated subprotocol is
graphql-transport-ws or the legacy graphql-ws.
Protocol messages handled:
connection_init- repliesconnection_ackping- repliespongsubscribe- AST-matches the query against the configured subscription expectation; on match pushes a scripted sequence ofnextmessages thencomplete; on no match sendserrorcomplete(client) - cancels that subscription's pending messages
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCallback interface for sending text frames to the client, with optional delay support.Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
ConstructorsConstructorDescriptionGraphQLSubscriptionHandler(GraphQLBody expectedSubscriptionQuery, List<WebSocketMessage> subscriptionPayloads, GraphQLSubscriptionHandler.FrameSender frameSender, io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker handshaker) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidchannelRead0(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.websocketx.WebSocketFrame frame) voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) static booleanisGraphQLWebSocketProtocol(String subprotocol) Check whether the given subprotocol string indicates a graphql-transport-ws or legacy graphql-ws protocol.Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Constructor Details
-
GraphQLSubscriptionHandler
public GraphQLSubscriptionHandler(GraphQLBody expectedSubscriptionQuery, List<WebSocketMessage> subscriptionPayloads, GraphQLSubscriptionHandler.FrameSender frameSender, io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker handshaker) - Parameters:
expectedSubscriptionQuery- a GraphQLBody describing the subscription query to matchsubscriptionPayloads- the sequence of payloads to push asnextmessagesframeSender- callback for sending text frames with optional delayshandshaker- the WebSocket handshaker for closing the connection
-
-
Method Details
-
channelRead0
protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.websocketx.WebSocketFrame frame) - Specified by:
channelRead0in classio.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.websocketx.WebSocketFrame>
-
exceptionCaught
- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter
-
isGraphQLWebSocketProtocol
Check whether the given subprotocol string indicates a graphql-transport-ws or legacy graphql-ws protocol.
-