graphql-spring-boot
graphql-spring-boot copied to clipboard
Forwarding of `RequestContext` not working in async mode
Describe the bug
Many spring framework rely on the RequestContextHolder
static class to access the current request attributes. One of them is the Spring-OAuth2 framework that uses it to relay user-token attributes stored in the session to other services in a micro-service architecture.
Only problem being that in async mode, the RequestContextHolder.getRequestAttributes()
returns null
. I see that something custom was required to do this with the security context, so would something similar be possible for RequestContext
?
To Reproduce Steps to reproduce the behavior:
- Enable async mode
- Perform any request, and just call
RequestContextHolder.getRequestAttributes()
from within any resolver. You should see that it's null. - Disable async mode
- Do the same thing, and the attributes should be non-null
Expected behavior
Expect the request attributes to be forwarded when the resolvers are called. Having the request in the DataFetchingEnvironment
is unfortunately not enough for libraries.