知识卡片
同一操作可请求多个根字段
一个 GraphQL 查询操作可以同时选择多个根字段,例如产品列表与原料列表,并在一次请求中获得各自结果。这样可减少网络往返;服务端解析成本及错误处理仍需分别观察。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《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