spring-projects / spring-projects/spring-graphql

@BatchMapping triggers the registration of a data fetcher imperatively in the global data loader registry

Open
#1,471 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
1.6k
Forks
336
PR merge metrics
No merged PRs in 30d

Description

In the default Spring Boot configuration, there can be only one GraphQL endpoint. To have more than one, Spring GraphQL beans needs to be redefined, duplicated as needed. So far so good, especially since the lastest addition of controllerPredicate on the AnnotatedControllerDetectionSupport via #1275.

I am still hitting an issue with a such configuration though. @BatchMapping annotations trigger the registeration of data fetchers. But the registry being used to register them is fetched from the application context. In my project, I have many, and I don't even put them in the application context.

The issue seems to be in AnnotatedControllerConfigurer#registerBatchLoader

Could the BatchLoaderRegistry be injected in the AnnotatedControllerConfigurer rather than fetched from the application context ?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/AnnotatedControllerConfigurer.java at registerBatchLoader, then trace how the BatchLoaderRegistry is obtained. Check the multi-endpoint configuration described in the issue and verify that @BatchMapping registration uses the intended registry rather than an unrelated application-context bean. Done means multiple GraphQL configurations can register their batch loaders independently.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, java
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.