Skip to main content
Version: 6.x.x


To see more details on how to implement subscriptions in your schema, see the schema generator docs on executing subscriptions. This page lists the graphql-kotlin-spring-server specific features.

Flow Support

graphql-kotlin-spring-server provides automatic support for Kotlin Flow by automatically configuring FlowSubscriptionSchemaGeneratorHooks and FlowSubscriptionExecutionStrategy beans.


If you define your subscriptions using Kotlin Flow, make sure to extend FlowSubscriptionSchemaGeneratorHooks whenever you need to provide some custom hooks.

subscriptions-transport-ws subprotocol


subscriptions-transport-ws was deprecated in favor of graphql-ws protocol.

We have implemented subscriptions in Spring WebSockets following the subscriptions-transport-ws subprotocol defined by Apollo. This requires that your client send and parse messages in a specific format.

If you would like to implement your own subscription handler, you can provide a primary spring bean for HandlerMapping that overrides the default one which sets the url for subscriptions to the Apollo subscription handler.

Subscription Hooks

In line with the Apollo protocol, we have implemented hooks to execute functions at different stages of the connection lifecycle. If you would like to implement your own subscription hooks, you can provide a primary spring bean for ApolloSubscriptionHooks that overrides the default one which do not perform any actions.

onConnect / onConnectWithContext

Allows validation of connectionParams prior to starting the connection. You can reject the connection by throwing an exception. If you need to forward state to execution, update and return the GraphQLContext.

onOperation / onOperationWithContext

Called when the client executes a GraphQL operation. The context can not be updated here, it is read only.


Called when client's unsubscribes


Called when the client disconnects


You can see an example implementation of a Subscription in the example app.