graphql-spring-boot
graphql-spring-boot copied to clipboard
Pass reactive context into GraphQL context
Is your feature request related to a problem? Please describe. After looking at the webflux examples, reading more i finally got graphql working in my Webflux application. Had to downgrade from 7.1.0 to 7.01 because of some other bug that people already have reported.
I use authentication in my webflux app and since the underlying graphql java engine only supports CompletableFuture and not Mono
or Flux
, the the ReactiveSecurityContextHolder.getContext()
will always return null since this is using the reactor context
which is not supported in CompletableFuture
.
I have been trying to look into how to be able to pass in the reactor context into the graphql context but i have only been working for a day with this, if someone has any input in how to implement this or point me in the right direction i would be super happy to give it a go.
By digging into the code i see that the ServerWebExchange
is used in the DefaultGraphQLSpringInvocationInputFactory#create
and then during GraphQLSingleInvocationInput#createExecutionInput
it looks like it's getting passed into the GraphQL context.
What i have been trying to figure out is how to access the context in the GraphQLQueryResolver
in the regular Datafetchers
you get access to the DataFetchingEnvironment
where you can extract the context, but i can't figure out how it is done i this project.
Describe the solution you'd like
Be able to use the ReactiveSecurityContextHolder.getContext()
or any type of reactive context in queries.
Describe alternatives you've considered If someone could point me in the right direction i could experiment in trying to implement this myself.