0

创建新记录后,我正在尝试更新我的 Apollo 缓存。

但是当我从缓存中读取(以获取当前集合值)时,它返回 null。我已经调查过cache.diff,它抱怨缺少字段错误。

当我检查缓存(通过 JS)时,它看起来确实存在该字段,那么可能出了什么问题?

这就是我正在做的事情:

我试图像这样从缓存中读取,但它返回null

const existingCollection = apolloClient.readQuery({
  query,
  variables,
});

我的query样子是这样的(用 包裹qgl):

query currentUser {
  currentUser {
    id
    user {
      id
      uuid
      company {
        id
        uuid
        usersCollection(first: 5) {
          edges {
            node {
              email
              id
              uuid
              firstName
              lastName
            }
          }
          pageInfo {
            hasNextPage
            hasPreviousPage
            startCursor
            endCursor
          }
          totalCount
        }
      }
    }
  }
}

当我运行时,cache.diff我得到以下结果:

apolloClient.cache.diff({
  query,
  variables
});

cache.diff 结果

要检查我一直在运行的缓存apolloClient.cache.data.data,我可以看到该记录的记录Company:1和该记录上的字段userCollection

在此处输入图像描述

这里的任何帮助或见解将不胜感激。谢谢

4

0 回答 0