apollo-client
- Version 2.6.10
- Published
- 1.15 MB
- 8 dependencies
- MIT license
Install
npm i apollo-clientyarn add apollo-clientpnpm add apollo-clientOverview
A simple yet functional GraphQL client.
Index
Functions
Classes
ApolloClient
- addResolvers()
- cache
- clearStore()
- defaultOptions
- disableNetworkFetches
- extract()
- getResolvers()
- initQueryManager()
- link
- mutate()
- onClearStore()
- onResetStore()
- query()
- queryDeduplication
- queryManager
- readFragment()
- readQuery()
- reFetchObservableQueries()
- resetStore()
- restore()
- setLocalStateFragmentMatcher()
- setResolvers()
- stop()
- store
- subscribe()
- typeDefs
- version
- watchQuery()
- writeData()
- writeFragment()
- writeQuery()
Interfaces
Enums
Type Aliases
Functions
function isApolloError
isApolloError: (err: Error) => err is ApolloError;Classes
class ApolloClient
class ApolloClient<TCacheShape> implements DataProxy {}constructor
constructor(options: ApolloClientOptions<TCacheShape>);property cache
cache: ApolloCache<TCacheShape>;property defaultOptions
defaultOptions: DefaultOptions;property disableNetworkFetches
disableNetworkFetches: boolean;property link
link: ApolloLink;property queryDeduplication
queryDeduplication: boolean;property queryManager
readonly queryManager: QueryManager<TCacheShape>;property store
store: DataStore<TCacheShape>;property typeDefs
readonly typeDefs: any;property version
version: string;method addResolvers
addResolvers: (resolvers: Resolvers | Resolvers[]) => void;method clearStore
clearStore: () => Promise<any[]>;method extract
extract: (optimistic?: boolean) => TCacheShape;method getResolvers
getResolvers: () => Resolvers;method initQueryManager
initQueryManager: () => QueryManager<TCacheShape>;method mutate
mutate: <T = any, TVariables = OperationVariables>( options: MutationOptions<T, TVariables>) => Promise<FetchResult<T>>;method onClearStore
onClearStore: (cb: () => Promise<any>) => () => void;method onResetStore
onResetStore: (cb: () => Promise<any>) => () => void;method query
query: <T = any, TVariables = OperationVariables>( options: QueryOptions<TVariables>) => Promise<ApolloQueryResult<T>>;method readFragment
readFragment: <T = any, TVariables = OperationVariables>( options: DataProxy.Fragment<TVariables>, optimistic?: boolean) => T | null;method readQuery
readQuery: <T = any, TVariables = OperationVariables>( options: DataProxy.Query<TVariables>, optimistic?: boolean) => T | null;method reFetchObservableQueries
reFetchObservableQueries: ( includeStandby?: boolean) => Promise<ApolloQueryResult<any>[]>;method resetStore
resetStore: () => Promise<ApolloQueryResult<any>[] | null>;method restore
restore: (serializedState: TCacheShape) => ApolloCache<TCacheShape>;method setLocalStateFragmentMatcher
setLocalStateFragmentMatcher: (fragmentMatcher: FragmentMatcher) => void;method setResolvers
setResolvers: (resolvers: Resolvers | Resolvers[]) => void;method stop
stop: () => void;method subscribe
subscribe: <T = any, TVariables = OperationVariables>( options: SubscriptionOptions<TVariables>) => Observable<FetchResult<T>>;method watchQuery
watchQuery: <T = any, TVariables = OperationVariables>( options: WatchQueryOptions<TVariables>) => ObservableQuery<T, TVariables>;method writeData
writeData: <TData = any>(options: DataProxy.WriteDataOptions<TData>) => void;method writeFragment
writeFragment: <TData = any, TVariables = OperationVariables>( options: DataProxy.WriteFragmentOptions<TData, TVariables>) => void;method writeQuery
writeQuery: <TData = any, TVariables = OperationVariables>( options: DataProxy.WriteQueryOptions<TData, TVariables>) => void;class ApolloError
class ApolloError extends Error {}constructor
constructor({ graphQLErrors, networkError, errorMessage, extraInfo,}: { graphQLErrors?: ReadonlyArray<GraphQLError>; networkError?: Error | null; errorMessage?: string; extraInfo?: any;});property extraInfo
extraInfo: any;property graphQLErrors
graphQLErrors: readonly GraphQLError[];property message
message: string;property networkError
networkError: Error;class ObservableQuery
class ObservableQuery< TData = any, TVariables = OperationVariables> extends Observable<ApolloQueryResult<TData>> {}constructor
constructor({ queryManager, options, shouldSubscribe,}: { queryManager: QueryManager<any>; options: WatchQueryOptions<TVariables>; shouldSubscribe?: boolean;});property options
options: WatchQueryOptions<TVariables>;property queryId
readonly queryId: string;property queryName
readonly queryName?: string;property variables
variables: {};method currentResult
currentResult: () => ApolloCurrentResult<TData>;method fetchMore
fetchMore: <K extends keyof TVariables>( fetchMoreOptions: FetchMoreQueryOptions<TVariables, K> & FetchMoreOptions<TData, TVariables>) => Promise<ApolloQueryResult<TData>>;method getCurrentResult
getCurrentResult: () => ApolloCurrentQueryResult<TData>;method getLastError
getLastError: () => ApolloError;method getLastResult
getLastResult: () => ApolloQueryResult<TData>;method isDifferentFromLastResult
isDifferentFromLastResult: (newResult: ApolloQueryResult<TData>) => boolean;method refetch
refetch: (variables?: TVariables) => Promise<ApolloQueryResult<TData>>;method resetLastResults
resetLastResults: () => void;method resetQueryStoreErrors
resetQueryStoreErrors: () => void;method result
result: () => Promise<ApolloQueryResult<TData>>;method setOptions
setOptions: ( opts: WatchQueryOptions) => Promise<ApolloQueryResult<TData> | void>;method setVariables
setVariables: ( variables: TVariables, tryFetch?: boolean, fetchResults?: boolean) => Promise<ApolloQueryResult<TData> | void>;method startPolling
startPolling: (pollInterval: number) => void;method stopPolling
stopPolling: () => void;method subscribeToMore
subscribeToMore: < TSubscriptionData = TData, TSubscriptionVariables = TVariables>( options: SubscribeToMoreOptions< TData, TSubscriptionVariables, TSubscriptionData >) => () => void;method updateQuery
updateQuery: <TVars = TVariables>( mapFn: ( previousQueryResult: TData, options: UpdateQueryOptions<TVars> ) => TData) => void;Interfaces
interface DefaultOptions
interface DefaultOptions {}property mutate
mutate?: Partial<MutationOptions>;property query
query?: Partial<QueryOptions>;property watchQuery
watchQuery?: Partial<WatchQueryOptions>;interface FetchMoreOptions
interface FetchMoreOptions<TData = any, TVariables = OperationVariables> {}property updateQuery
updateQuery: ( previousQueryResult: TData, options: { fetchMoreResult?: TData; variables?: TVariables; }) => TData;interface FetchMoreQueryOptions
interface FetchMoreQueryOptions<TVariables, K extends keyof TVariables> {}interface MutationOptions
interface MutationOptions< T = { [key: string]: any; }, TVariables = OperationVariables> extends MutationBaseOptions<T, TVariables> {}property context
context?: any;property fetchPolicy
fetchPolicy?: FetchPolicy;property mutation
mutation: DocumentNode;interface QueryBaseOptions
interface QueryBaseOptions<TVariables = OperationVariables> {}property context
context?: any;property errorPolicy
errorPolicy?: ErrorPolicy;property fetchResults
fetchResults?: boolean;property metadata
metadata?: any;property query
query: DocumentNode;property variables
variables?: TVariables;interface QueryOptions
interface QueryOptions<TVariables = OperationVariables> extends QueryBaseOptions<TVariables> {}property fetchPolicy
fetchPolicy?: FetchPolicy;interface Resolvers
interface Resolvers {}index signature
[key: string]: { [field: string]: Resolver;};interface SubscriptionOptions
interface SubscriptionOptions<TVariables = OperationVariables> {}property fetchPolicy
fetchPolicy?: FetchPolicy;property query
query: DocumentNode;property variables
variables?: TVariables;interface UpdateQueryOptions
interface UpdateQueryOptions<TVariables> {}property variables
variables?: TVariables;interface WatchQueryOptions
interface WatchQueryOptions<TVariables = OperationVariables> extends QueryBaseOptions<TVariables>, ModifiableWatchQueryOptions<TVariables> {}property fetchPolicy
fetchPolicy?: WatchQueryFetchPolicy;Enums
enum FetchType
enum FetchType { normal = 1, refetch = 2, poll = 3,}enum NetworkStatus
enum NetworkStatus { loading = 1, setVariables = 2, fetchMore = 3, refetch = 4, poll = 6, ready = 7, error = 8,}Type Aliases
type ApolloClientOptions
type ApolloClientOptions<TCacheShape> = { link?: ApolloLink; cache: ApolloCache<TCacheShape>; ssrForceFetchDelay?: number; ssrMode?: boolean; connectToDevTools?: boolean; queryDeduplication?: boolean; defaultOptions?: DefaultOptions; assumeImmutableResults?: boolean; resolvers?: Resolvers | Resolvers[]; typeDefs?: string | string[] | DocumentNode | DocumentNode[]; fragmentMatcher?: FragmentMatcher; name?: string; version?: string;};type ApolloCurrentQueryResult
type ApolloCurrentQueryResult<T> = { data: T | undefined; errors?: ReadonlyArray<GraphQLError>; loading: boolean; networkStatus: NetworkStatus; error?: ApolloError; partial?: boolean; stale?: boolean;};type ApolloCurrentResult
type ApolloCurrentResult<T> = { data: T | {}; errors?: ReadonlyArray<GraphQLError>; loading: boolean; networkStatus: NetworkStatus; error?: ApolloError; partial?: boolean;};type ApolloQueryResult
type ApolloQueryResult<T> = { data: T; errors?: ReadonlyArray<GraphQLError>; loading: boolean; networkStatus: NetworkStatus; stale: boolean;};type ErrorPolicy
type ErrorPolicy = 'none' | 'ignore' | 'all';type FetchPolicy
type FetchPolicy = | 'cache-first' | 'network-only' | 'cache-only' | 'no-cache' | 'standby';type LocalStateFragmentMatcher
type FragmentMatcher = ( rootValue: any, typeCondition: string, context: any) => boolean;type MutationQueryReducer
type MutationQueryReducer<T> = ( previousResult: Record<string, any>, options: { mutationResult: FetchResult<T>; queryName: string | undefined; queryVariables: Record<string, any>; }) => Record<string, any>;type MutationQueryReducersMap
type MutationQueryReducersMap< T = { [key: string]: any; }> = { [queryName: string]: MutationQueryReducer<T>;};type MutationUpdaterFn
type MutationUpdaterFn< T = { [key: string]: any; }> = (proxy: DataProxy, mutationResult: FetchResult<T>) => void;type OperationVariables
type OperationVariables = { [key: string]: any;};type PureQueryOptions
type PureQueryOptions = { query: DocumentNode; variables?: { [key: string]: any; }; context?: any;};type QueryListener
type QueryListener = ( queryStoreValue: QueryStoreValue, newData?: any, forceResolvers?: boolean) => void;type Resolver
type Resolver = ( rootValue?: any, args?: any, context?: any, info?: { field: FieldNode; fragmentMap: FragmentMap; }) => any;type SubscribeToMoreOptions
type SubscribeToMoreOptions< TData = any, TSubscriptionVariables = OperationVariables, TSubscriptionData = TData> = { document: DocumentNode; variables?: TSubscriptionVariables; updateQuery?: UpdateQueryFn<TData, TSubscriptionVariables, TSubscriptionData>; onError?: (error: Error) => void;};type WatchQueryFetchPolicy
type WatchQueryFetchPolicy = FetchPolicy | 'cache-and-network';Package Files (8)
Dependencies (8)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (1)
Badge
To add a badge like this oneto 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-client.
- Markdown[](https://www.jsdocs.io/package/apollo-client)
- HTML<a href="https://www.jsdocs.io/package/apollo-client"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3601 ms. - Missing or incorrect documentation? Open an issue for this package.
