知识卡片
字段解析映射内部引用
内部数据可只保存关联对象 ID,但 GraphQL 模式中的对象字段要求返回对象形状。字段解析器可在读取该字段时按 ID 查找并组装关联对象,使根查询解析器不必重复展开关系;查找失败时需按字段非空约束处理。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》第 10 章《Building GraphQL APIs with Python》(源文件:_epub-src/OEBPS/Text/10.htm)
- 结论依据:原文中配方把 ingredient 存为 ID,而模式要求 Ingredient 对象,随后示范在字段解析器中转换。
- 原始内容:The ingredient field maps to an ingredient ID, not a full ingredient object. This is our internal representation of the product’s ingredients.