Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
recordSourceOptions: CacheOptions = {},
storeOptions: {
persistOptions?: CacheOptionsStore;
gcScheduler?: Scheduler;
operationLoader?: OperationLoader;
getDataID?: any; // do not use
} = {},
offlineStoreOptions: CacheOptions = {},
): RelayModernEnvironment {
let idbStore: CacheOptions;
let idbRecords: CacheOptions;
let idbOffline: CacheOptions;
const { gcScheduler, operationLoader, getDataID, persistOptions } = storeOptions;
if (typeof window !== 'undefined') {
const { name = 'relay', onUpgrade, version } = idbOptions;
const idbStorages: ICacheStorage[] = IDBStorage.create({
name,
storeNames: ['store', 'records', 'offline'],
onUpgrade,
version,
});
idbStore = {
storage: idbStorages[0],
serialize: false,
prefix: null,
...persistOptions,
};
idbRecords = {
storage: idbStorages[1],
serialize: false,
const CacheLocalNew = new Cache({
errorHandling: (error) => {
console.log("error", error);
return true;
},
layers: [filterPersistReplace],
prefix: 'cachenew',
});
const CacheSessionNew = new Cache({
prefix: 'cachenew',
webStorage: 'session'
});
const idbStorages: CacheStorage[] = IDBStorage.create( {
name: "cache",
onUpgrade: (db, oldv, newv, transaction) => {
console.log("onUpgrade", db, oldv, newv, transaction);
},
storeNames: ["persist", "persist2"],
version: 1,
});
const idbStorageNo: CacheStorage[] = IDBStorage.create( {
name: "nocache",
onUpgrade: (db, oldv, newv, transaction) => {
console.log("onUpgrade", db, oldv, newv, transaction);
},
storeNames: ["persist"],
version: 1,
const CacheSessionNew = new Cache({
prefix: 'cachenew',
webStorage: 'session'
});
const idbStorages: CacheStorage[] = IDBStorage.create( {
name: "cache",
onUpgrade: (db, oldv, newv, transaction) => {
console.log("onUpgrade", db, oldv, newv, transaction);
},
storeNames: ["persist", "persist2"],
version: 1,
});
const idbStorageNo: CacheStorage[] = IDBStorage.create( {
name: "nocache",
onUpgrade: (db, oldv, newv, transaction) => {
console.log("onUpgrade", db, oldv, newv, transaction);
},
storeNames: ["persist"],
version: 1,
});
console.log(idbStorages[0]);
console.log(idbStorages);
const CacheLocalIDBNO = new Cache({
prefix: null,
serialize: false,
} = {},
): ApolloClientOffline {
const { cacheOptions, persistOptions = {}, offlineStoreOptions = {}, idbOptions = {} } = options;
const idbStore: CacheOptions = {
serialize: false,
prefix: null,
...persistOptions,
};
const idbOffline: CacheOptions = {
serialize: false,
prefix: null,
...offlineStoreOptions,
};
if (typeof window !== 'undefined') {
const { name = 'apollo', onUpgrade, version } = idbOptions;
const idbStorages: Array = IDBStorage.create({
name,
storeNames: ['store', 'offline'],
onUpgrade,
version,
});
idbStore.storage = idbStorages[0];
idbOffline.storage = idbStorages[1];
}
const cache = new ApolloCache(cacheOptions, idbStore);
return new ApolloClientOffline({ ...config, cache }, idbOffline);
}
}