Reactjs 为什么';阿波罗商店更新?

Reactjs 为什么';阿波罗商店更新?,reactjs,redux,graphql,apollo,react-apollo,Reactjs,Redux,Graphql,Apollo,React Apollo,我有以下疑问 const ITEM_COMMENTS_QUERY = gql` query Search($id: UUID, $per_page: Int) { item(id: $id) { id comments(page: 1, per_page: $per_page) { edges { id author { id first_name

我有以下疑问

const ITEM_COMMENTS_QUERY = gql`
  query Search($id: UUID, $per_page: Int) {
    item(id: $id) {
      id
      comments(page: 1, per_page: $per_page) {
        edges {
          id
          author {
            id
            first_name
            last_name
          }
          content
        }
        total_count
      }
    }
  }
`;
下面的突变

  const CREATE_COMMENT_MUTATION = gql`
  mutation create_comment($id: UUID!, $content: String!) {
    create_comment(id: $id, content: $content, type: COMMENT_TYPE_ITEM) {
      id
      ... on ItemComment {
        item {
          id
          comments(page: 1, per_page: 100) {
            edges {
              id
              author {
                id
                first_name
                last_name
              }
              content
            }
          }
        }
      }
    }
  }
`;
回答是正确的,但是阿波罗商店没有更新。 (我有dataIdFromObject:
elm=>elm.id


阿波罗客户端仅在更新时更新存储。所以,当您使用创建或删除变异时,您需要告诉Apollo客户端如何更新。我原以为商店会自动更新,但它没有

更新/删除变异后,需要使用
update
refetch
命令更新存储。下面是一个
更新
示例和