UNPKG

5.1 kBTypeScriptView Raw
1import { ApolloLink, FetchResult } from 'apollo-link';
2import { DocumentNode } from 'graphql';
3import { Cache } from 'apollo-cache';
4import { Observer, Subscription, Observable } from '../util/Observable';
5import { DataStore } from '../data/store';
6import { MutationStore } from '../data/mutations';
7import { QueryStore } from '../data/queries';
8import { QueryOptions, WatchQueryOptions, SubscriptionOptions, MutationOptions } from './watchQueryOptions';
9import { ObservableQuery } from './ObservableQuery';
10import { QueryListener, ApolloQueryResult, FetchType, OperationVariables } from './types';
11import { LocalState } from './LocalState';
12export interface QueryInfo {
13 listeners: Set<QueryListener>;
14 invalidated: boolean;
15 newData: Cache.DiffResult<any> | null;
16 document: DocumentNode | null;
17 lastRequestId: number;
18 observableQuery: ObservableQuery<any> | null;
19 subscriptions: Set<Subscription>;
20 cancel?: () => void;
21}
22export declare class QueryManager<TStore> {
23 link: ApolloLink;
24 mutationStore: MutationStore;
25 queryStore: QueryStore;
26 dataStore: DataStore<TStore>;
27 readonly assumeImmutableResults: boolean;
28 private queryDeduplication;
29 private clientAwareness;
30 private localState;
31 private onBroadcast;
32 private ssrMode;
33 private idCounter;
34 private queries;
35 private fetchQueryRejectFns;
36 constructor({ link, queryDeduplication, store, onBroadcast, ssrMode, clientAwareness, localState, assumeImmutableResults, }: {
37 link: ApolloLink;
38 queryDeduplication?: boolean;
39 store: DataStore<TStore>;
40 onBroadcast?: () => void;
41 ssrMode?: boolean;
42 clientAwareness?: Record<string, string>;
43 localState?: LocalState<TStore>;
44 assumeImmutableResults?: boolean;
45 });
46 stop(): void;
47 mutate<T>({ mutation, variables, optimisticResponse, updateQueries: updateQueriesByName, refetchQueries, awaitRefetchQueries, update: updateWithProxyFn, errorPolicy, fetchPolicy, context, }: MutationOptions): Promise<FetchResult<T>>;
48 fetchQuery<T>(queryId: string, options: WatchQueryOptions, fetchType?: FetchType, fetchMoreForQueryId?: string): Promise<FetchResult<T>>;
49 private markQueryResult;
50 queryListenerForObserver<T>(queryId: string, options: WatchQueryOptions, observer: Observer<ApolloQueryResult<T>>): QueryListener;
51 private transformCache;
52 transform(document: DocumentNode): Readonly<{
53 document: Readonly<DocumentNode>;
54 hasClientExports: boolean;
55 hasForcedResolvers: boolean;
56 clientQuery: Readonly<DocumentNode> | null;
57 serverQuery: Readonly<DocumentNode> | null;
58 defaultVars: Readonly<OperationVariables>;
59 }>;
60 private getVariables;
61 watchQuery<T, TVariables = OperationVariables>(options: WatchQueryOptions, shouldSubscribe?: boolean): ObservableQuery<T, TVariables>;
62 query<T>(options: QueryOptions): Promise<ApolloQueryResult<T>>;
63 generateQueryId(): string;
64 stopQueryInStore(queryId: string): void;
65 private stopQueryInStoreNoBroadcast;
66 addQueryListener(queryId: string, listener: QueryListener): void;
67 updateQueryWatch(queryId: string, document: DocumentNode, options: WatchQueryOptions): () => void;
68 addObservableQuery<T>(queryId: string, observableQuery: ObservableQuery<T>): void;
69 removeObservableQuery(queryId: string): void;
70 clearStore(): Promise<void>;
71 resetStore(): Promise<ApolloQueryResult<any>[]>;
72 reFetchObservableQueries(includeStandby?: boolean): Promise<ApolloQueryResult<any>[]>;
73 observeQuery<T>(queryId: string, options: WatchQueryOptions, observer: Observer<ApolloQueryResult<T>>): Promise<FetchResult<T, Record<string, any>, Record<string, any>>>;
74 startQuery<T>(queryId: string, options: WatchQueryOptions, listener: QueryListener): string;
75 startGraphQLSubscription<T = any>({ query, fetchPolicy, variables, }: SubscriptionOptions): Observable<FetchResult<T>>;
76 stopQuery(queryId: string): void;
77 private stopQueryNoBroadcast;
78 removeQuery(queryId: string): void;
79 getCurrentQueryResult<T>(observableQuery: ObservableQuery<T>, optimistic?: boolean): {
80 data: T | undefined;
81 partial: boolean;
82 };
83 getQueryWithPreviousResult<TData, TVariables = OperationVariables>(queryIdOrObservable: string | ObservableQuery<TData, TVariables>): {
84 previousResult: any;
85 variables: TVariables | undefined;
86 document: DocumentNode;
87 };
88 broadcastQueries(): void;
89 getLocalState(): LocalState<TStore>;
90 private inFlightLinkObservables;
91 private getObservableFromLink;
92 private fetchRequest;
93 private getQuery;
94 private setQuery;
95 private invalidate;
96 private prepareContext;
97 checkInFlight(queryId: string): boolean;
98 private pollingInfoByQueryId;
99 startPollingQuery(options: WatchQueryOptions, queryId: string, listener?: QueryListener): string;
100 stopPollingQuery(queryId: string): void;
101}
102//# sourceMappingURL=QueryManager.d.ts.map
\No newline at end of file