1 |
|
2 |
|
3 | import { NetworkInterface, createNetworkInterface, addQueryMerging } from './networkInterface';
|
4 | import { Document, FragmentDefinition } from 'graphql';
|
5 | import { print } from 'graphql-tag/printer';
|
6 | import { createApolloStore, ApolloStore, createApolloReducer, ApolloReducerConfig, Store } from './store';
|
7 | import { QueryManager, SubscriptionOptions, ResultComparator, ResultTransformer } from './QueryManager';
|
8 | import { ObservableQuery } from './ObservableQuery';
|
9 | import { Observable, Subscription } from './util/Observable';
|
10 | import { WatchQueryOptions } from './watchQueryOptions';
|
11 | import { readQueryFromStore, readFragmentFromStore } from './data/readFromStore';
|
12 | import { writeQueryToStore, writeFragmentToStore } from './data/writeToStore';
|
13 | import { IdGetter } from './data/extensions';
|
14 | import { QueryTransformer, addTypenameToSelectionSet } from './queries/queryTransform';
|
15 | import { MutationBehavior, MutationBehaviorReducerMap, MutationQueryReducersMap } from './data/mutationResults';
|
16 | import { createFragmentMap } from './queries/getFromAST';
|
17 | import { ApolloError } from './errors';
|
18 | export { createNetworkInterface, addQueryMerging, createApolloStore, createApolloReducer, readQueryFromStore, readFragmentFromStore, addTypenameToSelectionSet as addTypename, writeQueryToStore, writeFragmentToStore, print as printAST, createFragmentMap, ApolloError, WatchQueryOptions, ObservableQuery, MutationBehavior, MutationQueryReducersMap, Subscription, ApolloStore };
|
19 | export declare type ApolloQueryResult = {
|
20 | data: any;
|
21 | loading: boolean;
|
22 | };
|
23 | export declare type ApolloStateSelector = (state: any) => Store;
|
24 | export declare let fragmentDefinitionsMap: {
|
25 | [fragmentName: string]: FragmentDefinition[];
|
26 | };
|
27 | export declare function createFragment(doc: Document, fragments?: (FragmentDefinition[] | FragmentDefinition[][])): FragmentDefinition[];
|
28 | export declare function disableFragmentWarnings(): void;
|
29 | export declare function enableFragmentWarnings(): void;
|
30 | export declare function clearFragmentDefinitions(): void;
|
31 | export default class ApolloClient {
|
32 | networkInterface: NetworkInterface;
|
33 | store: ApolloStore;
|
34 | reduxRootKey: string;
|
35 | reduxRootSelector: ApolloStateSelector | null;
|
36 | initialState: any;
|
37 | queryManager: QueryManager;
|
38 | reducerConfig: ApolloReducerConfig;
|
39 | queryTransformer: QueryTransformer;
|
40 | resultTransformer: ResultTransformer;
|
41 | resultComparator: ResultComparator;
|
42 | shouldBatch: boolean;
|
43 | shouldForceFetch: boolean;
|
44 | dataId: IdGetter;
|
45 | fieldWithArgs: (fieldName: string, args?: Object) => string;
|
46 | batchInterval: number;
|
47 | constructor({networkInterface, reduxRootKey, reduxRootSelector, initialState, dataIdFromObject, queryTransformer, resultTransformer, resultComparator, shouldBatch, ssrMode, ssrForceFetchDelay, mutationBehaviorReducers, batchInterval}?: {
|
48 | networkInterface?: NetworkInterface;
|
49 | reduxRootKey?: string;
|
50 | reduxRootSelector?: string | ApolloStateSelector;
|
51 | initialState?: any;
|
52 | dataIdFromObject?: IdGetter;
|
53 | queryTransformer?: QueryTransformer;
|
54 | resultTransformer?: ResultTransformer;
|
55 | resultComparator?: ResultComparator;
|
56 | shouldBatch?: boolean;
|
57 | ssrMode?: boolean;
|
58 | ssrForceFetchDelay?: number;
|
59 | mutationBehaviorReducers?: MutationBehaviorReducerMap;
|
60 | batchInterval?: number;
|
61 | });
|
62 | watchQuery(options: WatchQueryOptions): ObservableQuery;
|
63 | query(options: WatchQueryOptions): Promise<ApolloQueryResult>;
|
64 | mutate(options: {
|
65 | mutation: Document;
|
66 | variables?: Object;
|
67 | resultBehaviors?: MutationBehavior[];
|
68 | fragments?: FragmentDefinition[];
|
69 | optimisticResponse?: Object;
|
70 | updateQueries?: MutationQueryReducersMap;
|
71 | refetchQueries?: string[];
|
72 | }): Promise<ApolloQueryResult>;
|
73 | subscribe(options: SubscriptionOptions): Observable<any>;
|
74 | reducer(): Function;
|
75 | middleware: () => (store: ApolloStore) => (next: any) => (action: any) => any;
|
76 | initStore(): void;
|
77 | resetStore(): void;
|
78 | private setStore(store);
|
79 | }
|