From af0a03f2876d7b36198b84c6ab9c92b5d6b1623e Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Sat, 25 Jan 2020 13:44:29 -0500 Subject: [PATCH] Make cache.policies public to support dynamic policy loading. A small step towards implementing https://github.com/apollographql/apollo-client/issues/5750#issuecomment-575795646. --- src/cache/inmemory/inMemoryCache.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cache/inmemory/inMemoryCache.ts b/src/cache/inmemory/inMemoryCache.ts index afb5dbc2657..01565735eed 100644 --- a/src/cache/inmemory/inMemoryCache.ts +++ b/src/cache/inmemory/inMemoryCache.ts @@ -42,12 +42,16 @@ export class InMemoryCache extends ApolloCache { protected config: InMemoryCacheConfig; private watches = new Set(); private addTypename: boolean; - private policies: Policies; private typenameDocumentCache = new Map(); private storeReader: StoreReader; private storeWriter: StoreWriter; + // Dynamically imported code can augment existing typePolicies or + // possibleTypes by calling cache.policies.addTypePolicies or + // cache.policies.addPossibletypes. + public readonly policies: Policies; + // Set this while in a transaction to prevent broadcasts... // don't forget to turn it back on! private silenceBroadcast: boolean = false;