Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: allow for returning Mono/Flux within dataFetchers/mutations. #376

Closed
ruseinov opened this issue Jun 1, 2021 · 4 comments
Closed
Labels
enhancement New feature or request

Comments

@ruseinov
Copy link

ruseinov commented Jun 1, 2021

Please read our contributor guide before
creating an issue. Also consider discussing your idea on
the discussion forum first.

Describe the Feature Request

Currently when one returns a Mono/Flux within, for example, a DataFetcher - that results in a null.
There are more details here: Netflix/dgs-examples-webflux#5 and a workaround that involves converting Mono/Flux to a CompletableFuture.

One of the use-cases for this is DGS + Webflux + ReactiveMongoTemplate integration. At the moment that requires extra effort/boilerplate and I am guessing a slight overhead, because the CompletableFuture returned by the Datafetchers is then converted back to Mono.
It also makes using reactive Mongo with DGS + Webflux a bit confusing, because when using Spring MVC you can use Mongo/Flux as return types for your endpoints and in DGS it results in an error.

Describe Preferred Solution

Allow for returning a Mono/Flux within Mutations/Datafetchers/Subscriptions and automatically convert those to Entities/Lists of entities.

Describe Alternatives

Could be seen in Netflix/dgs-examples-webflux#5 , basically converting reactor stuff to CompletableFutures.

@ruseinov ruseinov added the enhancement New feature or request label Jun 1, 2021
@driverpt
Copy link

driverpt commented Jun 1, 2021

+1

@paulbakker
Copy link
Collaborator

This obviously makes sense to support. The one problem is that graphql-java doesn't support Flux/Mono, so internally everything still has to be CompletableFuture.

I've added some code that basically does the conversion automatically. I think that would work well, but please test it out.

#389

@paulbakker
Copy link
Collaborator

This was released in: https://github.com/Netflix/dgs-framework/releases/tag/v4.2.0

@ruseinov
Copy link
Author

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants