我正在寻找优化在graphql-java和上运行的 GraphQL 端点graphql-java-tools。
我有以下架构:
{
product(id: String) {
id
title
offer {
price
}
}
}
id并且title来自服务A,价格来自服务B。
现在,我有一个GraphQLQueryResolver返回CompletableFuture<ProductResponse>where ProductResponsecontains idand的 a title,还有一个返回 aGraphQLResolver<ProductResponse>的方法。offer(ProductResponse productResponse)CompletableFuture<OfferResponse>
但是,这意味着我必须等待服务 A 返回 aProductResponse才能开始向服务 B 查询 a OfferResponse。这两个服务只需要 ID 作为输入,因此可以并行执行。有没有办法在不调整架构的情况下并行执行两个服务调用?