Skip to main content
Version: 3.x.x

Subscriptions

Schema#

To see more details of how to implement subscriptions in your schema, see executing subscriptions.

graphql-ws subprotocol#

Overview#

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.

Subscription Hooks#

In line with the protocol, we have implemented hooks to execute functions at different stages of the connection lifecycle:

  • onConnect
  • onOperation
  • onOperationComplete
  • onDisconnect

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.

Example#

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

Last updated on by jgorman-exp