Reactjs 阿波罗3号分页,带有开始和限制更多和字段策略
我正在使用fetchmMore Apollo函数,如下所示:Reactjs 阿波罗3号分页,带有开始和限制更多和字段策略,reactjs,react-native,graphql,apollo,strapi,Reactjs,React Native,Graphql,Apollo,Strapi,我正在使用fetchmMore Apollo函数,如下所示: const { data: data_next_drops, loading: loading_next_drops, error: error_next_drops, fetchMore: fetchMoreNext, refetch: refetchNext } = useQuery(GET_ALL_NEXT_DROPS, { variables: { date
const {
data: data_next_drops,
loading: loading_next_drops,
error: error_next_drops,
fetchMore: fetchMoreNext,
refetch: refetchNext
} = useQuery(GET_ALL_NEXT_DROPS, {
variables: {
date: date,
limit: limit,
start: starte
},
});
const loadMore = async () => {
setLoading(true)
fetchMoreNext({
variables: {
date: date,
limit: 10,
start: Skip
},
updateQuery: (preveResult, {fetchMoreResult}) => {
setSkip(Skip+limit)
fetchMoreResult.drops = [
...preveResult.drops,
...fetchMoreResult.drops
]
setLoading(false)
return fetchMoreResult;
}
})
}
但我有一个警告:
The updateQuery callback for fetchMore is deprecated, and will be removed
in the next major version of Apollo Client.
Please convert updateQuery functions to field policies with appropriate
read and merge functions, or use/adapt a helper function (such as
concatPagination, offsetLimitPagination, or relayStylePagination) from
@apollo/client/utilities.
The field policy system handles pagination more effectively than a
hand-written updateQuery function, and you only need to define the policy
once, rather than every time you call fetchMore.
正如你们所看到的,我在分页时使用了限制和开始,所以我认为我不能使用偏移限制分页或RelayStyle分页,所以可以使用concatPagination吗?或者有没有其他方法
提前谢谢你 警告只是告诉您将
updateQuery
函数移出到InMemoryCache
请看(完整地阅读,我第一次错过了一些重要信息),或者因为我有一个无关的问题,使我用一个与您非常接近的工作示例制作了这个