对于超级图中属性为 null 的情况,是否有任何方法可以为子图中的扩展属性设置默认值?
type Book @key(fields: "id language country name desc") @extends {
id: ID! @external
language: String! @external
country: String @external
name: String! @external
description: String! @external
information: MetaInformation @requires(fields: "id language country name desc ")
}
这里我扩展了带有信息属性的书籍,其他的来自书籍图表,我想知道如何设置国家/地区的默认值?它在 Book 图中可以为 null,但它需要获取信息属性,或者以某种方式我应该在 datafetcher 中处理它。
type Book @key(fields: "id language country name desc") @extends {
id: ID! @external
language: String! @external
country: String @external
name: String! @external
description: String! @external
information: MetaInformation @requires(fields: "id language country name desc ")
}
here I extended book with information property and other ones are coming from Book graph, I want to know how I can set default value for country? It can be null in Book graph but it requires for fetching information property or somehow I should handle it in datafetcher.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您需要使用扩展实体而不是扩展类型,这里的 Apollo 文档上有更多详细信息:https://www.apollographql.com/docs/federation/v1/entities/#extending-entities
与扩展相关的类似线程GQL 规范中的类型:https://stackoverflow.com/a/56204966/9281567
It sounds like you need to use an extended entity instead of an extended type, there are more details on this on the Apollo docs here: https://www.apollographql.com/docs/federation/v1/entities/#extending-entities
A similar thread related to extending types in GQL's spec: https://stackoverflow.com/a/56204966/9281567