smallrye-graphql
smallrye-graphql copied to clipboard
@GraphQLSupplyAsAsync for GraphQLApi Resouces or Resolver Methods
Accoring to your Async Sample it would be nice to have the possibilty to annotate graphql resouces or resolvers as async.
I think this is a very common usecase that resolvers depending on a @source type is executed in async mode.
Here a sample....
@GraphQLApi
@GraphQLSupplyAsAsync
public class PersonResource {
@Inject
BackendService backendService;
@Query
public Person getPerson(long id) throws InterruptedException {
return backendService.getPerson(id);
}
public List<Adress> getAdresses(@Source Person p) throws InterruptedException{
return backendService.getAdressesForPerson(p.id);
}
}
Or the Annotion could be done on the resolver as well
@GraphQLSupplyAsAsync
public List<Adress> getAdresses(@Source Person p) throws InterruptedException{
return backendService.getAdressesForPerson(p.id);
}
Thanks for the feature request. We will look at this a.s.a.p. You are also welcome to supply a PR :) .
Also see https://openliberty.io/blog/2019/01/24/async-rest-jaxrs-microprofile.html as an possible way to do it. (Thanks @andymc12 )