-
-
Notifications
You must be signed in to change notification settings - Fork 522
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
Not persisting cache with apollo-cache-persist #233
Comments
I'm trying as well to get this working... Have you been able to get anything more ? I understand that you do have a correct window objet. Mine is undefined despite I'm in a SPA application so that the code is run client-side (process.browser === true). |
Ok I got it working this way : import { HttpLink } from 'apollo-link-http'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { withClientState } from 'apollo-link-state'
import { persistCache } from 'apollo-cache-persist'
import stores from '../local-state'
export default ctx => {
// CONFIGURE REMOTE ENDPOINT
const httpLink = new HttpLink({
uri: 'https://fsdfessdfsdfsdfsd.cloudfront.net/graphql'
})
// CONFIGURE CACHE
const cache = new InMemoryCache()
if (process.browser) {
persistCache({
cache,
storage: window.localStorage
})
}
// HANDLE LOCAL STATE
const stateLink = withClientState({
cache,
defaults: stores.defaultState,
resolvers: stores.resolvers
})
const link = stateLink.concat(httpLink)
return { link, cache }
}
|
@Akryum I think we can close this issue. |
I have a project where I need to persist the cache in localStorage using 'apollo-cache-persist'. I can see the cache being saved in localStorage, but when refreshing the page it's re-running all queries again (I can see in the network tab in dev tools).
I'm using both 'apollo-cache-inmemory' and 'apollo-link-state'. At first I though the issue was related to 'apollo-link-state' and that it might be related to this issue
But as I said earlier, it's all queries running again on a page refresh.
I've tried using both 'persistCache' and 'CachePersistor' from apollo-cache-persist.
This is how I've tried to implement it:
Is it even possible to use apollo-cache-persist with Vue Apollo and if so are there any examples where it has been implemented?
The text was updated successfully, but these errors were encountered: