简体   繁体   English

是否可以使用 Netflix DGS 在一个请求中执行多个查询?

[英]Is it possible to do multiple queries in one request with Netflix DGS?

I am doing the query like this:我正在做这样的查询:

    GraphQLQueryRequest req = new GraphQLQueryRequest(query, projection);
    String serialized = req.serialize();
    GraphQLResponse response = getClient().executeQuery(serialized);

The response seems to be prepared to return multiple entities.响应似乎准备返回多个实体。 How do I request multiple queries?如何请求多个查询?

If you are try to call the same query twice or more, you should use an alias eg:如果您尝试调用同一个查询两次或更多次,您应该使用别名,例如:

        this.dgsQueryExecutor.execute("""
                {
                    request1 : doctor {
                     id
                     name
                   },
                    request2 : doctor {
                     id
                     name
                   }
                }
                """);

Otherwise, you can just call two queries like:否则,您可以调用两个查询,例如:

        this.dgsQueryExecutor.execute("""
                {
                    doctor {
                     id
                     name
                   },
                    patient {
                     id
                     name
                   }
                }
                """);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM