Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
GraphQL 规范允许我们添加自定义查询指令。我正在寻找有关如何执行此操作的一些信息。我想创建一个 @include类似的指令,但逻辑更复杂。
@include
Apollo 指南仅描述了添加方案(即在服务器上工作)指令。
@include 指令可用于包含基于 if 参数值的字段。如果 includeAuthor GraphQL 变量的值为 true,则下面的查询将仅包括帖子的作者。
GraphQL 查询
query ($includeAuthor: Boolean!) { queryPost { id title text author @include(if: $includeAuthor) { id name } } }
GraphQL 变量
{ "includeAuthor": false }