Skip to content

Cache.invalidate how it works #2161

Answered by JoviDeCroock
Miloshinjo asked this question in Q&A
Discussion options

You must be logged in to vote

This isn't really derivable from your example but I'm going out on a limb here to say you probably know which Parent you want to invalidate so let's look at this example in specific:

const updates = {
  Mutation: {
    unlinkChildFromParent: (result, args, cache) => {
      if (result.unlinkChildFromParent) {
        // this means we'll invalidate Parent:id.child
        cache.invalidate(cache.keyOfEntity({ __typename: 'Parent', id: args.id }), 'child')
        // this means we'll just invalidate Child:id from the cache, this means that when we
        // get the parent that used to link to this before it will go
        // Parent:id.child --> Child:id --> oh it's missing
        cache.in…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Miloshinjo
Comment options

Answer selected by Miloshinjo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants