question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Persisted queries and better access to cache

See original GitHub issue

Im 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:open
  • Created 5 years ago
  • Reactions:2
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
malbernazcommented, Feb 8, 2019

It removes an item with a given key from the cache?

I agree that clear is a better term then reset.

1reaction
malbernazcommented, Feb 7, 2019

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automatic persisted queries - Apollo GraphQL Docs
A persisted query is a query string that's cached on the server side, along with its unique identifier (always its SHA-256 hash). Clients...
Read more >
Using Persisted Queries · - OneGraph
Caching. The cacheStrategy argument on the persistQuery mutation allows you to specify a ttl for the query. OneGraph will cache the result of ......
Read more >
Understanding persisted queries - Documentation - Brightspot
Introduction to GraphQL persisted queries GraphQL queries are an effective method ... This allows CDNs to cache the result, further improving performance.
Read more >
Automatic Persisted Queries and why you should use them
When we do a request, we only send a small hash, and the server checks if it has the same hash in cache....
Read more >
Persisted Queries - Relay
✓ If your server's persisted query datastore gets wiped, you can recover automatically through your client's requests. · ❌ When there's a cache...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found