-
Notifications
You must be signed in to change notification settings - Fork 305
Spring for GraphQL 1.3
On Java 21+, when AnnotatedControllerConfigurer
is configured with an Executor
, e.g. when the Spring Boot property spring.threads.virtual.enabled
is set, controller methods with a blocking method signature are invoked asynchronously. Method are considered blocking if they do not return Flux
, Mono
or CompletableFuture
, and are not a Kotlin suspending function. You can configure a blocking controller method Predicate
on AnnotatedControllerConfigurer
.
GraphQlClient
provides a common workflow for GraphQL requests over any transport including HTTP, WebSocket, and RSocket. You can now use it on a blocking stack over the synchronous RestClient, and with a synchronous API. See the reference docs for details.
DgsGraphQlClient
is a thin wrapper around any GraphQlClient
that is designed to work with a DGS generated client API. See the reference docs for details. In addition Spring Initializer supports creating Spring GraphQL projects with DGS codegen enabled.
There is now support for GraphQL subscriptions over SSE with Spring MVC and WebFlux based on the GraphQL over SSE spec. See the reference docs for details. On the client side, HttpGraphQlClient
supports GraphQL subscriptions over SSE via WebClient
.
There is now built-in support for federation. The FederationSchemaFactory
assists with configuration and detects @EntityMapping
controller methods to load federated entity types. For details see the reference docs and the updated federation-jvm-spring-example.
There is now support for mapping schema interface fields by making repeated registrations for the same field once for every implementing object type transparently unless any already exist. This works for both @SchemaMapping and for @BatchMapping methods.
Schema inspection supports interfaces and unions, which may work transparently, depending on the exact naming convention, by discovering Java types that correspond to interface implementing and union member types. If necessary, there are options to customize this to help the inspection.
Schema inspection reports mismatches between @Argument
controller method parameters and field arguments declared in the schema.
You can use built-in interceptors for authentication with GraphQL over WebSocket extracted from the payload of the "connection_init"
message, and subsequently propagated to requests on the WebSocket connection. See the reference and the graphql-websocket-auth sample.
Client and server WebSocket transports support sending PING messages at regular intervals if no other messages have been sent. On the server side, this is enabled through the Spring Boot property spring.graphql.websocket.keep-alive
. On the client side, this is enabled through the client builder.
WebSocketGraphQlTester
support configuring interceptors, which can be used for example to specify authentication information through a "connection_init"
payload.
It is now possible to configure a Jackson codec for a GraphQL endpoint separate from the one used for HTTP and web endpoints. This can be important to render GraphQL responses as needed (e.g. with null values) without causing side effects for regular HTTP endpoints.
Annotated controller methods can return Kotlin Flow
.
GraphQL Java 22 provides experimental support for incremental delivery. To learn more see the Working Group page. To experiment, see the spring-graphql-defer sample.