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.

Example of how to restore offline changes

See original GitHub issue

Struggling with how to restore offline changes so that they reflect on the UI.

The following offline mutation saves the data to the offline store and reflects immediately on the UI - however when I refresh the page the changes are no longer reflected.

const [ updateTodo ] = useOfflineMutation(gql`
  mutation UpdateTodo ($id: ID! $name: String!)
    updateTodo (id: $id name: $id) {
      id
      name
    }
  }
`)

await updateTodo({
  variables: { id: item.id, name: item.name },
  returnType: 'Todo',
  operationType: CacheOperation.REFRESH,
  idField: 'id'
})

I’ve read through the docs and came across mutationCacheUpdates which looks as if it’s designed to do the trick but I can’t work out for the life of me how to use it - any pointers/examples would be much appreciated - cheers!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
wtrockicommented, Jan 29, 2020

Most of the queries from client are not named to reduce payload size. Named query/mutation can contain multiple underlying graphql queries and mutations. That is the reason we require actual query name in global cache updates. In terms of our underlying engine each operation is processed separately by conflict/offline engine anyway.

I guess we need to document good patterns to not name your queries if single operation is send etc. Also once we integrate offix with graphback we can enforce some standards or even generate cache update functions as they would be easy to build - then our helpers could be deprecated

2reactions
darahayescommented, Jan 29, 2020

Have you tried the following?

const mutationCacheUpdates = {
  sendMessage: sendMessageUpdateFn
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to restore changes that were made offline in ...
Open a document, spreadsheet, presentation, or drawing. · Click the File menu and select See revision history. · Click a time stamp in...
Read more >
Restore a past version in Google Docs - YouTube
Restore a past version in Google Docs. ... Top 5 Excel Functions for Finance People (with end-to-end example ). Chandoo. Chandoo.
Read more >
Google Docs How to Recover an Erased Paper or Work
Best data recovery software : https://bit.ly/3IxCapK50% off now : https://bit.ly/3rLcoZpWas the video helpful? Want to return the favor.
Read more >
Top 6 Ways to Fix Google Drive Offline Not Working Issue
1. Open Google Chrome. · 2. Click the Advanced button to expand the Settings tab and then scroll down to the Restore settings...
Read more >
3 Ways to Turn On Offline Sync Google Drive/Google Docs
This article covers the full explanation of offline sync Google Drive and provides ... It does so by Saving the changes on your...
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