UNPKG

@urql/exchange-graphcache

Version:

A normalized and configurable cache exchange for urql

38 lines (32 loc) 1.3 kB
import { StorageAdapter } from './urql-exchange-graphcache-chunk.js'; interface StorageOptions { /** Name of the IndexedDB database that will be used. * @defaultValue `'graphcache-v4'` */ idbName?: string; /** Maximum age of cache entries (in days) after which data is discarded. * @defaultValue `7` days */ maxAge?: number; /** Gets Called when the exchange has hydrated the data from storage. */ onCacheHydrated?: () => void; } /** Sample storage adapter persisting to IndexedDB. */ interface DefaultStorage extends StorageAdapter { /** Clears the entire IndexedDB storage. */ clear(): Promise<any>; } /** Creates a default {@link StorageAdapter} which uses IndexedDB for storage. * * @param opts - A {@link StorageOptions} configuration object. * @returns the created {@link StorageAdapter}. * * @remarks * The default storage uses IndexedDB to persist the normalized cache for * offline use. It demonstrates that the cache can be chunked by timestamps. * * Note: We have no data on stability of this storage and our Offline Support * for large APIs or longterm use. Proceed with caution. */ declare const makeDefaultStorage: (opts?: StorageOptions) => DefaultStorage; export { DefaultStorage, StorageOptions, makeDefaultStorage };