返回主题:GraphQL 模式、查询与执行

知识卡片

普通读书笔记卡 · 3505.e

同一操作可请求多个根字段

理解等级:中级

一个 GraphQL 查询操作可以同时选择多个根字段,例如产品列表与原料列表,并在一次请求中获得各自结果。这样可减少网络往返;服务端解析成本及错误处理仍需分别观察。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    原书出处

    参考来源

    - 位置:《Microservice APIs》第 9 章《Consuming GraphQL APIs》(源文件:_epub-src/OEBPS/Text/09.htm) - 结论依据:原文把 allProducts 与 allIngredients 放在同一选择集中,说明可减少请求往返。 - 原始内容:GraphQL also allows us to send several queries in one request. This is yet another powerful feature of GraphQL that can help us save unnecessary network round-trips to the server