Graphql 使用fetchPolicy=';缓存和网络&x27;apollo客户端中的in-useQuery未更新fetchMore上的缓存
我正在使用apollo客户端进行graphql设置。我有一个分页调用,我使用Graphql 使用fetchPolicy=';缓存和网络&x27;apollo客户端中的in-useQuery未更新fetchMore上的缓存,graphql,apollo,apollo-client,graphql-js,Graphql,Apollo,Apollo Client,Graphql Js,我正在使用apollo客户端进行graphql设置。我有一个分页调用,我使用useQuery钩子返回的fetchMore函数来调用它。 在fetchMore函数中,我使用其updateQueryparam将新获取的数据附加到缓存中的结果中 fetchMore({ variables: { request: fetchMorerequest, }, updateQuery: (previousResult, { fetchMoreResult }) => { con
useQuery
钩子返回的fetchMore
函数来调用它。
在fetchMore
函数中,我使用其updateQuery
param将新获取的数据附加到缓存中的结果中
fetchMore({
variables: {
request: fetchMorerequest,
},
updateQuery: (previousResult, { fetchMoreResult }) => {
const updatedResults = update(previousResult, {
list: {
data: { $push: fetchMoreResult.list.data },
hasMore: { $set: fetchMoreResult.list.hasMore },
},
});
return updatedResults;
},
});
这对我来说很好
现在,我已经将我的fetchPolicy
从默认的cache first
更改为cache and network
。
更改之后,我从updateQuery
函数返回的updateResults
将反映在缓存中,但不会在组件中返回。我可以在chrome中的apollo扩展中看到缓存中的更新项。但是没有把它们放在我的组件中
你知道这里有什么问题吗?我错过什么了吗?请提供帮助。在您的
defaultOptions
或当前查询选项中设置nextFetchPolicy:'cache first'