【问题标题】:Is there any way to set default value for extended property in subgraph, for case of if property is null in supergraph?有没有办法为子图中的扩展属性设置默认值,如果属性在超图中为空?
【发布时间】:2022-06-22 03:11:07
【问题描述】:
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 graph 中可以为 null,但它需要获取信息属性,或者我应该在 datafetcher 中处理它。

【问题讨论】:

    标签: graphql apollo-federation


    【解决方案1】:

    听起来您需要使用扩展实体而不是扩展类型,在此处的 Apollo 文档中有更多详细信息:https://www.apollographql.com/docs/federation/v1/entities/#extending-entities

    与 GQL 规范中的扩展类型相关的类似线程:https://stackoverflow.com/a/56204966/9281567

    【讨论】:

      猜你喜欢
      • 2019-08-16
      • 2019-05-30
      • 2021-02-18
      • 1970-01-01
      • 1970-01-01
      • 2010-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多