Interface WebSocketGraphQlInterceptor

All Superinterfaces:
WebGraphQlInterceptor
All Known Implementing Classes:
AbstractAuthenticationWebSocketInterceptor, AuthenticationWebSocketInterceptor, AuthenticationWebSocketInterceptor

public interface WebSocketGraphQlInterceptor extends WebGraphQlInterceptor
An extension of WebGraphQlInterceptor with additional methods to handle the start and end of a WebSocket connection, as well as client-side cancellation of subscriptions.

Use WebGraphQlHandler.Builder.interceptor(WebGraphQlInterceptor...) to configure the interceptor chain. Only one interceptor in the chain may be of type WebSocketGraphQlInterceptor.

Since:
1.0.0
Author:
Rossen Stoyanchev
  • Method Details

    • intercept

      default reactor.core.publisher.Mono<WebGraphQlResponse> intercept(WebGraphQlRequest request, WebGraphQlInterceptor.Chain chain)
      Description copied from interface: WebGraphQlInterceptor
      Intercept a request and delegate to the rest of the chain including other interceptors and a ExecutionGraphQlService.
      Specified by:
      intercept in interface WebGraphQlInterceptor
      Parameters:
      request - the request which may be a WebSocketGraphQlRequest when intercepting a GraphQL request over WebSocket
      chain - the rest of the chain to execute the request
      Returns:
      a Mono with the response
    • handleConnectionInitialization

      default reactor.core.publisher.Mono<Object> handleConnectionInitialization(WebSocketSessionInfo sessionInfo, Map<String,Object> connectionInitPayload)
      Handle the "connection_init" message at the start of a GraphQL over WebSocket session and return an optional payload for the "connection_ack" message to send back.
      Parameters:
      sessionInfo - information about the underlying WebSocket session
      connectionInitPayload - the payload from the "connection_init" message
      Returns:
      the payload for the "connection_ack", or empty
    • handleCancelledSubscription

      default reactor.core.publisher.Mono<Void> handleCancelledSubscription(WebSocketSessionInfo sessionInfo, String subscriptionId)
      Handle the "complete" message that a client sends to stop a subscription stream. The underlying Publisher for the subscription is automatically cancelled. This callback is for any additional, or more centralized handling across subscriptions.
      Parameters:
      sessionInfo - information about the underlying WebSocket session
      subscriptionId - the unique id for the subscription; correlates to the requestId from the "subscribe" message that started the subscription stream
      Returns:
      Mono for the completion of handling
    • handleConnectionClosed

      default void handleConnectionClosed(WebSocketSessionInfo sessionInfo, int statusCode, Map<String,Object> connectionInitPayload)
      Invoked when the WebSocket session is closed, from either side.
      Parameters:
      sessionInfo - information about the underlying WebSocket session
      statusCode - the WebSocket "close" status code
      connectionInitPayload - the payload from the "connect_init" message received at the start of the connection