Skip to content

Subscriptions and Pagination #1691

Answered by JoviDeCroock
Miloshinjo asked this question in Q&A
Discussion options

You must be logged in to vote

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:

cache.writeFragment(gql`
  fragment _ on Todo {
    id
    text
  }
`, { id: subscription.data.todo.id, text: subscription.data.todo.text })

Do note that if the __typename and id are present in the subscription that this should happen automatically.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Miloshinjo
Comment options

Answer selected by JoviDeCroock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants