Open mheidt opened 6 days ago
But I can solve it with toFuture().get() But in case the feign service might return real Flux, we might have a problem
Hum, hum, You're right : the Spring GraphQL controllers don't expect a precise return type. They actually expect an Object, and will manage these kind of return:
A resolved value of any type.
Mono and Flux for asynchronous value(s). Supported for controller methods and for any DataFetcher as described in Reactive DataFetcher.
java.util.concurrent.Callable to have the value(s) produced asynchronously. For this to work, AnnotatedControllerConfigurer must be configured with an Executor.
The current generated code force the return type to be the first line, which is not reactive at all. :(
I missed that point, when migrating to Spring GraphQL.
I'll add this change in the next version.
Etienne
Hello @etienne-sf
Now that I had to switch from webmvc to webflux, I ended up shifting from open-feign to reactivefeign. I have some issues with the following code which is a kind of migrated snippet using Mono
`@Override public List customers(DataFetchingEnvironment dataFetchingEnvironment, DashboardConfig origin, Long customerTypeId, Long customerShortnameTypeId, Long customerGroupId) {
SecurityContext securityContext = SecurityContextHolder.getContext(); //only needed for caching
dashboardConfigService.loadCustomers(getDashboardFilter(dataFetchingEnvironment), customerTypeId, customerShortnameTypeId, customerGroupId, securityContext.toString())
.map(idNameMapper::toMM) // Transform each IdNameDTO to IdName
.collectList() // Collect into a List
.subscribe(origin::setCustomers); // Set the customers once the list is available
}`
But the function will return too early returning empty. calling block() won't work at runtime...some exception, that blocking is not allowed. I would rather see something, that the customers function returns a Mono.
but I override one of the generated functions. Do you have experience with that?