Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(types): document ApolloPersistOptions parameters #529

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,50 @@ type StorageType<T, TSerialize extends boolean> = TSerialize extends true

export interface ApolloPersistOptions<
TSerialized,
TSerialize extends boolean = true
TSerialize extends boolean = true,
> {
/**
* Reference to your Apollo cache.
*/
cache: ApolloCache<TSerialized>;
/**
* Reference to your storage provider wrapped in a storage wrapper implementing `PersistentStorage` interface.
*/
storage: StorageType<PersistedData<TSerialized>, 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;
}