To see more details of how to implement subscriptions in your schema, see executing subscriptions.
We have implemented subscriptions in Spring WebSockets following the
graphql-ws subprotocol defined by Apollo. This requires that your client send and parse messages in a specific format.
You can see more details in the file ApolloSubscriptionProtocolHandler.
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.
In line with the protocol, we have implemented hooks to execute functions at different stages of the connection lifecycle:
You can see more details in the file ApolloSubscriptionHooks.
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.
You can see an example implementation of a
Subscription in the example app.