嵌套字段上具有类型条件的Apollo graphql查询

嵌套字段上具有类型条件的Apollo graphql查询,graphql,apollo,Graphql,Apollo,我正在研究以下类型,其中“注释”的“内容”是联合类型: type TextContent { text: String } type RichContent { participants: [String] startTime: String } union Content = TextContent | RichContent type Comment { id: ID sender: String content: Content } type Review

我正在研究以下类型,其中“注释”的“内容”是联合类型:

type TextContent {
  text: String
}

type RichContent {
  participants: [String]
  startTime: String
}

union Content = TextContent | RichContent

type Comment {
  id: ID
  sender: String
  content: Content
}

type Review {
  id: ID
  title: String
  lastComment: Comment
}
在我的Apollo查询中,我尝试在两种内容类型上使用条件片段:

query listOfReviews {
  reviews {
    ...reviewFields
  }
}

fragment reviewFields on Review {
  id
  title
  lastComment {
    content {
      ... on TextContent {
        text
      }
      ... on RichContent {
        participants
        startTime
      }
    }
  }
}
我收到一个运行时错误,阿波罗似乎试图访问“未定义”的“参与者”字段,其中实际的内容对象是:

{
  __typename: "TextContent:,
  text: "abc"
}
看起来这两种类型的联合内容合并在一起了

我的问题是:在Apollo查询中是否允许对嵌套字段使用类型条件?或者必须在查询返回的顶级类型上使用类型条件?如果允许,我应该如何修复我的类型/查询


非常感谢

@const86帮助指出这是由以下错误造成的: