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.

Is it possible to persist in localstorage (or similar) until offline is ready?

See original GitHub issue

I read docs on website and offline RFC issue.

But then I saw this code in this file: https://github.com/FormidableLabs/urql/blob/master/exchanges/graphcache/src/cacheExchange.ts

export interface CacheExchangeOpts {
  updates?: Partial<UpdatesConfig>;
  resolvers?: ResolverConfig;
  optimistic?: OptimisticMutationConfig;
  keys?: KeyingConfig;
  schema?: IntrospectionQuery;
  storage?: StorageAdapter;
}

So the questionis:

Until https://github.com/FormidableLabs/urql/issues/683 is ready, is it possible to use localstorage today at least temporarily?

Something like: https://github.com/apollographql/apollo-cache-persist?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
kittencommented, Apr 15, 2020

The persistence is indeed already functional and you can find an example of this in our persisted-store sample app: https://github.com/FormidableLabs/urql/blob/master/exchanges/graphcache/examples/persisted-store/src/app/index.tsx

That persistence is fully functional but we may make small tweaks to the API as we’re adding full offline support. Overall it should be stable and work correctly, but do treat it as experimental until it’s documented and announced please ♥️

When you use it, it should fully work as expected minus what’s mentioned in the RFC, eg optimistic mutations having special handling when a mutation fails due to being offline, or ignoring certain errored results.

1reaction
kittencommented, Apr 18, 2020

I ask you to wait a little longer before closing this: I will try this today.

Well, the question itself is answered so the typically close the issue out after a response.

But don’t worry, you can keep commenting and ask more questions if you need, even when the issue is closed! 🙌

Btw, I’ve noticed you’re opening a lot of issues that end up being questions rather than bugs or actual issues. Maybe you’ll want to take a look at our Spectrum community? It may be a better place for us to help you with questions since it’s more of a message board / forum

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to persist in localstorage (or similar) until offline is ...
I would advise not to store too much in local storage. On some platforms you'll run into performance limitations and that's also a...
Read more >
JavaScript LocalStorage: a Complete Guide
Data in localStorage, though, persists until it is cleared. ... localStorage enables you to take your work offline, just like with Wordle.
Read more >
localForage: Managing offline browser storage - LogRocket Blog
For such needs, browsers provide two main storage mechanisms that are persistent and accessible offline: localStorage and IndexedDB.
Read more >
Web Storage API - MDN Web Docs - Mozilla
localStorage does the same thing, but persists even when the browser is closed and reopened. Stores data with no expiration date, ...
Read more >
Please Stop Using Local Storage - DEV Community ‍ ‍
It still limits the size of data you can store (~5MB across all major browsers). This is a fairly low limit for people...
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