Apollo 3 pagination with Field Policies
Remove updateQuery callback function completely:
fetchMore({ variables: { offset: data.users.length } });
And change your cache to:
import { offsetLimitPagination } from "@apollo/client/utilities";
const cache = new InMemoryCache({
typePolicies: {
Query: {
fields: {
users: offsetLimitPagination(),
},
},
},
});
So your query in qraphql must have offset and limit arguments.
Other options are: concatPagination
and relayStylePagination
If you need to distinguish different request to same field users
ex. put keyArg: offsetLimitPagination(["filters"])
and query your users with filters arg. Cache will store it separately.
More info in official release