Persisted queries and better access to cache
See original GitHub issueIm really intrigued by this library, mainly because of small size (Apollo adds almost 40Kb gzipped which is 1/3 of my bundle…) and simple core API to build my own thing with (e.g. on React hooks). Great job!
However I have few feature requests, I’d like to hear your opinion before even thinking about switching:
1. What do you think about reworking flush or adding a new API to access cache in app? Word flush seems odd in that context. Few options: method to read data by key or even expose map directly.
Direct access opens up so many possibilities which enables us to build pretty complex behaviors with these primitives, e.g. show partial data while loading when navigating from list view to detail view. I just tested it and 2 identical queries except with few different fields don’t return the same item from cache (not sure if partial bug or intended, I never understood Apollo partial either).
2. Option to generate id for query objects and pass it to fetch function, then we’re able to only send query id instead of whole query, less bytes to upload and ability to white-list (persisted queries). Preferably a hash based on query string, then we don’t end up with same queries and different ids.
Neither of these features would really add any size to final bundle, persisted queries would be almost entirely babel-plugin feature and better cache access would be max few lines of code.
Cheers
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:11 (4 by maintainers)

Top Related StackOverflow Question
It removes an item with a given key from the cache?
I agree that clear is a better term then reset.
@adjourn I’ll do it my self then.
About the integrations I’m planning to add hooks support for react and preact and will open a proper issue for that. So feel free to leave any suggestions there.
@mogelbrod I’m not quite sure if I understand your proposal for
resetByKey. Could you explain further?And I’ll definitely add a contribution guide, great Idea.