Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BatchMapping annotation does not do parallel execution for data loaders out of the box for Java 17 #1096

Open
kaus02 opened this issue Dec 4, 2024 · 2 comments
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@kaus02
Copy link

kaus02 commented Dec 4, 2024

BatchMapping annotation has been recently introduced as a substitute to configuring BatchLoaderRegistry and using annotation SchemaMapping. In the docs it is not specified that solely using the BatchMapping annotation does not do a parallel execution for field resolvers, how do we enable parallel fetch for field resolvers when using batchmapping and Java 17.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 4, 2024
@kaus02
Copy link
Author

kaus02 commented Dec 4, 2024

@rstoyanchev if you can please help here

@kaus02
Copy link
Author

kaus02 commented Dec 4, 2024

Documentation mentions following line

@SchemaMapping and @BatchMapping methods can return Callable that is submitted to an Executor such as the Spring Framework VirtualThreadTaskExecutor. To enable this, you must configure an Executor on AnnotatedControllerConfigurer.

Can we have an example of this , how to "configure an Executor on AnnotatedControllerConfigurer"?
As I'm creating the bean like following and the code is not executing on different threads, even after using both schemamapping and batchmapping annotation.

@Bean
public DefaultBatchLoaderRegistry batchLoaderRegistry() {
    return new DefaultBatchLoaderRegistry();
}

@Bean // <1>
public AnnotatedControllerConfigurer annotatedControllerConfigurer() {
    AnnotatedControllerConfigurer annotatedControllerConfigurer= new AnnotatedControllerConfigurer();
    annotatedControllerConfigurer.setExecutor(new VirtualThreadTaskExecutor());
    return annotatedControllerConfigurer;
}
@Bean // <2>
public ExecutionGraphQlService executionGraphQlService() {
    GraphQlSource graphQlSource = GraphQlSource.schemaResourceBuilder() // <3>
            .schemaResources(new ClassPathResource("graphql/schema.graphqls"))
            .configureRuntimeWiring(annotatedControllerConfigurer())
            .build();
    DefaultExecutionGraphQlService service = new DefaultExecutionGraphQlService(graphQlSource);
    service.addDataLoaderRegistrar(batchLoaderRegistry());
    return service;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants