知识卡片
输入类型聚合操作参数
GraphQL 的 input 类型把一组查询或变更参数封装为可复用的输入结构,避免操作签名随过滤项增加而难读。输入类型专供请求参数使用,可设置字段类型、非空约束与默认值;设计创建和更新时,需分别检查哪些字段真正必填。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》第 8 章《Designing GraphQL APIs》(源文件:_epub-src/OEBPS/Text/08.htm)
- 结论依据:原文先把 products 查询的多个过滤参数移入 ProductsFilter,再把 addProduct 的参数移入 AddProductInput,并在 updateProduct 中复用。
- 原始内容:In GraphQL, we can define lists of parameters by using input types, which have the same look and feel as any other GraphQL object type, but they’re meant for use as input for queries and mutations.