Open lorensr opened 3 years ago
@lorensr I like this idea, but I think I would prefer allowing nested fields
, which should be unambiguous because objects and functions are easily distinguishable:
const [removeReview] = useMutation(REMOVE_REVIEW_MUTATION, {
update(cache) {
cache.modify({
fields: {
currentUser: {
favoriteReviews: (reviews, { readField }) =>
reviews.filter((review) => readField('id', review) !== id),
},
},
})
},
})
Currently, modifying a non-root, non-normalized field requires nesting calls to
cache.modify()
, like the below code modifyingROOT_QUERY.currentUser.favoriteReviews
:It would be nice if there were a simpler API, for example allowing dot notation in
fields
: