Graphql 如何使解析器异步运行

Graphql 如何使解析器异步运行,graphql,graphql-java,Graphql,Graphql Java,我正在设置基于java的graphQl应用程序,发现graphQl java工具确实很方便解决这个问题,尽管这很简单 使用GraphQLJava使字段解析器异步,我找不到使用GraphQLJava工具的方法 我试过了 @Bean public ExecutionStrategy executionStrategy() { return new AsyncExecutionStrategy(); } 这里是我用来测试的解析器 @Component public c

我正在设置基于java的graphQl应用程序,发现graphQl java工具确实很方便解决这个问题,尽管这很简单 使用GraphQLJava使字段解析器异步,我找不到使用GraphQLJava工具的方法

我试过了

@Bean
    public ExecutionStrategy executionStrategy() {
        return new AsyncExecutionStrategy();
    }
这里是我用来测试的解析器

@Component
public class VideoResolver  implements GraphQLResolver<Video> {


     public Episode getEpisode(Video video){

        Episode result = new Episode();

        result.setTitle("episodeTitle");
        result.setUuid("EpisodeUuid");
        result.setBrand("episodeBrand");
        try {
            Thread.sleep(2000L);
            System.out.println(Thread.currentThread().getName());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return result;
    }

    public List<Images> getImages(Video video){

        Images image = new Images();
        image.setFileName("Image FileName1");
        List<Images> imageList = new ArrayList<>();
        imageList.add(image);

        try {
            Thread.sleep(2000L);
            System.out.println(Thread.currentThread().getName());
        } catch (InterruptedException e) {

            System.out.println("Exxxxxxxxxx");
        }
        return imageList;
    }
}

@组件
公共类VideoResolver实现GraphQLResolver{
公共插曲(视频){
插曲结果=新插曲();
结果:片名(“片名”);
结果:毛状体(“幕状体”);
结果:setBrand(“eposodebrand”);
试一试{
睡眠(2000L);
System.out.println(Thread.currentThread().getName());
}捕捉(中断异常e){
e、 printStackTrace();
}
返回结果;
}
公共列表getImages(视频){
图像=新图像();
setFileName(“image FileName1”);
List imageList=新建ArrayList();
添加(图像);
试一试{
睡眠(2000L);
System.out.println(Thread.currentThread().getName());
}捕捉(中断异常e){
系统输出打印项次(“Exxxxxxxxxx”);
}
返回图像列表;
}
}
假设这应该在2秒钟内运行并打印两个不同的流,但不需要4秒 并将其全部打印在同一个流中