Skip to content

Spring for GraphQL 1.2

Rossen Stoyanchev edited this page May 17, 2023 · 4 revisions

What’s New in Spring for GraphQL 1.2

New Features

Pagination and Sorting

First-class support for pagination, seamlessly adapting Spring Data pagination to the GraphQL Cursor Connection specification, including support for the latest Scroll API, new in Spring Data 2023.01. To learn more, start with the section on Pagination in the reference documentation, and follow links to other sections.

Querydsl and QBE Pagination

The Querydsl and Query by Example built-in data fetchers now support pagination. The Data Integration section of the reference documentation has been updated accordingly.

Schema Mapping Checks on Startup

You can enable inspection of GraphQL schema mappings on startup to detect schema fields with neither a DataFetcher nor a corresponding Java object property, and likewise to detect controller methods and DataFetcher registrations to non-existing fields. See the section on Schema Mappings Inpsection in the reference documentation.

Annotated Exception Handling

You can now handle exceptions from @SchemaMapping controller methods via @GraphQlExceptionHandler annotated handler methods declared and apply either locally in the controller, or in a @ControllerAdvice. For more, see the section on @GraphQlExceptionHandler in the reference documentation.

Single Argument Input Types with Querydsl and QBE

For requests with a single argument that is a GraphQL input type, you can now use an example object that is the direct equivalent of the GraphQL input type, and does not need an artificial wrapper around it. See issue #216.

Custom Argument Resolvers

You can now configure a custom HandlerMethodArgumentResolver on AnnotatedControllerConfigurer.

Argument Binding via Direct Fields

You can now configure @ArgumentBinding to fall back on direct field access through an option on AnnotatedControllerConfigurer.

Validation with Groups

Validation via @Validated on method parameter is now supported as an alternative to @Valid if you need to specify validation groups for a specific parameter. Alternatively, @Validated can also be declared on the method or on the class level.

Upgrade and Migration Notes

@Argument Map<String, Object> no longer returns the full arguments map, and instead now always returns the raw argument value, matching either to the name specified in the annotation, or to the parameter name. For access to the full arguments map, please use @Arguments Map<String, Object> or DataFetchingEnvironment#getArguments.