Seen plenty of discussions regarding GraphqlContex...
# graphql-kotlin
k
Seen plenty of discussions regarding GraphqlContext. Maybe it has been discussed plenty of times (will appreciate links to existing threads) but what is the best way to expose request scoped graphqlContext as a Spring bean in webflux reactive app with coroutines? Of course the option of bypassing it from graphql layer to all the services, repositories, etc works fine. But it makes the code more verbose and harder to maintain. Thanks
s
Even with all the extra work I would avoid setting the context as a bean. Bean imply there is only on single creation of the object and you can access it from anywhere. That is not the case with the context.
That being said it would be possible to use Spring BeanFactory to dynamically set a bean value https://expediagroup.github.io/graphql-kotlin/docs/3.x.x/spring-server/spring-schema/
k
Thanks for the suggestion. Although I'm not sure I fully understand how to utilize bean factory here. I was thinking about beans with Request scope. But I'm not sure if something like that even supported in spring webflux