spring-graphql
spring-graphql copied to clipboard
BatchMapping not working with subscription, although working in query
Hi. I've created a "simple" poc project for spring-graphql. Everything works fine and this definitely poses as good enough for adoption for our spring-boot APIs.
The problem I'm reporting is related to @BatchMapping when used in a subscription.
In the POC there's an integration test (failing) with the following name
it should have consistent results between queries and subscription
The idea of such test is use query to fetch one entity ( a quiz that has multiple child categories - that mapping is done by @BatchMapping ) and compare that with the same quizz which was received via a subscription.
The test can be found here
Further information
The BatchMapping method is invoked when new values ( for the subscription ) are generated, so one would imagine everything is working. But then, the generated result has everything except the values that would come from batch mapping.
Further information Mono
I even tried to change @BatchMapping annotated method result to a Mono<Map<>> instead of a plain map. It worked as query, but not as subscription.
So I would say this is a bug on spring-graphql. I'm available for any doubt or further explanation that is required.
This should work. I'm not sure what the specific issue is, and I tried the sample, but the tests give me this error:
Caused by: java.lang.IllegalArgumentException: Did not find a query class pt.goncalo.playground.springbootgraphql.repository.entity.QCompany for domain class pt.goncalo.playground.springbootgraphql.repository.entity.Company
at org.springframework.data.querydsl.SimpleEntityPathResolver.createPath(SimpleEntityPathResolver.java:78)
at org.springframework.data.jpa.repository.support.QuerydslJpaPredicateExecutor.<init>(QuerydslJpaPredicateExecutor.java:83)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getRepositoryFragments(JpaRepositoryFactory.java:273)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getRepositoryFragments(JpaRepositoryFactory.java:243)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepositoryComposition(RepositoryFactorySupport.java:436)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:301)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:323)
at org.springframework.data.util.Lazy.getNullable(Lazy.java:231)
at org.springframework.data.util.Lazy.get(Lazy.java:115)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:329)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:144)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
... 104 more
Caused by: java.lang.ClassNotFoundException: pt.goncalo.playground.springbootgraphql.repository.entity.QCompany
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:284)
at org.springframework.data.querydsl.SimpleEntityPathResolver.createPath(SimpleEntityPathResolver.java:71)
... 116 more
Hello @rstoyanchev, thanks for the reply. I've updated the project and ran the test again in now they pass; so i guess this can be closed :)
Thanks.