diff --git a/packages/apollo-cache-inmemory/src/__tests__/writeToStore.ts b/packages/apollo-cache-inmemory/src/__tests__/writeToStore.ts index 8731a614206..bc4aee1ed56 100644 --- a/packages/apollo-cache-inmemory/src/__tests__/writeToStore.ts +++ b/packages/apollo-cache-inmemory/src/__tests__/writeToStore.ts @@ -1180,7 +1180,6 @@ describe('writing to the store', () => { selectionSet: def.selectionSet, result: cloneDeep(result), context: { - storeFactory: defaultNormalizedCacheFactory, store: defaultNormalizedCacheFactory(), variables, dataIdFromObject: () => '5', diff --git a/packages/apollo-cache-inmemory/src/inMemoryCache.ts b/packages/apollo-cache-inmemory/src/inMemoryCache.ts index bb05861af0c..062b624b771 100644 --- a/packages/apollo-cache-inmemory/src/inMemoryCache.ts +++ b/packages/apollo-cache-inmemory/src/inMemoryCache.ts @@ -22,7 +22,6 @@ const defaultConfig: ApolloReducerConfig = { fragmentMatcher: new HeuristicFragmentMatcher(), dataIdFromObject: defaultDataIdFromObject, addTypename: true, - storeFactory: defaultNormalizedCacheFactory, }; export function defaultDataIdFromObject(result: any): string | null { @@ -69,7 +68,7 @@ export class InMemoryCache extends ApolloCache { } this.addTypename = this.config.addTypename; - this.data = this.config.storeFactory(); + this.data = defaultNormalizedCacheFactory(); } public restore(data: NormalizedCacheObject): this { @@ -92,7 +91,7 @@ export class InMemoryCache extends ApolloCache { } return readQueryFromStore({ - store: this.config.storeFactory(this.extract(query.optimistic)), + store: defaultNormalizedCacheFactory(this.extract(query.optimistic)), query: this.transformDocument(query.query), variables: query.variables, rootId: query.rootId, @@ -118,7 +117,7 @@ export class InMemoryCache extends ApolloCache { public diff(query: Cache.DiffOptions): Cache.DiffResult { return diffQueryAgainstStore({ - store: this.config.storeFactory(this.extract(query.optimistic)), + store: defaultNormalizedCacheFactory(this.extract(query.optimistic)), query: this.transformDocument(query.query), variables: query.variables, returnPartialData: query.returnPartialData, diff --git a/packages/apollo-cache-inmemory/src/types.ts b/packages/apollo-cache-inmemory/src/types.ts index 7d5838e1cc6..df45006146b 100644 --- a/packages/apollo-cache-inmemory/src/types.ts +++ b/packages/apollo-cache-inmemory/src/types.ts @@ -39,10 +39,6 @@ export interface StoreObject { [storeFieldKey: string]: StoreValue; } -export type NormalizedCacheFactory = ( - seed?: NormalizedCacheObject, -) => NormalizedCache; - export type OptimisticStoreItem = { id: string; data: NormalizedCacheObject; @@ -68,7 +64,6 @@ export type ApolloReducerConfig = { fragmentMatcher?: FragmentMatcherInterface; addTypename?: boolean; cacheRedirects?: CacheResolverMap; - storeFactory?: NormalizedCacheFactory; }; export type ReadStoreContext = { diff --git a/packages/apollo-cache-inmemory/src/writeToStore.ts b/packages/apollo-cache-inmemory/src/writeToStore.ts index f12f107e0fd..9c3f182cf2c 100644 --- a/packages/apollo-cache-inmemory/src/writeToStore.ts +++ b/packages/apollo-cache-inmemory/src/writeToStore.ts @@ -33,7 +33,6 @@ import { defaultNormalizedCacheFactory, ObjectCache } from './objectCache'; import { IdGetter, NormalizedCache, - NormalizedCacheFactory, ReadStoreContext, StoreObject, } from './types'; @@ -72,8 +71,7 @@ export function enhanceErrorWithDocument(error: Error, document: DocumentNode) { export function writeQueryToStore({ query, result, - storeFactory = defaultNormalizedCacheFactory, - store = storeFactory(), + store = defaultNormalizedCacheFactory(), variables, dataIdFromObject, fragmentMatcherFunction, @@ -81,7 +79,6 @@ export function writeQueryToStore({ query: DocumentNode; result: Object; store?: NormalizedCache; - storeFactory?: NormalizedCacheFactory; variables?: Object; dataIdFromObject?: IdGetter; fragmentMatcherFunction?: FragmentMatcher; @@ -95,7 +92,6 @@ export function writeQueryToStore({ selectionSet: queryDefinition.selectionSet, context: { store, - storeFactory, processedData: {}, variables: assign({}, getDefaultValues(queryDefinition), variables), dataIdFromObject, @@ -110,7 +106,6 @@ export function writeQueryToStore({ export type WriteContext = { readonly store: NormalizedCache; - readonly storeFactory: NormalizedCacheFactory; readonly processedData?: { [x: string]: FieldNode[] }; readonly variables?: any; readonly dataIdFromObject?: IdGetter; @@ -122,8 +117,7 @@ export function writeResultToStore({ dataId, result, document, - storeFactory = defaultNormalizedCacheFactory, - store = storeFactory(), + store = defaultNormalizedCacheFactory(), variables, dataIdFromObject, fragmentMatcherFunction, @@ -132,7 +126,6 @@ export function writeResultToStore({ result: any; document: DocumentNode; store?: NormalizedCache; - storeFactory?: NormalizedCacheFactory; variables?: Object; dataIdFromObject?: IdGetter; fragmentMatcherFunction?: FragmentMatcher; @@ -147,7 +140,6 @@ export function writeResultToStore({ selectionSet: operationDefinition.selectionSet, context: { store, - storeFactory, processedData: {}, variables: assign({}, getDefaultValues(operationDefinition), variables), dataIdFromObject,