I’m having an issue with Apollo Client’s cache where my type-level merge policy for CustomFieldValue
isn’t being applied when I update a Entry
that contains it.
My Setup
Type Structure:
type Entry {
entryUrn: String!
customFieldValues: [CustomFieldValue]
# other fields
}
type CustomFieldValue {
urn: String!
# other fields
}
Cache Configuration:
const cache = new InMemoryCache({
typePolicies: {
CustomFieldValue: {
keyFields: ['urn'],
merge: mergeCustomFieldValue // Custom merge function for this type
},
Entry: {
keyFields: ['entryUrn'],
}
}
});
The Problem:
When I update an Entry
(through a mutation or cache write) that contains updated customFieldValues
, the mergeCustomFieldValue
function defined in my type policy for CustomFieldValue
is never called. I expect the type-level merge function to be triggered for each CustomFieldValue
object in the array, but this isn’t happening.
Question:
Why isn’t my type-level merge policy for CustomFieldValue
being triggered when I update an Entry
containing updated customFieldValues
? Do I need to add something specific to make nested normalized objects use their type-level merge functions during parent object updates?