Paginated read functions is not returning updated args when using fetchMore
cesarve77 opened this issue · 1 comments
cesarve77 commented
Issue Description
I am using fetchMore to make pagination works.
typePolicies: {
Query: {
fields: {
books: {
read(existing, {args: {skip = 0}}) {
//THIS ARGS IS ALWAYS THE INITIAL ARGS, NEVER IS UPDATED BY FETHMORE
console.log('read skip', skip)
return existing?.slice(skip, skip + 10);
},
keyArgs: false,
merge(existing, incoming, {args: {skip = 0}}) {
//THIS IS UPDATED OK
console.log('merge skip', skip)
const merged = existing ? existing.slice(0) : [];
for (let i = 0; i < incoming.length; ++i) {
merged[skip + i] = incoming[i];
}
return merged;
},
}
}
}
}
fetchMore({
variables:{skip: skip + 10}
})
no matter what the passed to fetchMore, in read->args skip always is the initial value. while in merge->args is updated.
Link to Reproduction
https://github.com/cesarve77/apollo3bug
Reproduction Steps
git clone https://github.com/cesarve77/apollo3bug
cd apollo3bug
apollo3bug server
npm i
node index.js
cd apollo3bug
apollo3bug browser
npm i
npm run start
click on next page, check the console,
('read skip', skip) should change any timt next page is clicked
@apollo/client
version
3.9.9
jerelmiller commented
Hey @cesarve77 👋
Thanks for the report! We'll do our best to take a look at this soon.