smallrye-graphql icon indicating copy to clipboard operation
smallrye-graphql copied to clipboard

@GraphQLSupplyAsAsync for GraphQLApi Resouces or Resolver Methods

Open michaelsonnleitner opened this issue 5 years ago • 2 comments

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);
    }

michaelsonnleitner avatar Oct 09 '20 08:10 michaelsonnleitner

Thanks for the feature request. We will look at this a.s.a.p. You are also welcome to supply a PR :) .

phillip-kruger avatar Oct 10 '20 09:10 phillip-kruger

Also see https://openliberty.io/blog/2019/01/24/async-rest-jaxrs-microprofile.html as an possible way to do it. (Thanks @andymc12 )

phillip-kruger avatar Oct 14 '20 14:10 phillip-kruger