# graphql-kotlin


12/18/2021, 2:24 AM
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

Shane Myrick

12/18/2021, 3:08 AM
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


12/18/2021, 7:41 AM
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