Skip to content

Spring for GraphQL 1.1

Brian Clozel edited this page Nov 25, 2022 · 5 revisions

What’s New in Spring for GraphQL 1.1

JDK 17+ and Jakarta EE 9+ Baseline

  • The framework codebase is on Java 17 source code level.

  • Migrated from javax to jakarta namespace for Servlet 5+, HTTP and WebSocket handlers, Validation 3.0, and JPA 3.0; see also Spring Boot 3.0 release notes

  • GraphQL Java 19

  • Spring Data 2022.0.0, for using QueryDSL or Query by Example

  • Supported by starter in Spring Boot 3.0+

New Features

Argument binding

Several improvements for cases with input binding via @Argument method parameters, see #516, #447, #449, and #394.

Support for an ArgumentValue wrapper around an @Argument, or around a nested field of an @Argument annotated method parameter, as a means of checking whether an input value was provided but set to null or omitted from the input altogether;

Observability

The metrics instrumentation in Spring Boot 2.7.x has been removed in favor of direct instrumentation in Spring for GraphQL with the new Micrometer Observation API. The new GraphQlObservationInstrumentation can be configured on the GraphQlSource builder in your application (this is auto-configured for you in Spring Boot).

This instrumentation publishes a observation named "graphql.request" for the entire request and "graphql.datafetcher" observations for each non-trivial data fetching operation happening within the request.

Spring for GraphQL now uses the Micrometer context propagation library to propagate contextual information from the transport layer to controllers in the data fetching layer. This includes propagation of ThreadLocal values with a Spring MVC transport, and Reactor context with a WebFlux transport.

AOT and GraalVM Native

You can now compile your application to a native binary thanks to GraalVM. We are now applying a SchemaMappingBeanFactoryInitializationAotProcessor during the AOT phase that detects all the relevant types in your Controller method signatures and register them with GraalVM for reflection or proxying, when needed. You can learn more about the native image setup in the Spring Boot docs and also about the known limitations.

Other improvements

@BatchMapping exposes a maxBatchSize that’s set on the DataLoaderOptions for the underlying DataLoader.

Support for configuring global DataLoaderOptions as a starting point for all batch loader registrations via DefaultBatchLoaderRegistry constructor argument.

Upgrade and Migration Notes

The ThreadLocalAccessor contract from 1.0 is no longer supported. The Micrometer context-propagation library provides an equivalent contract that needs to be implemented instead, see #459.