Class GraphQLWSSubprotocolHandler

java.lang.Object
io.smallrye.graphql.client.vertx.websocket.graphqlws.GraphQLWSSubprotocolHandler
All Implemented Interfaces:
WebSocketSubprotocolHandler

public class GraphQLWSSubprotocolHandler extends Object implements WebSocketSubprotocolHandler
Handler for the legacy `graphql-ws` subprotocol Specification of the protocol: `https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md`
  • Constructor Summary

    Constructors
    Constructor
    Description
    GraphQLWSSubprotocolHandler(io.vertx.core.http.WebSocket webSocket, Integer subscriptionInitializationTimeout, Map<String,Object> initPayload, Runnable onClose)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Cancels an active subscription with the given ID.
    void
    Cancels an active single-result operation with the given ID.
    void
    Called when the websocket should be closed (for example, when the GraphQL client is being closed).
    io.smallrye.mutiny.Uni<Void>
    This is called to initialize the websocket connection and prepare it for executing operations.
    executeMulti(jakarta.json.JsonObject request, io.smallrye.mutiny.subscription.MultiEmitter<? super String> emitter)
    Requests an execution of a subscription operation over the websocket.
    executeUni(jakarta.json.JsonObject request, io.smallrye.mutiny.subscription.UniEmitter<? super String> emitter)
    Requests an execution of a single-result operation over the websocket.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GraphQLWSSubprotocolHandler

      public GraphQLWSSubprotocolHandler(io.vertx.core.http.WebSocket webSocket, Integer subscriptionInitializationTimeout, Map<String,Object> initPayload, Runnable onClose)
  • Method Details

    • ensureInitialized

      public io.smallrye.mutiny.Uni<Void> ensureInitialized()
      Description copied from interface: WebSocketSubprotocolHandler
      This is called to initialize the websocket connection and prepare it for executing operations. The returned Uni is completed when the websocket is fully initialized (including necessary server ACKs specific to the protocol). If the handler is already fully initialized, this returns a completed Uni.
      Specified by:
      ensureInitialized in interface WebSocketSubprotocolHandler
    • executeUni

      public String executeUni(jakarta.json.JsonObject request, io.smallrye.mutiny.subscription.UniEmitter<? super String> emitter)
      Description copied from interface: WebSocketSubprotocolHandler
      Requests an execution of a single-result operation over the websocket.
      Specified by:
      executeUni in interface WebSocketSubprotocolHandler
      Parameters:
      request - Request in full JSON format describing the operation to be executed.
      emitter - Emitter that should receive the completion event (or an error) when the operation finishes.
      Returns:
      The generated internal ID of this operation.
    • executeMulti

      public String executeMulti(jakarta.json.JsonObject request, io.smallrye.mutiny.subscription.MultiEmitter<? super String> emitter)
      Description copied from interface: WebSocketSubprotocolHandler
      Requests an execution of a subscription operation over the websocket.
      Specified by:
      executeMulti in interface WebSocketSubprotocolHandler
      Parameters:
      request - Request in full JSON format describing the operation to be executed.
      emitter - Emitter that should receive the completion events (or an error) from the subscription.
      Returns:
      The generated internal ID of this operation.
    • cancelUni

      public void cancelUni(String id)
      Description copied from interface: WebSocketSubprotocolHandler
      Cancels an active single-result operation with the given ID. This does not do anything with the Emitter for this operation, it only sends a cancellation message to the server (if applicable depending on the protocol), and marks this operation as finished.
      Specified by:
      cancelUni in interface WebSocketSubprotocolHandler
      Parameters:
      id - ID of the operation (returned from calling `executeUni`)
    • cancelMulti

      public void cancelMulti(String id)
      Description copied from interface: WebSocketSubprotocolHandler
      Cancels an active subscription with the given ID. This does not do anything with the Emitter for this operation, it only sends a cancellation message to the server (if applicable depending on the protocol), and marks this operation as finished.
      Specified by:
      cancelMulti in interface WebSocketSubprotocolHandler
      Parameters:
      id - ID of the operation (returned from calling `executeMulti`)
    • close

      public void close()
      Description copied from interface: WebSocketSubprotocolHandler
      Called when the websocket should be closed (for example, when the GraphQL client is being closed).
      Specified by:
      close in interface WebSocketSubprotocolHandler