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

知识卡片

普通读书笔记卡 · 3503.c

对象类型组合资源字段

理解等级:初级

GraphQL 对象类型用 type 声明一个资源的字段集合,每个字段再标注标量或其他对象类型。例如 Cake 可列出名称、价格和可用状态。对象类型定义可查询结构;它与数据库表可相关,却不要求一张对象类型直接对应一张表。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    原书出处

    参考来源

    - 位置:《Microservice APIs》第 8 章《Designing GraphQL APIs》(源文件:_epub-src/OEBPS/Text/08.htm) - 结论依据:原文把蛋糕、饮料、原料等资源建模为对象类型,并展示 `type Cake { ... }` 形式与字段的名称/类型组合。 - 原始内容:Object types are collections of properties, and as the name indicates, we use them to define objects. To define an object type, we use the type keyword followed by the object name, and the list of object properties wrapped between curly braces.