Skip to content

Problems with removing an entity from cache with invalidate #1027

Answered by Svarto
Svarto asked this question in Q&A
Discussion options

You must be logged in to vote

For people that might run into the same problem, I solved this by instead using a writeQuery and writing an empty array / object into the place I wanted to delete. I guess the cache.invalidate does not work in nested places or on root objects as they werent removed properly.

      delete_recipe_bookmarks: (result, args, cache, info) => {
        cache.updateQuery(
          {
            query: GET_BOOKMARK_STATUS,
            variables: {
              recipeId: args.where.recipe_id._eq,
              user_id: args.where.user_id._eq,
            },
          },
          (data) => {
            if (!data) return null;
            data.recipe_bookmarks = [];
            return data;
     …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Svarto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant