@apollo/client
Version:
A fully-featured caching GraphQL client.
18 lines • 841 B
JavaScript
import { defaultMakeCacheKey } from "optimism";
/**
* A variant of `optimism`'s `defaultMakeCacheKey` function that allows us to
* pre-bind some arguments to be part of the cache key Trie path.
*
* This should always be used in place of `defaultMakeCacheKey` to bind
* the `this` context of classes owning wrapped functions, to ensure that
* the cache keys are collected from memory when the owning object is garbage collected.
*
* Without this, cache keys can stay in memory indefinitely, even though the owning
* Apollo Client instance is long gone.
* This is a risk in long-running processes with `[DocumentNode, string, string]`
* style cache keys with persistent document nodes.
*/
export function bindCacheKey(...prebound) {
return defaultMakeCacheKey.bind(null, ...prebound);
}
//# sourceMappingURL=bindCacheKey.js.map