Skip to content

Commit f4c6fca

Browse files
committed
Update docs for blocking controller method support
See gh-958
1 parent bbea54b commit f4c6fca

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

spring-graphql-docs/modules/ROOT/pages/controllers.adoc

+31-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ method arguments and return values..
125125

126126

127127
[[controllers.schema-mapping.signature]]
128-
=== Method Signature
128+
=== Method Arguments
129129

130130
Schema mapping handler methods can have any of the following method arguments:
131131

@@ -208,6 +208,10 @@ See xref:controllers.adoc#controllers.schema-mapping.data-loader[`DataLoader`].
208208

209209
|===
210210

211+
212+
[[controllers.schema-mapping.return.values]]
213+
=== Return Values
214+
211215
Schema mapping handler methods can return:
212216

213217
- A resolved value of any type.
@@ -217,6 +221,16 @@ Schema mapping handler methods can return:
217221
- `java.util.concurrent.Callable` to have the value(s) produced asynchronously.
218222
For this to work, `AnnotatedControllerConfigurer` must be configured with an `Executor`.
219223

224+
On Java 21+, when `AnnotatedControllerConfigurer` is configured with an `Executor`, controller
225+
methods with a blocking method signature are invoked asynchronously. By default, a controller
226+
method is considered blocking if it does not return an async type such as `Flux`, `Mono`,
227+
`CompletableFuture`, and is also not a Kotlin suspending function. You can configure a
228+
blocking controller method `Predicate` on `AnnotatedControllerConfigurer` to help
229+
determine which methods are considered blocking.
230+
231+
TIP: The Spring Boot starter for Spring for GraphQL automatically configures
232+
`AnnotatedControllerConfigurer` with an `Executor` for virtual threads when the property
233+
`spring.threads.virtual.enabled` is set.
220234

221235

222236
[[controllers.schema-mapping.interfaces]]
@@ -705,7 +719,7 @@ annotation attributes. The type name can also be inherited from a class level
705719

706720

707721
[[controllers.batch-mapping.signature]]
708-
=== Method Signature
722+
=== Method Arguments
709723

710724
Batch mapping methods support the following arguments:
711725

@@ -731,9 +745,12 @@ Batch mapping methods support the following arguments:
731745
| The environment that is available in GraphQL Java to a
732746
`org.dataloader.BatchLoaderWithContext`.
733747

734-
735748
|===
736749

750+
751+
[[controllers.batch-mapping.return.values]]
752+
=== Return Values
753+
737754
Batch mapping methods can return:
738755

739756
[cols="1,2"]
@@ -759,6 +776,17 @@ Batch mapping methods can return:
759776

760777
|===
761778

779+
On Java 21+, when `AnnotatedControllerConfigurer` is configured with an `Executor`, controller
780+
methods with a blocking method signature are invoked asynchronously. By default, a controller
781+
method is considered blocking if it does not return an async type such as `Flux`, `Mono`,
782+
`CompletableFuture`, and is also not a Kotlin suspending function. You can configure a
783+
blocking controller method `Predicate` on `AnnotatedControllerConfigurer` to help
784+
determine which methods are considered blocking.
785+
786+
TIP: The Spring Boot starter for Spring for GraphQL automatically configures
787+
`AnnotatedControllerConfigurer` with an `Executor` for virtual threads when the property
788+
`spring.threads.virtual.enabled` is set.
789+
762790

763791

764792
[[controllers.batch-mapping.interfaces]]

0 commit comments

Comments
 (0)