When defining a field read policy in Apollo-Client's cache, does anybody know if it's possible to use readField handle to read values of fields with arguments?
E.g., I have the following object in my cache:
parent {
id
child({"arg1"="A"})
child({"arg1"="B"})
}
I need to set a read policy on a child field of parent to handle those cases when a second argument (e.g., arg2) is passed to that field. In other words, I need to read child({"arg1"="A","arg2"=true}) (not present in cache) based off of the value of child({"arg1"="A"}) (present in cache). E.g.:
read(cached, { readField, args }){
if(!args?.arg2) return cached;
const cachedWithoutArg2 = ???
return doSomething(cachedWithoutArg2);
}
Is there any way to do it?