Skip to content

Releases: graphql-java-kickstart/graphql-java-servlet

7.3.3

04 Mar 08:09
Compare
Choose a tag to compare
  • Allow batch handler to set http status (#156)

7.3.2

01 Mar 12:25
Compare
Choose a tag to compare

Improved batch execution handling

7.1.1

24 Nov 11:27
Compare
Choose a tag to compare

Enhancements

Added null checks to GraphQLConfiguration and some minor refactorings to make it a bit easier to use.

7.1.0

20 Nov 19:12
Compare
Choose a tag to compare

Feature

Method for requesting number of subscriptions.

7.0.1

20 Nov 18:45
Compare
Choose a tag to compare

Bugfix

The new GraphQLConfiguration didn't allow you to configure a custom GraphQLContextBuilder or GraphQLRootObjectBuilder. That has been fixed in this small bugfix release.

7.0.0

15 Nov 20:22
Compare
Choose a tag to compare

Updated graphql-java dependency to 11.0

Graphql-Java has been updated to 11.0, which contains breaking changes. See the release notes.

Simplified construction of GraphQL Servlet

The process for constructing a GraphQL Servlet has been simplified. If you just want to use all default settings and want to expose a schema you can simply create the servlet calling GraphQLHttpServlet.with(graphqlSchema).

If you need more control you can use GraphQLHttpServlet.with(graphqlConfiguration). The GraphQLConfiguration can be built in line with how the Builder worked before.

The third option is by subclassing the GraphQLHttpServlet:

@WebServlet(name = "HelloServlet", urlPatterns = {"graphql"}, loadOnStartup = 1)
public class HelloServlet extends GraphQLHttpServlet {

  @Override
  protected GraphQLConfiguration getConfiguration() {
    return GraphQLConfiguration.with(createSchema()).build();
  }

  private GraphQLSchema createSchema() {
    String schema = "type Query{hello: String}";

    SchemaParser schemaParser = new SchemaParser();
    TypeDefinitionRegistry typeDefinitionRegistry = schemaParser.parse(schema);

    RuntimeWiring runtimeWiring = newRuntimeWiring()
        .type("Query", builder -> builder.dataFetcher("hello", new StaticDataFetcher("world")))
        .build();

    SchemaGenerator schemaGenerator = new SchemaGenerator();
    return schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);
  }

}

Improved naming for getting files from GraphQLContext

The method GraphQLContext.getFiles() incorrectly gave the impression it would only return Part representing actual files, while it included other form fields as well. Therefore deprecated this method and added two alternatives:

/**
 * @return list of all parts representing files
 */
public List<Part> getFileParts();

/**
 * @return map representing all form fields
 */
public Map<String, List<Part>> getParts()

Fixed Karaf example

The Karaf example hadn't been updated in a while and therefore wouldn't run anymore. All dependencies have been updated now to work with the latest versions.

Improve schema OSGi whiteboard update performance by batching

Allow the ability to delay the update of the schema through a config option. By default this is 0, leaving the behaviour unchanged, and no penalty is paid. If the delay is set to a non zero value, it only updates the schema if no
changes to the whiteboard have happened within that delay timeout.

Also fixed up a couple of things with the whiteboard. Using policy=DYNAMIC is the normal approach, the component can activate and gets references added as appropriate. The "typesProviders" method was in error as the name didn't match the unbind. I believe that what was happening before is that the component was being activated
and deactivated each time a new reference was added. Now it's activated once and the whiteboard works correctly.

It has been advised by the contributor @tomq42 to set the default delay to 150ms. This will give improved behaviour for most people. The default has been left though as 0 so that the current behaviour is maintained, and there is no impact of this change at all otherwise.

6.2.0

17 Oct 17:44
Compare
Choose a tag to compare

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

6.1.4

05 Oct 06:35
Compare
Choose a tag to compare

Updated Maven coordinates in Central

The artifacts are available in Maven Central starting with this version.