-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Imperative cache API #58
Comments
The biggest hurdle atm is how to compute the storage key for particular piece of data in the cache. I think the current selection object is not friendly enough for a user facing API so I think we need to come up with something different. Fundamentally, writing data to the cache relies on 3 things besides the value: the ID of the object, the key of the field, and the type of the value (to marshal any complex values the user might provide). Some use cases the API should cover:
Some random thoughts:
|
Not an easy topic, thx for putting a starting point 👍 |
@AlecAivazis @jycouet so I found an interesting use case for this (I'm actually doing this on one of my projects):
|
After a call with @AlecAivazis , let's put down a few thoughts: // reset everything
cache.markAllStale()
// root
const rootCache = cache.getRoot()
// reset all `quoteEdge`
rootCache.markStale("quoteEdge")
// GQL_quoteEdge.markStale();
// reset some fields
const quoteEdge = rootCache.getFields("quoteEdge")
quoteEdge.markStale("nodes")
quoteEdge.markStale("totalCount")
quoteEdge.set("totalCount", 10)
// set a reference
user.set("favoriteFood", cache.get("Recipe", {id: 5})
// reset some fields when specific inputs
rootCache.markStale("quoteEdge", {edge: { pagination: { skip: 0 }, filters: { creatorUserId: null} }})
rootCache.markStale("user", { name: 'JYC'} )
// add an updater to the layer
quoteEdge.set("totalCount", count => count + 1) A lot of things are subject to change... but it's a start 😊 |
Don't have this is a HUGE BLOCKER for us to switching from urql to houdini. I wish you to work on it expressing the best of yourself. 😄 |
@frederikhors it's looking like this will be the next thing we focus on. stay tuned! |
@frederikhors mind telling me which features/ use cases you need most out of the imperative api? I'm assuming marking data as stale is an important one but I'm curious if there are others? |
For now I only need invalidation. We're using it hard because we invalidate & refetch in case of update/delete of an item. I'll let you know if something else is needed. |
Awesome! Thanks for the quick reply. Would you want a way to automatically trigger refetches of the deleted value or is that something you would do by hand? Or just the next time the query is fired? |
I think this depends each time. All the options? It's difficult? |
Nope, not difficult just trying to figure out the priority for all of the features. There's a lot that I'd like to be able to do with this API but with |
Houdini needs to provide the user a way to interact with the cache imperatively to handle situations that aren't covered by the declarative API
The text was updated successfully, but these errors were encountered: