Skip to content

Commit

Permalink
Remove InMemoryCache methods that are now identical to ApolloCache me…
Browse files Browse the repository at this point in the history
…thods.

Once we stopped calling this.transformDocument in these method
implementations, they became character-for-character identical to the
implementations already provided by the ApolloCache superclass, so we can
simply inherit them as-is.
  • Loading branch information
benjamn committed Jan 17, 2019
1 parent d92fc1c commit fc3c3f1
Showing 1 changed file with 1 addition and 47 deletions.
48 changes: 1 addition & 47 deletions packages/apollo-cache-inmemory/src/inMemoryCache.ts
Expand Up @@ -3,10 +3,9 @@ import './fixPolyfills';

import { DocumentNode } from 'graphql';

import { Cache, DataProxy, ApolloCache, Transaction } from 'apollo-cache';
import { Cache, ApolloCache, Transaction } from 'apollo-cache';

import {
getFragmentQueryDocument,
addTypenameToDocument,
} from 'apollo-utilities';

Expand Down Expand Up @@ -320,51 +319,6 @@ export class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
return document;
}

public readQuery<QueryType, TVariables = any>(
options: DataProxy.Query<TVariables>,
optimistic: boolean = false,
): QueryType {
return this.read({
query: options.query,
variables: options.variables,
optimistic,
});
}

public readFragment<FragmentType, TVariables = any>(
options: DataProxy.Fragment<TVariables>,
optimistic: boolean = false,
): FragmentType | null {
return this.read({
query: getFragmentQueryDocument(options.fragment, options.fragmentName),
variables: options.variables,
rootId: options.id,
optimistic,
});
}

public writeQuery<TData = any, TVariables = any>(
options: DataProxy.WriteQueryOptions<TData, TVariables>,
): void {
this.write({
dataId: 'ROOT_QUERY',
result: options.data,
query: options.query,
variables: options.variables,
});
}

public writeFragment<TData = any, TVariables = any>(
options: DataProxy.WriteFragmentOptions<TData, TVariables>,
): void {
this.write({
dataId: options.id,
result: options.data,
query: getFragmentQueryDocument(options.fragment, options.fragmentName),
variables: options.variables,
});
}

protected broadcastWatches() {
if (!this.silenceBroadcast) {
this.watches.forEach(c => this.maybeBroadcastWatch(c));
Expand Down

0 comments on commit fc3c3f1

Please sign in to comment.