UNPKG

2.46 kBTypeScriptView Raw
1import { DocumentNode, GraphQLError } from 'graphql';
2import { Cache } from '../cache';
3import { WatchQueryOptions, ErrorPolicy } from './watchQueryOptions';
4import { ObservableQuery } from './ObservableQuery';
5import { QueryListener } from './types';
6import { FetchResult } from '../link/core';
7import { ObservableSubscription } from '../utilities';
8import { NetworkStatus } from './networkStatus';
9import { ApolloError } from '../errors';
10import { QueryManager } from './QueryManager';
11export type QueryStoreValue = Pick<QueryInfo, "variables" | "networkStatus" | "networkError" | "graphQLErrors">;
12export declare const enum CacheWriteBehavior {
13 FORBID = 0,
14 OVERWRITE = 1,
15 MERGE = 2
16}
17export declare class QueryInfo {
18 readonly queryId: string;
19 listeners: Set<QueryListener>;
20 document: DocumentNode | null;
21 lastRequestId: number;
22 subscriptions: Set<ObservableSubscription>;
23 variables?: Record<string, any>;
24 networkStatus?: NetworkStatus;
25 networkError?: Error | null;
26 graphQLErrors?: ReadonlyArray<GraphQLError>;
27 stopped: boolean;
28 private cache;
29 constructor(queryManager: QueryManager<any>, queryId?: string);
30 init(query: {
31 document: DocumentNode;
32 variables: Record<string, any> | undefined;
33 networkStatus?: NetworkStatus;
34 observableQuery?: ObservableQuery<any>;
35 lastRequestId?: number;
36 }): this;
37 private dirty;
38 private notifyTimeout?;
39 reset(): void;
40 getDiff(variables?: Record<string, any> | undefined): Cache.DiffResult<any>;
41 private lastDiff?;
42 private updateLastDiff;
43 private getDiffOptions;
44 setDiff(diff: Cache.DiffResult<any> | null): void;
45 readonly observableQuery: ObservableQuery<any> | null;
46 private oqListener?;
47 setObservableQuery(oq: ObservableQuery<any> | null): void;
48 notify(): void;
49 private shouldNotify;
50 stop(): void;
51 private cancel;
52 private lastWatch?;
53 private updateWatch;
54 private lastWrite?;
55 resetLastWrite(): void;
56 private shouldWrite;
57 markResult<T>(result: FetchResult<T>, document: DocumentNode, options: Pick<WatchQueryOptions, "variables" | "fetchPolicy" | "errorPolicy">, cacheWriteBehavior: CacheWriteBehavior): void;
58 markReady(): NetworkStatus;
59 markError(error: ApolloError): ApolloError;
60}
61export declare function shouldWriteResult<T>(result: FetchResult<T>, errorPolicy?: ErrorPolicy): boolean;
62//# sourceMappingURL=QueryInfo.d.ts.map
\No newline at end of file