Subscriptions and Pagination #1691
-
What is the proposed/best way to handle when you want to subscribe to some data that is paginated? Pagination has its own I guess my question is, how do you create/update/delete in the cache for subscription data, when you have bunch of queries (paginated) and not only query for your data (eg. todos). Is there any example or thread I can be pointed to? :) Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I don't specifically know what you mean here, a subscription generally is used to notify you about an entity that has changed. For instance we're looking at a paginated-query of todos and the second item has changed, when the subscription message comes in graphcache will attempt to automatically update cache.writeFragment(gql`
fragment _ on Todo {
id
text
}
`, { id: subscription.data.todo.id, text: subscription.data.todo.text }) Do note that if the |
Beta Was this translation helpful? Give feedback.
I don't specifically know what you mean here, a subscription generally is used to notify you about an entity that has changed. For instance we're looking at a paginated-query of todos and the second item has changed, when the subscription message comes in graphcache will attempt to automatically update
Todo:2
if it finds it in cache. If not you can use something like the following:Do note that if the
__typename
andid
are present in the subscription that this should happen automatically.