Interface WebSocketGraphQlInterceptor
- All Superinterfaces:
WebGraphQlInterceptor
- All Known Implementing Classes:
AbstractAuthenticationWebSocketInterceptor
,AuthenticationWebSocketInterceptor
,AuthenticationWebSocketInterceptor
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.graphql.server.WebGraphQlInterceptor
WebGraphQlInterceptor.Chain
-
Method Summary
Modifier and TypeMethodDescriptiondefault reactor.core.publisher.Mono<Void>
handleCancelledSubscription
(WebSocketSessionInfo sessionInfo, String subscriptionId) Handle the"complete"
message that a client sends to stop a subscription stream.default void
handleConnectionClosed
(WebSocketSessionInfo sessionInfo, int statusCode, Map<String, Object> connectionInitPayload) Invoked when the WebSocket session is closed, from either side.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.default reactor.core.publisher.Mono<WebGraphQlResponse>
intercept
(WebGraphQlRequest request, WebGraphQlInterceptor.Chain chain) Intercept a request and delegate to the rest of the chain including other interceptors and aExecutionGraphQlService
.Methods inherited from interface org.springframework.graphql.server.WebGraphQlInterceptor
andThen, apply
-
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 aExecutionGraphQlService
.- Specified by:
intercept
in interfaceWebGraphQlInterceptor
- Parameters:
request
- the request which may be aWebSocketGraphQlRequest
when intercepting a GraphQL request over WebSocketchain
- 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 sessionconnectionInitPayload
- 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 underlyingPublisher
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 sessionsubscriptionId
- the unique id for the subscription; correlates to therequestId
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 sessionstatusCode
- the WebSocket "close" status codeconnectionInitPayload
- the payload from the"connect_init"
message received at the start of the connection
-