UNPKG

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