Skip to content

RFC (graphcache): Cache resolve & invalidate with partial args #2713

Description

@villesau

Summary

Let's say I have relay paginated savedArticles field that takes folder id into account. If I want to invalidate or resolve it, I need something like:

cache.resolve('Query', 'savedArticles', { "first": 20, "folderId": "187", "term": "" })

I'm removing an article from folder 187. I'm not too interested in the page it is at, all I want is to invalidate all the queries that matches folderId 187. Would make the code more readable and easier to write, if I could simply: cache.invalidate('Query', 'savedArticles', { "folderId": "187" }) without knowing anything about extra arguments. In my use case, the folderId is known by the mutation I'm using while the other variables are not interesting in that regard.Thus, I don't have easy access to them. I want to invalidate everything that matches the folder without caring about the rest of the arguments.

Proposed Solution

I'm proposing partial args matching for the cache resolve & invalidate, similar to pattern matching. This would greatly help with dealing with cache invalidation in resolvers.

Requirements

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    future 🔮An enhancement or feature proposal that will be addressed after the next release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions