Interface ISocketSessionInterceptor
- Namespace
- HotChocolate.AspNetCore
- Assembly
- HotChocolate.AspNetCore.dll
The socket interceptor allows to customize the GraphQL over Websocket behavior.
public interface ISocketSessionInterceptor
Methods
OnCloseAsync(ISocketSession, CancellationToken)
Invoked when the connection is closed.
ValueTask OnCloseAsync(ISocketSession session, CancellationToken cancellationToken = default)
Parameters
session
ISocketSessionThe socket session.
cancellationToken
CancellationTokenThe cancellation token.
Returns
OnCompleteAsync(ISocketSession, string, CancellationToken)
Invoked when the execution of a GraphQL request is completed. This interception method is guaranteed to be invoked even if the operation fails or the connection is closed.
The cancellation token might be cancelled if the connection is closed.
ValueTask OnCompleteAsync(ISocketSession session, string operationSessionId, CancellationToken cancellationToken = default)
Parameters
session
ISocketSessionThe socket session.
operationSessionId
stringThe user-provided unique operation session id.
cancellationToken
CancellationTokenThe cancellation token.
Returns
OnConnectAsync(ISocketSession, IOperationMessagePayload, CancellationToken)
Invoked when the socket connection initialization message is received.
ValueTask<ConnectionStatus> OnConnectAsync(ISocketSession session, IOperationMessagePayload connectionInitMessage, CancellationToken cancellationToken = default)
Parameters
session
ISocketSessionThe socket session.
connectionInitMessage
IOperationMessagePayloadThe connection init message that was received.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- ValueTask<ConnectionStatus>
Returns the connection status that specifies if the socket connection shall be accepted or if it shall be refused.
OnPingAsync(ISocketSession, IOperationMessagePayload, CancellationToken)
Invoked when a ping message is received and allows to produce the payload for the pong message.
ValueTask<IReadOnlyDictionary<string, object?>?> OnPingAsync(ISocketSession session, IOperationMessagePayload pingMessage, CancellationToken cancellationToken = default)
Parameters
session
ISocketSessionThe socket session.
pingMessage
IOperationMessagePayloadThe ping message.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- ValueTask<IReadOnlyDictionary<string, object>>
Returns the Pong-message payload.
OnPongAsync(ISocketSession, IOperationMessagePayload, CancellationToken)
Invoked when a pong message is received.
ValueTask OnPongAsync(ISocketSession session, IOperationMessagePayload pongMessage, CancellationToken cancellationToken = default)
Parameters
session
ISocketSessionThe socket session.
pongMessage
IOperationMessagePayloadThe pong message.
cancellationToken
CancellationTokenThe cancellation token.
Returns
OnRequestAsync(ISocketSession, string, IQueryRequestBuilder, CancellationToken)
Invoked when a GraphQL request is registered with the socket session.
ValueTask OnRequestAsync(ISocketSession session, string operationSessionId, IQueryRequestBuilder requestBuilder, CancellationToken cancellationToken = default)
Parameters
session
ISocketSessionThe socket session.
operationSessionId
stringThe user-provided unique operation session id.
requestBuilder
IQueryRequestBuilderThe GraphQL request builder.
cancellationToken
CancellationTokenThe cancellation token.
Returns
OnResultAsync(ISocketSession, string, IQueryResult, CancellationToken)
Invoked before the result is serialized and send to the client. This interception method allows to amend the result object.
ValueTask<IQueryResult> OnResultAsync(ISocketSession session, string operationSessionId, IQueryResult result, CancellationToken cancellationToken = default)
Parameters
session
ISocketSessionThe socket session.
operationSessionId
stringThe user-provided unique operation session id.
result
IQueryResultThe result produced by executing the GraphQL request.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- ValueTask<IQueryResult>
Returns the result that shall be send to the client.