I was using both merge
and read
on typePolicies
, and found out that the read
function didn’t have the correct cache key, hence returned the wrong result for the query.
And then I found this comment in the code (ref).
// If we have both a read and a merge function, assume
// keyArgs:false, because read and merge together can take
// responsibility for interpreting arguments in and out. This
// default assumption can always be overridden by specifying
// keyArgs explicitly in the FieldPolicy.
I wouldn’t have known that I need to specify keyArgs
or the problem arose because I have both merge
and read
in the policy. I think it should be documented in this section.