Skip to content

6.2.0

Compare
Choose a tag to compare
@oliemansm oliemansm released this 17 Oct 17:44
· 841 commits to master since this release

Breaking change: added HttpServletResponse to GraphQLContextBuilder

The HttpServletResponse was inadvertently removed from GraphQLContext and its related builders. To reinstate it we needed to add the field to multiple builders and the DefaultGraphQLContextBuilder. This allows you to use the HttpServletResponse in your custom GraphQLContextBuilder now which was the purpose of this change.

This means implementations of GraphQLContextBuilder need to add this parameter to their build method:

GraphQLContext build(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse);

Ability to handle Apollo subscription onConnect

The connect of Apollo subscription allows an optional, custom payload to be sent along. This could be used for authentication for example. To allow this the SubscriptionConnectionListener has been introduced. The ApolloSubscriptionConnectionListener provides the onConnect method which is called during the connect process. It can either return an optional custom object to be stored in the Session, or you can have the server return an error by throwing an exception.

Apollo subscription keep alive

The implementation of keep alive for Apollo subscriptions was incorrect. It would only send one keep alive message, while it should be sending repeatedly, because otherwise Apollo client will assume the connection is inactive and reconnect. The default implementation therefore now sends keep alive messages every 15 seconds.

The behavior of this keep alive can be configured by passing a SubscriptionConnectionListener when constructing the GraphQLWebsocketServlet.

GraphQLWebsocketServlet servlet = new GraphQLWebsocketServlet(queryInvoker, invocationInputFactory, graphQLObjectMapper, subscriptionConnectionListener);

Two static factory methods are available for creating SubscriptionConnectionListeners for the most common use cases.

Disabling keep alive entirely

ApolloSubscriptionConnectionListener.createWithKeepAliveDisabled();

Setting a custom interval

Keep in mind when setting the custom interval to use a value below 30 seconds, because otherwise it would defeat the purpose and Apollo will disconnect.

ApolloSubscriptionConnectionListener.createWithKeepAliveInterval(Duration.ofSeconds(20));

Changes in this release

All changes in this release