Description
Hello everyone,
I looked into the virtual thread support today.
It seems, that we have to wrap all @schemamapping annotated methods to return Callable:
@SchemaMapping
public boolean isLatest(ParentObject parent) {
return true; // Long running I/O task
}
Would have to become
@SchemaMapping
public Callable<Boolean> isLatest(ParentObject parent) {
return () -> {
return true; // Long running I/O task
};
}
DGS automatically works with virtual threads on annotated controllers. Would it be an idea to implement this in Spring for GraphQL?
An opt-in configuration option would probably be required, and it would only work on JDK 21+.
https://netflix.github.io/dgs/advanced/virtual-threads/
It filters out CompletableFutures etc.:
https://github.com/Netflix/dgs-framework/blob/ee3d9eba9485cafadfc4cc9d2bbf0c6d4c8bdd89/graphql-dgs/src/main/java21/com.netflix.graphql.dgs.internal.VirtualThreadTaskExecutor/VirtualThreadTaskExecutor.java#L35
https://github.com/Netflix/dgs-framework/blob/master/graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/internal/CompletableFutureWrapper.kt#L51-L53