From 83fb72d5b82951972b3878040e67938e33b48c89 Mon Sep 17 00:00:00 2001 From: Nicolas Charpentier Date: Wed, 29 May 2024 11:49:40 -0400 Subject: [PATCH] chore(types): document `ApolloPersistOptions` parameters --- src/types/index.ts | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/types/index.ts b/src/types/index.ts index be79303c..3c097b5a 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -24,15 +24,50 @@ type StorageType = TSerialize extends true export interface ApolloPersistOptions< TSerialized, - TSerialize extends boolean = true + TSerialize extends boolean = true, > { + /** + * Reference to your Apollo cache. + */ cache: ApolloCache; + /** + * Reference to your storage provider wrapped in a storage wrapper implementing `PersistentStorage` interface. + */ storage: StorageType, TSerialize>; + /** + * When to persist the cache. + * + * `write`: Persist upon every write to the cache. Default. + * + * `background`: Persist when your app moves to the background. **React Native only**. + * + * For a custom trigger, provide a function. See below for more information. + * + * To disable automatic persistence and manage persistence manually, provide `false`. + */ trigger?: 'write' | 'background' | TriggerFunction | false; + /** + * Debounce interval between persists (in ms). + * Defaults to `0` for `background` and `1000` for `write` and custom triggers. + */ debounce?: number; + /** + * Key to use with the storage provider. Defaults to `apollo-cache-persist`. + */ key?: string; + /** + * Whether to serialize to JSON before/after persisting. Defaults to `true`. + */ serialize?: TSerialize; + /** + * Maximum size of cache to persist (in bytes). + * Defaults to `1048576` (1 MB). For unlimited cache size, provide `false`. + * If exceeded, persistence will pause and app will start up cold on next launch. + */ maxSize?: number | false; persistenceMapper?: PersistenceMapperFunction; + /** + * Enable console logging. + */ debug?: boolean; }