知识卡片
Mutation根类型组织变更
GraphQL 用 Mutation 根类型声明会改变服务端状态的操作,例如新增、更新或删除资源。每个变更字段同样有参数和返回类型,可把服务器生成的 ID 或更新后对象返回给客户端;它与仅读取数据的 [[Query根类型组织读取]] 分工明确。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》第 8 章《Designing GraphQL APIs》(源文件:_epub-src/OEBPS/Text/08.htm)
- 结论依据:原文定义 mutation 用于改变服务端状态,列举新增、更新和删除,并展示 `type Mutation` 下的 addProduct 字段与返回类型。
- 原始内容:While the purpose of a query is to let us fetch data from the server, mutations allow us to create new resources, to delete them, or to alter their state. Mutations have a return value, which can be a scalar, such as a Boolean, or an object.