spring-projects / spring-projects/spring-graphql
@BatchMapping does not support kotlin collection whose element type is interface.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 336
- PR merge metrics
- No merged PRs in 30d
Description
The annotation @BatchMapping requires method whose parameter is collection/list, eg
@BatchMapping
public Map<Child, Parent> manyToOne(List<Child> childObjects) {...}
For java, it's OK.
Howerver, for kotlin, it's not OK
@BatchMapping
fun manyToOne(childObjects: List<Child>): Map<Child, Parent> =...
Because kotlin compiler generates the parameter type as kotlin.collections.List/kotlin.collections.Collection, not java.util.List/java.util.Collection
Now, my workaround is: Explicitly use java.util.List in kotlin, this will cause warning of Intellij.
SpringBoot version:
2.7.0
Example code:
Line 36 and 46 of here
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lines 36 and 46 of BookController.kt in the linked Jimmer example and compare the Kotlin collection signatures with the Java @BatchMapping example. Trace how @BatchMapping recognizes the parameter type; done means Kotlin kotlin.collections.List or Collection parameters with interface element types work without explicitly using java.util.List.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, java, kotlin, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100