Skip to content
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

Support cache persistence configuration #594

Open
dpmillerau opened this issue Feb 15, 2024 · 0 comments
Open

Support cache persistence configuration #594

dpmillerau opened this issue Feb 15, 2024 · 0 comments

Comments

@dpmillerau
Copy link

Your use case

We need to persist the cache using storage as per https://www.apollographql.com/docs/react/caching/advanced-topics for that our client can access results in an offline state.

The solution you'd like

In nuxt.config.ts

import { Storage } from 'unstorage'

export default defineNuxtConfig({
 ...
  apollo: {
    clients: {
      default: {
       ...
       persistCacheStorage: Storage,
      ...
      }
    }
  },

During configuration of client, something like around line 110 src/runtime/plugin.ts

import { persistCache } from 'apollo3-cache-persist';

const cache = new InMemoryCache(clientConfig.inMemoryCacheOptions)

if (clientConfig.persistCacheStorage) {
  persistCache({
    cache,
    storage: clientConfig.persistCacheStorage,
  })
}

Possible alternatives

No response

Additional information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant