知识卡片
关系对象保存连接属性
两种对象的关系若本身带有数据,就可用中间对象类型描述连接,而非只列目标对象。例如产品配方连接原料时,还需保存数量和计量单位,IngredientRecipe 将这些属性与原料一起提供给查询方。参见 [[边字段连接对象类型]]。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》第 8 章《Designing GraphQL APIs》(源文件:_epub-src/OEBPS/Text/08.htm)
- 结论依据:原文对比直接列 Ingredient 与增加 IngredientRecipe 中间类型,后者描述原料、用量及计量单位。
- 原始内容:We could connect them by adding a simple list of ingredients to Cake and Beverage , as shown in figure 8.9, but this wouldn’t tell us how much of each ingredient goes into a product’s recipe. ... IngredientRecipe has three properties: the ingredient itself, its amount, and the unit in which the amount is measured.