apollo-cache

  • Version 1.3.5
  • Published
  • 97 kB
  • 2 dependencies
  • MIT license

Install

npm i apollo-cache
yarn add apollo-cache
pnpm add apollo-cache

Overview

Core abstract of Caching layer for Apollo Client

Index

Classes

class ApolloCache

abstract class ApolloCache<TSerialized> implements DataProxy {}

    method diff

    abstract diff: <T>(query: Cache.DiffOptions) => Cache.DiffResult<T>;

      method evict

      abstract evict: <TVariables = any>(
      query: Cache.EvictOptions<TVariables>
      ) => Cache.EvictionResult;

        method extract

        abstract extract: (optimistic?: boolean) => TSerialized;

          method performTransaction

          abstract performTransaction: (transaction: Transaction<TSerialized>) => void;

            method read

            abstract read: <T, TVariables = any>(
            query: Cache.ReadOptions<TVariables>
            ) => T | null;

              method readFragment

              readFragment: <FragmentType, TVariables = any>(
              options: DataProxy.Fragment<TVariables>,
              optimistic?: boolean
              ) => FragmentType | null;

                method readQuery

                readQuery: <QueryType, TVariables = any>(
                options: DataProxy.Query<TVariables>,
                optimistic?: boolean
                ) => QueryType | null;

                  method recordOptimisticTransaction

                  abstract recordOptimisticTransaction: (
                  transaction: Transaction<TSerialized>,
                  id: string
                  ) => void;

                    method removeOptimistic

                    abstract removeOptimistic: (id: string) => void;

                      method reset

                      abstract reset: () => Promise<void>;

                        method restore

                        abstract restore: (serializedState: TSerialized) => ApolloCache<TSerialized>;

                          method transformDocument

                          transformDocument: (document: DocumentNode) => DocumentNode;
                            transformForLink: (document: DocumentNode) => DocumentNode;

                              method watch

                              abstract watch: (watch: Cache.WatchOptions) => () => void;

                                method write

                                abstract write: <TResult = any, TVariables = any>(
                                write: Cache.WriteOptions<TResult, TVariables>
                                ) => void;

                                  method writeData

                                  writeData: <TData = any>({ id, data }: Cache.WriteDataOptions<TData>) => void;

                                    method writeFragment

                                    writeFragment: <TData = any, TVariables = any>(
                                    options: Cache.WriteFragmentOptions<TData, TVariables>
                                    ) => void;

                                      method writeQuery

                                      writeQuery: <TData = any, TVariables = any>(
                                      options: Cache.WriteQueryOptions<TData, TVariables>
                                      ) => void;

                                        Interfaces

                                        interface DataProxy

                                        interface DataProxy {}

                                          method readFragment

                                          readFragment: <FragmentType, TVariables = any>(
                                          options: DataProxy.Fragment<TVariables>,
                                          optimistic?: boolean
                                          ) => FragmentType | null;

                                            method readQuery

                                            readQuery: <QueryType, TVariables = any>(
                                            options: DataProxy.Query<TVariables>,
                                            optimistic?: boolean
                                            ) => QueryType | null;

                                              method writeData

                                              writeData: <TData = any>(options: DataProxy.WriteDataOptions<TData>) => void;

                                                method writeFragment

                                                writeFragment: <TData = any, TVariables = any>(
                                                options: DataProxy.WriteFragmentOptions<TData, TVariables>
                                                ) => void;

                                                  method writeQuery

                                                  writeQuery: <TData = any, TVariables = any>(
                                                  options: DataProxy.WriteQueryOptions<TData, TVariables>
                                                  ) => void;

                                                    Type Aliases

                                                    type Transaction

                                                    type Transaction<T> = (c: ApolloCache<T>) => void;

                                                      Namespaces

                                                      namespace Cache

                                                      namespace Cache {}

                                                        interface DiffOptions

                                                        interface DiffOptions extends ReadOptions {}

                                                          property returnPartialData

                                                          returnPartialData?: boolean;

                                                            interface EvictionResult

                                                            interface EvictionResult {}

                                                              property success

                                                              success: Boolean;

                                                                interface EvictOptions

                                                                interface EvictOptions<TVariables = any> extends DataProxy.Query<TVariables> {}

                                                                  property rootId

                                                                  rootId?: string;

                                                                    interface ReadOptions

                                                                    interface ReadOptions<TVariables = any> extends DataProxy.Query<TVariables> {}

                                                                      property optimistic

                                                                      optimistic: boolean;

                                                                        property previousResult

                                                                        previousResult?: any;

                                                                          property rootId

                                                                          rootId?: string;

                                                                            interface WatchOptions

                                                                            interface WatchOptions extends ReadOptions {}

                                                                              property callback

                                                                              callback: WatchCallback;

                                                                                interface WriteOptions

                                                                                interface WriteOptions<TResult = any, TVariables = any>
                                                                                extends DataProxy.Query<TVariables> {}

                                                                                  property dataId

                                                                                  dataId: string;

                                                                                    property result

                                                                                    result: TResult;

                                                                                      type WatchCallback

                                                                                      type WatchCallback = (newData: any) => void;

                                                                                        namespace DataProxy

                                                                                        namespace DataProxy {}

                                                                                          interface Fragment

                                                                                          interface Fragment<TVariables> {}

                                                                                            property fragment

                                                                                            fragment: DocumentNode;

                                                                                              property fragmentName

                                                                                              fragmentName?: string;

                                                                                                property id

                                                                                                id: string;

                                                                                                  property variables

                                                                                                  variables?: TVariables;

                                                                                                    interface Query

                                                                                                    interface Query<TVariables> {}

                                                                                                      property query

                                                                                                      query: DocumentNode;

                                                                                                        property variables

                                                                                                        variables?: TVariables;

                                                                                                          interface WriteDataOptions

                                                                                                          interface WriteDataOptions<TData> {}

                                                                                                            property data

                                                                                                            data: TData;

                                                                                                              property id

                                                                                                              id?: string;

                                                                                                                interface WriteFragmentOptions

                                                                                                                interface WriteFragmentOptions<TData, TVariables> extends Fragment<TVariables> {}

                                                                                                                  property data

                                                                                                                  data: TData;

                                                                                                                    interface WriteQueryOptions

                                                                                                                    interface WriteQueryOptions<TData, TVariables> extends Query<TVariables> {}

                                                                                                                      property data

                                                                                                                      data: TData;

                                                                                                                        type DiffResult

                                                                                                                        type DiffResult<T> = {
                                                                                                                        result?: T;
                                                                                                                        complete?: boolean;
                                                                                                                        };

                                                                                                                          Package Files (4)

                                                                                                                          Dependencies (2)

                                                                                                                          Dev Dependencies (0)

                                                                                                                          No dev dependencies.

                                                                                                                          Peer Dependencies (1)

                                                                                                                          Badge

                                                                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/apollo-cache.

                                                                                                                          • Markdown
                                                                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/apollo-cache)
                                                                                                                          • HTML
                                                                                                                            <a href="https://www.jsdocs.io/package/apollo-cache"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>