Package-level declarations

Types

Link copied to clipboard
abstract class GraphQLCoroutine(val channel: Channel<OperationMessage<*>>)

Base class for child coroutines of the GraphQLWebSocketConsumer. Allows for sending messages back to the main coroutine channel for doing things like sending messages back to the WebSocket client

Link copied to clipboard
open class GraphQLWebSocketAdapter(val subProtocol: GraphQLWebSocketSubProtocol, val channel: Channel<OperationMessage<*>>, val objectMapper: ObjectMapper, dispatcher: CoroutineDispatcher = Dispatchers.IO) : WebSocketAdapter, CoroutineScope

WebSocketAdapter implementation that bridges incoming WebSocket events into a coroutine Channel to be handled by a consumer, and provides access to the remote for sending messages to the client.

Link copied to clipboard

Enum of websocket closure reasons from the graphql-ws protocol specification

Link copied to clipboard
class GraphQLWebSocketConsumer(val graphQL: GraphQL, val graphQLConfig: GraphQLConfig, val upgradeContainerRequestContext: ContainerRequestContext, val channel: Channel<OperationMessage<*>>, val adapter: GraphQLWebSocketAdapter, val keepAliveDispatcher: CoroutineDispatcher = Dispatchers.Default, val dataLoaderRegistryFactory: KotlinDataLoaderRegistryFactory? = null, val graphQLWebSocketAuthenticator: GraphQLWebSocketAuthenticator? = null)

Coroutine based consumer that listens for events on coming from the WebSocket managed by a GraphQLWebSocketAdapter, and implements the apollo graphql-ws protocol from https://github.com/apollographql/subscriptions-transport-ws/blob/HEAD/PROTOCOL.md

Link copied to clipboard
class GraphQLWebSocketCreator(val graphQL: GraphQL, val objectMapper: ObjectMapper, val graphQLConfig: GraphQLConfig, val dataLoaderRegistryFactory: KotlinDataLoaderRegistryFactory? = null, val graphQLWebSocketAuthenticator: GraphQLWebSocketAuthenticator? = null, val dispatcher: CoroutineDispatcher) : WebSocketCreator

WebSocketCreator that creates a GraphQLWebSocketAdapter, a Channel that gets sent WebSocket API events, and a GraphQLWebSocketConsumer to consume that channel.

Link copied to clipboard
class GraphQLWebSocketDropwizardAuthenticator @Inject constructor(@Nullable val authFilter: AuthFilter<*, *>?) : Function1<@JvmSuppressWildcards ContainerRequestContext, @JvmSuppressWildcards Principal?>

A GraphQLWebSocketAuthenticator that delegates authentication to a Dropwizard AuthFilter from the Guice injector.

Link copied to clipboard
enum GraphQLWebSocketSubProtocol(val subProtocol: String, messageMapping: Map<OperationType<*>, OperationType<*>>, val onInvalidMessageCallback: (String?, String, GraphQLWebSocketAdapter) -> Unit, val onDuplicateQueryCallback: (OperationMessage<*>, GraphQLWebSocketAdapter) -> Unit, val onDuplicateInitCallback: (OperationMessage<*>, GraphQLWebSocketAdapter) -> Unit) : Enum<GraphQLWebSocketSubProtocol>

Encapsulates the different behaviors in the apollo vs/ graphql-ws protocols. Maps equivalent messages (eg "start" vs "subscribe"), and provides callbacks for different behaviors (eg end an "error" message vs/ close the connection).

Link copied to clipboard
class KeepAliveCoroutine(val graphQLConfig: GraphQLConfig, val channel: Channel<OperationMessage<*>>, val message: OperationMessage<*>) : GraphQLCoroutine

Coroutine that sends a keepalive ping over the websocket every GraphQLConfig.keepAliveIntervalSeconds seconds until it gets canceled by its parent

Link copied to clipboard
data class OperationMessage<T : Any>(val type: OperationType<T>?, val id: String?, val payload: T? = null)

Model for a message in the graphql websocket protocol. Supports messages for either the apollo or graphql-ws protocols

Link copied to clipboard
data class OperationType<T : Any>(val type: String, val payloadType: KClass<T>)

Captures the mapping from operation type to payload type for the messages in the protocol

Link copied to clipboard
class QueryCoroutine(val graphQL: GraphQL, val channel: Channel<OperationMessage<*>>, val messageId: String, val executionQuery: ExecutionInput) : GraphQLCoroutine

Coroutine that runs a GraphQL query and emits data messages to be sent back to the WebSocket client. On completion of the query will send a GQL_COMPLETE message back. On any error will send a GQL_ERROR.

Properties

Link copied to clipboard
private val log: KLogger
private val log: KLogger

Functions

Link copied to clipboard
fun Session.close(reason: GraphQLWebSocketCloseReason)

Extension method to close the WebSocket session using a GraphQLWebSocketCloseReason instead of code/description pairs