Reputation: 41
There is a pagination example on the https://www.apollographql.com/docs/react/pagination/offset-based/.
Given there is a peace of code:
const { loading, data, fetchMore } = useQuery(FEED_QUERY, {
variables: {
offset: 0,
limit: 10,
},
});
...
const loadNextPage = useCallback(() => {
return fetchMore({
variables: {
offset: data.feed.length,
},
});
}, []);
...
<button onClick={loadNextPage}>Load more</button>;
I cannot get what is wrong with my configuration and why it calls the first page every time. It is unnecesarry.
There is some picularity there. The fetchPolicy
is set to 'network-only'
in the defaultOptions
configuration of the ApolloClient
:
query: {
fetchPolicy: 'network-only'
}
Upvotes: 3
Views: 262