Closed robertionut95b closed 9 months ago
I got same issue, this issue occured when using org.springframework.boot:spring-boot-starter-data-rest
in the depedencies that make method com.netflix.graphql.dgs.webmvc.autoconfigure.DgsWebMvcAutoConfiguration.WebMvcArgumentHandlerConfiguration#dgsWebDataBinderFactory
have 2 bean candidates
we have 2 possible solution for this issue:
Downgrande the dgs to 4.9.10
because this version have no DgsWebMvcAutoConfiguration.DgsWebMvcAutoConfiguration.WebMvcArgumentHandlerConfiguration
class
override the WebMvcArgumentHandlerConfiguration
class with other configuration then force pick qualified bean for DgsWebMvcAutoConfiguration.WebMvcArgumentHandlerConfiguration#dgsWebDataBinderFactory
parameter just like this
@Configuration
@Import(value = [DgsWebMvcAutoConfiguration.WebMvcArgumentHandlerConfiguration::class])
class DgsConfiguration {
@Qualifier
private annotation class Dgs
@Bean
@Dgs
fun dgsWebDataBinderFactory(@Qualifier("requestMappingHandlerAdapter") adapter: ObjectProvider<RequestMappingHandlerAdapter>): WebDataBinderFactory {
return ServletRequestDataBinderFactory(listOf(), adapter.ifAvailable?.webBindingInitializer)
}
@Bean
open fun requestHeaderMapResolver(@Dgs dataBinderFactory: WebDataBinderFactory): ArgumentResolver {
return HandlerMethodArgumentResolverAdapter(RequestHeaderMapMethodArgumentResolver(), dataBinderFactory)
}
@Bean
open fun requestHeaderResolver(beanFactory: ConfigurableBeanFactory, @Dgs dataBinderFactory: WebDataBinderFactory): ArgumentResolver {
return HandlerMethodArgumentResolverAdapter(
RequestHeaderMethodArgumentResolver(beanFactory),
dataBinderFactory
)
}
@Bean
open fun requestParamResolver(@Dgs dataBinderFactory: WebDataBinderFactory): ArgumentResolver {
return HandlerMethodArgumentResolverAdapter(RequestParamMethodArgumentResolver(false), dataBinderFactory)
}
@Bean
open fun requestParamMapResolver(@Dgs dataBinderFactory: WebDataBinderFactory): ArgumentResolver {
return HandlerMethodArgumentResolverAdapter(RequestParamMapMethodArgumentResolver(), dataBinderFactory)
}
@Bean
open fun cookieValueResolver(beanFactory: ConfigurableBeanFactory, @Dgs dataBinderFactory: WebDataBinderFactory): ArgumentResolver {
return HandlerMethodArgumentResolverAdapter(ServletCookieValueMethodArgumentResolver(beanFactory), dataBinderFactory)
}
}
Thanks for reporting. I think we can fix this by adding the qualifier in the framework so it doesn't clash.
On Mon, Jan 30, 2023 at 8:03 AM gho1b @.***> wrote:
I got same issue, this issue occured when using org.springframework.boot:spring-boot-starter-data-rest in the depedencies that make method com.netflix.graphql.dgs.webmvc.autoconfigure.DgsWebMvcAutoConfiguration.WebMvcArgumentHandlerConfiguration#dgsWebDataBinderFactory have 2 bean candidates
we have 2 possible solution for this issue:
1.
Downgrande the dgs to 4.9.10 because this version have no com.netflix.graphql.dgs.webmvc.autoconfigure.DgsWebMvcAutoConfiguration.WebMvcArgumentHandlerConfiguration class 2.
override the com.netflix.graphql.dgs.webmvc.autoconfigure.DgsWebMvcAutoConfiguration.WebMvcArgumentHandlerConfiguration class with other configuration. just like this
@Configuration @Import(value = [DgsWebMvcAutoConfiguration.WebMvcArgumentHandlerConfiguration::class]) class DgsConfiguration { @Qualifier private annotation class Dgs
@Bean @Dgs fun ***@***.***("requestMappingHandlerAdapter") adapter: ObjectProvider<RequestMappingHandlerAdapter>): WebDataBinderFactory { return ServletRequestDataBinderFactory(listOf(), adapter.ifAvailable?.webBindingInitializer) } @Bean open fun ***@***.*** dataBinderFactory: WebDataBinderFactory): ArgumentResolver { return HandlerMethodArgumentResolverAdapter(RequestHeaderMapMethodArgumentResolver(), dataBinderFactory) } @Bean open fun requestHeaderResolver(beanFactory: ConfigurableBeanFactory, @Dgs dataBinderFactory: WebDataBinderFactory): ArgumentResolver { return HandlerMethodArgumentResolverAdapter( RequestHeaderMethodArgumentResolver(beanFactory), dataBinderFactory ) } @Bean open fun ***@***.*** dataBinderFactory: WebDataBinderFactory): ArgumentResolver { return HandlerMethodArgumentResolverAdapter(RequestParamMethodArgumentResolver(false), dataBinderFactory) } @Bean open fun ***@***.*** dataBinderFactory: WebDataBinderFactory): ArgumentResolver { return HandlerMethodArgumentResolverAdapter(RequestParamMapMethodArgumentResolver(), dataBinderFactory) } @Bean open fun cookieValueResolver(beanFactory: ConfigurableBeanFactory, @Dgs dataBinderFactory: WebDataBinderFactory): ArgumentResolver { return HandlerMethodArgumentResolverAdapter(ServletCookieValueMethodArgumentResolver(beanFactory), dataBinderFactory) }
}
— Reply to this email directly, view it on GitHub https://github.com/Netflix/dgs-framework/issues/1262#issuecomment-1408882845, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ5JPXNCHNVUKGF4FKMVGGDWU7Q4JANCNFSM6AAAAAAQ6ZXN2U . You are receiving this because you are subscribed to this thread.Message ID: @.***>
is there any working solution for this. cannot able to identify and understand solution posted by @gho1b
We don't yet due to other priorities. If this is a blocker, please feel free to open a PR with a fix to unblock and we'd be happy to review and release.
Resolving since this issue was fixed in 58b5462 and 564e82d.
Please read our contributor guide before creating an issue.
Hello,
I have just migrated my project on a separate branch from graphql-kickstarter to dgs. Unfortunately, I cannot boot-up the application after adding the required dependencies and modifying the data fetching logic to DGS's concepts.
Am I missing something from the configuration?
Expected behavior
Application should start as usual.
Actual behavior
Steps to reproduce
The branch repo is available at https://github.com/robertionut95b/paxton/tree/dgs-graphql/apps/paxton-api
Note: A test case would be highly appreciated, but we understand that's not always possible