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

20 lines
623 B
JavaScript
Raw Normal View History

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