webpack-bootstrap-ui-kit/src/js/ajax/apollo/cache.js

20 lines
622 B
JavaScript
Raw Normal View History

2022-05-03 20:50:57 +02:00
import { InMemoryCache } from '@apollo/client'
2021-08-09 18:04:09 +02:00
2022-05-03 20:50:57 +02:00
// import { IonicStorageModule } from '@ionic/storage';
// import { persistCache, IonicStorageWrapper } from 'apollo3-cache-persist';
import { persistCacheSync, LocalStorageWrapper } from 'apollo3-cache-persist'
2021-08-09 18:04:09 +02:00
2022-05-03 20:50:57 +02:00
const cache = new InMemoryCache()
2021-08-09 18:04:09 +02:00
// await before instantiating ApolloClient, else queries might run before the cache is persisted
2022-05-03 20:50:57 +02:00
// await persistCache({
2021-08-09 18:04:09 +02:00
persistCacheSync({
cache,
storage: new LocalStorageWrapper(window.localStorage),
2022-05-03 20:50:57 +02:00
key: 'web-persist',
2021-08-09 18:04:09 +02:00
maxSize: 1048576, // 1Mb
2022-05-03 20:50:57 +02:00
// new IonicStorageWrapper(IonicStorageModule),
})
2021-08-09 18:04:09 +02:00
2022-05-03 20:50:57 +02:00
export { cache }