This problem happened on react.
This is my cache modify code, and i have a pagination of projects that is based on skip and limit. After cache modification the pagination query refetched from skip:0 or the initial variable values. I don’t to refetch the pagination from the begining it should just give me the all cached projects. That’s one problem. Another one is if i go into a single project page and added one asset which uses the same below code to modify the cache, and after that if i came to pagination page, it successfully fetches the initial variables with skip:0 limit:6, after that when i’m doing pagination it’s going on a loop graphql query call every fetchMore using skip:6 , limit:2 also calls skip:0 limit:6. Every fetchMore triggers two queries.
const validate = cache?.modify({
id: "Project:" + projectId,
fields: {
assets: (existingRefs) => {
const newAssetRef = cache.writeFragment({
data: data.createAsset,
fragment: gql`
fragment NewAsset on Asset {
id
name
}
`,
});
console.log(newAssetRef, "newAssetRef");
return [...existingRefs, newAssetRef];
},
},
});
console.log(validate, "validate");
tried with broadcast:false, nothing worked.
anyone can help me?