UNPKG

1.46 kBTypeScriptView Raw
1import { Middleware, Action } from 'redux';
2import { FragmentMatcher } from 'graphql-anywhere';
3import { NormalizedCache } from './data/storeUtils';
4import { OptimisticStore, getDataWithOptimisticResults } from './optimistic-data/store';
5export { getDataWithOptimisticResults };
6import { ApolloAction } from './actions';
7import { IdGetter } from './core/types';
8import { CustomResolverMap } from './data/readFromStore';
9export interface ReducerError {
10 error: Error;
11 queryId?: string;
12 mutationId?: string;
13 subscriptionId?: number;
14}
15export interface Store {
16 data: NormalizedCache;
17 optimistic: OptimisticStore;
18 reducerError: ReducerError | null;
19}
20export interface ApolloStore {
21 dispatch: (action: ApolloAction) => void;
22 getState: () => any;
23}
24export declare type ApolloReducer = (store: NormalizedCache, action: ApolloAction) => NormalizedCache;
25export declare function createApolloReducer(config: ApolloReducerConfig): (state: Store, action: ApolloAction | Action) => Store;
26export declare function createApolloStore({reduxRootKey, initialState, config, reportCrashes, logger}?: {
27 reduxRootKey?: string;
28 initialState?: any;
29 config?: ApolloReducerConfig;
30 reportCrashes?: boolean;
31 logger?: Middleware;
32}): ApolloStore;
33export declare type ApolloReducerConfig = {
34 dataIdFromObject?: IdGetter;
35 customResolvers?: CustomResolverMap;
36 fragmentMatcher?: FragmentMatcher;
37 addTypename?: boolean;
38};