AWS AppSync - 订阅突变不 return 所需的字段

AWS AppSync - Subscription to a mutation does not return the desired fields

我尝试在 AWS AppSync 中订阅 DynamoDB table 中的变更。该架构简要如下所示:

type Post {
  id: ID!
  userId: String!
  title: String
  body: String!
}
input UpdatePostInput {
  id: ID!
  title: String
  body: String
}
type Mutation {
  updatePost(input: UpdatePostInput!): Post
}
type Subscription {
  onUpdatePost(id: ID!): Post
    @aws_subscribe(mutations: ["updatePost"])
}

给定 post 的 ID,当我想获取 post 正文中的更改时,我尝试使用上面的订阅作为:

subscription OnUpdatePost {
  onUpdatePost(id: "some-id") {
    id
    body ## This line should make the trick, but it does not
  }
}

订阅被解雇 - 这很好。但是,结果包含 ID__typename,而不包含 body:

{
  "data": {
    "onUpdatePost": {
      "id": "some-id",
      "__typename": "Post"
    }
  }
}

按照指南 here.

,字段中有 body 应该就足够了

我是否遗漏了此订阅设置的内容?

注:

调用 AWS AppSync 中的订阅作为对突变的响应。订阅由突变触发,the mutation selection set 发送给订阅者。

我怀疑您没有在 updatePost 突变选择集中返回 body。添加该字段,订阅将包含 body,例如

mutation {
  updatePost(input: { id: "some-id" }) {
    id
    body
  }
}