@apollo/client
Version:
A fully-featured caching GraphQL client.
32 lines • 2.57 kB
TypeScript
import { DocumentNode } from 'graphql';
import { StoreObject, Reference } from '../../utilities';
import { DataProxy } from './types/DataProxy';
import { Cache } from './types/Cache';
export type Transaction<T> = (c: ApolloCache<T>) => void;
export declare abstract class ApolloCache<TSerialized> implements DataProxy {
abstract read<TData = any, TVariables = any>(query: Cache.ReadOptions<TVariables, TData>): TData | null;
abstract write<TData = any, TVariables = any>(write: Cache.WriteOptions<TData, TVariables>): Reference | undefined;
abstract diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T>;
abstract watch<TData = any, TVariables = any>(watch: Cache.WatchOptions<TData, TVariables>): () => void;
abstract reset(options?: Cache.ResetOptions): Promise<void>;
abstract evict(options: Cache.EvictOptions): boolean;
abstract restore(serializedState: TSerialized): ApolloCache<TSerialized>;
abstract extract(optimistic?: boolean): TSerialized;
abstract removeOptimistic(id: string): void;
batch<U>(options: Cache.BatchOptions<this, U>): U;
abstract performTransaction(transaction: Transaction<TSerialized>, optimisticId?: string | null): void;
recordOptimisticTransaction(transaction: Transaction<TSerialized>, optimisticId: string): void;
transformDocument(document: DocumentNode): DocumentNode;
transformForLink(document: DocumentNode): DocumentNode;
identify(object: StoreObject | Reference): string | undefined;
gc(): string[];
modify(options: Cache.ModifyOptions): boolean;
readQuery<QueryType, TVariables = any>(options: Cache.ReadQueryOptions<QueryType, TVariables>, optimistic?: boolean): QueryType | null;
private getFragmentDoc;
readFragment<FragmentType, TVariables = any>(options: Cache.ReadFragmentOptions<FragmentType, TVariables>, optimistic?: boolean): FragmentType | null;
writeQuery<TData = any, TVariables = any>({ id, data, ...options }: Cache.WriteQueryOptions<TData, TVariables>): Reference | undefined;
writeFragment<TData = any, TVariables = any>({ id, data, fragment, fragmentName, ...options }: Cache.WriteFragmentOptions<TData, TVariables>): Reference | undefined;
updateQuery<TData = any, TVariables = any>(options: Cache.UpdateQueryOptions<TData, TVariables>, update: (data: TData | null) => TData | null | void): TData | null;
updateFragment<TData = any, TVariables = any>(options: Cache.UpdateFragmentOptions<TData, TVariables>, update: (data: TData | null) => TData | null | void): TData | null;
}
//# sourceMappingURL=cache.d.ts.map