Skip to content

7.0.0

Compare
Choose a tag to compare
@oliemansm oliemansm released this 15 Nov 20:22
· 812 commits to master since this release

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.