Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Pass reactive context into GraphQL context #437

Open
@Toerktumlare

Description

@Toerktumlare

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions