【发布时间】:2021-02-16 03:17:43
【问题描述】:
我正在使用这样的 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: 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.
如您所见,我使用 limit 和 start 进行分页,所以我认为我不能使用 offsetLimitPagination 或 relayStylePagination,所以这可以使用 concatPagination 吗?还是有其他方法?
提前谢谢你!
【问题讨论】:
标签: reactjs react-native graphql apollo strapi