Skip to content

Commit

Permalink
Update docs for blocking controller method support
Browse files Browse the repository at this point in the history
See gh-958
  • Loading branch information
rstoyanchev committed May 7, 2024
1 parent bbea54b commit f4c6fca
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions spring-graphql-docs/modules/ROOT/pages/controllers.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ method arguments and return values..


[[controllers.schema-mapping.signature]]
=== Method Signature
=== Method Arguments

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

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

|===


[[controllers.schema-mapping.return.values]]
=== Return Values

Schema mapping handler methods can return:

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

On Java 21+, when `AnnotatedControllerConfigurer` is configured with an `Executor`, controller
methods with a blocking method signature are invoked asynchronously. By default, a controller
method is considered blocking if it does not return an async type such as `Flux`, `Mono`,
`CompletableFuture`, and is also not a Kotlin suspending function. You can configure a
blocking controller method `Predicate` on `AnnotatedControllerConfigurer` to help
determine which methods are considered blocking.

TIP: The Spring Boot starter for Spring for GraphQL automatically configures
`AnnotatedControllerConfigurer` with an `Executor` for virtual threads when the property
`spring.threads.virtual.enabled` is set.


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


[[controllers.batch-mapping.signature]]
=== Method Signature
=== Method Arguments

Batch mapping methods support the following arguments:

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


|===


[[controllers.batch-mapping.return.values]]
=== Return Values

Batch mapping methods can return:

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

|===

On Java 21+, when `AnnotatedControllerConfigurer` is configured with an `Executor`, controller
methods with a blocking method signature are invoked asynchronously. By default, a controller
method is considered blocking if it does not return an async type such as `Flux`, `Mono`,
`CompletableFuture`, and is also not a Kotlin suspending function. You can configure a
blocking controller method `Predicate` on `AnnotatedControllerConfigurer` to help
determine which methods are considered blocking.

TIP: The Spring Boot starter for Spring for GraphQL automatically configures
`AnnotatedControllerConfigurer` with an `Executor` for virtual threads when the property
`spring.threads.virtual.enabled` is set.



[[controllers.batch-mapping.interfaces]]
Expand Down

0 comments on commit f4c6fca

Please sign in to comment.