1 | import type { DocumentNode } from "graphql";
|
2 | import type { ApolloLink, FetchResult } from "../link/core/index.js";
|
3 | import type { Cache, ApolloCache } from "../cache/index.js";
|
4 | import { Observable, DocumentTransform } from "../utilities/index.js";
|
5 | import type { QueryOptions, WatchQueryOptions, SubscriptionOptions, MutationOptions, ErrorPolicy, MutationFetchPolicy } from "./watchQueryOptions.js";
|
6 | import { ObservableQuery } from "./ObservableQuery.js";
|
7 | import { NetworkStatus } from "./networkStatus.js";
|
8 | import type { ApolloQueryResult, OperationVariables, MutationUpdaterFunction, OnQueryUpdated, InternalRefetchQueriesInclude, InternalRefetchQueriesOptions, InternalRefetchQueriesMap, DefaultContext } from "./types.js";
|
9 | import type { LocalState } from "./LocalState.js";
|
10 | import type { QueryStoreValue } from "./QueryInfo.js";
|
11 | interface MutationStoreValue {
|
12 | mutation: DocumentNode;
|
13 | variables: Record<string, any>;
|
14 | loading: boolean;
|
15 | error: Error | null;
|
16 | }
|
17 | type UpdateQueries<TData> = MutationOptions<TData, any, any>["updateQueries"];
|
18 | interface TransformCacheEntry {
|
19 | hasClientExports: boolean;
|
20 | hasForcedResolvers: boolean;
|
21 | hasNonreactiveDirective: boolean;
|
22 | clientQuery: DocumentNode | null;
|
23 | serverQuery: DocumentNode | null;
|
24 | defaultVars: OperationVariables;
|
25 | asQuery: DocumentNode;
|
26 | }
|
27 | import type { DefaultOptions } from "./ApolloClient.js";
|
28 | import { Trie } from "@wry/trie";
|
29 | export interface QueryManagerOptions<TStore> {
|
30 | cache: ApolloCache<TStore>;
|
31 | link: ApolloLink;
|
32 | defaultOptions: DefaultOptions;
|
33 | documentTransform: DocumentTransform | null | undefined;
|
34 | queryDeduplication: boolean;
|
35 | onBroadcast: undefined | (() => void);
|
36 | ssrMode: boolean;
|
37 | clientAwareness: Record<string, string>;
|
38 | localState: LocalState<TStore>;
|
39 | assumeImmutableResults: boolean;
|
40 | defaultContext: Partial<DefaultContext> | undefined;
|
41 | }
|
42 | export declare class QueryManager<TStore> {
|
43 | cache: ApolloCache<TStore>;
|
44 | link: ApolloLink;
|
45 | defaultOptions: DefaultOptions;
|
46 | readonly assumeImmutableResults: boolean;
|
47 | readonly documentTransform: DocumentTransform;
|
48 | readonly ssrMode: boolean;
|
49 | readonly defaultContext: Partial<DefaultContext>;
|
50 | private queryDeduplication;
|
51 | private clientAwareness;
|
52 | private localState;
|
53 | private onBroadcast?;
|
54 | mutationStore?: {
|
55 | [mutationId: string]: MutationStoreValue;
|
56 | };
|
57 | private queries;
|
58 | protected fetchCancelFns: Map<string, (error: any) => any>;
|
59 | constructor(options: QueryManagerOptions<TStore>);
|
60 | /**
|
61 | * Call this method to terminate any active query processes, making it safe
|
62 | * to dispose of this QueryManager instance.
|
63 | */
|
64 | stop(): void;
|
65 | private cancelPendingFetches;
|
66 | mutate<TData, TVariables extends OperationVariables, TContext extends Record<string, any>, TCache extends ApolloCache<any>>({ mutation, variables, optimisticResponse, updateQueries, refetchQueries, awaitRefetchQueries, update: updateWithProxyFn, onQueryUpdated, fetchPolicy, errorPolicy, keepRootFields, context, }: MutationOptions<TData, TVariables, TContext>): Promise<FetchResult<TData>>;
|
67 | markMutationResult<TData, TVariables, TContext, TCache extends ApolloCache<any>>(mutation: {
|
68 | mutationId: string;
|
69 | result: FetchResult<TData>;
|
70 | document: DocumentNode;
|
71 | variables?: TVariables;
|
72 | fetchPolicy?: MutationFetchPolicy;
|
73 | errorPolicy: ErrorPolicy;
|
74 | context?: TContext;
|
75 | updateQueries: UpdateQueries<TData>;
|
76 | update?: MutationUpdaterFunction<TData, TVariables, TContext, TCache>;
|
77 | awaitRefetchQueries?: boolean;
|
78 | refetchQueries?: InternalRefetchQueriesInclude;
|
79 | removeOptimistic?: string;
|
80 | onQueryUpdated?: OnQueryUpdated<any>;
|
81 | keepRootFields?: boolean;
|
82 | }, cache?: ApolloCache<TStore>): Promise<FetchResult<TData>>;
|
83 | markMutationOptimistic<TData, TVariables, TContext, TCache extends ApolloCache<any>>(optimisticResponse: any, mutation: {
|
84 | mutationId: string;
|
85 | document: DocumentNode;
|
86 | variables?: TVariables;
|
87 | fetchPolicy?: MutationFetchPolicy;
|
88 | errorPolicy: ErrorPolicy;
|
89 | context?: TContext;
|
90 | updateQueries: UpdateQueries<TData>;
|
91 | update?: MutationUpdaterFunction<TData, TVariables, TContext, TCache>;
|
92 | keepRootFields?: boolean;
|
93 | }): boolean;
|
94 | fetchQuery<TData, TVars extends OperationVariables>(queryId: string, options: WatchQueryOptions<TVars, TData>, networkStatus?: NetworkStatus): Promise<ApolloQueryResult<TData>>;
|
95 | getQueryStore(): Record<string, QueryStoreValue>;
|
96 | resetErrors(queryId: string): void;
|
97 | transform(document: DocumentNode): DocumentNode;
|
98 | private transformCache;
|
99 | getDocumentInfo(document: DocumentNode): TransformCacheEntry;
|
100 | private getVariables;
|
101 | watchQuery<T, TVariables extends OperationVariables = OperationVariables>(options: WatchQueryOptions<TVariables, T>): ObservableQuery<T, TVariables>;
|
102 | query<TData, TVars extends OperationVariables = OperationVariables>(options: QueryOptions<TVars, TData>, queryId?: string): Promise<ApolloQueryResult<TData>>;
|
103 | private queryIdCounter;
|
104 | generateQueryId(): string;
|
105 | private requestIdCounter;
|
106 | generateRequestId(): number;
|
107 | private mutationIdCounter;
|
108 | generateMutationId(): string;
|
109 | stopQueryInStore(queryId: string): void;
|
110 | private stopQueryInStoreNoBroadcast;
|
111 | clearStore(options?: Cache.ResetOptions): Promise<void>;
|
112 | getObservableQueries(include?: InternalRefetchQueriesInclude): Map<string, ObservableQuery<any, OperationVariables>>;
|
113 | reFetchObservableQueries(includeStandby?: boolean): Promise<ApolloQueryResult<any>[]>;
|
114 | setObservableQuery(observableQuery: ObservableQuery<any, any>): void;
|
115 | startGraphQLSubscription<T = any>({ query, fetchPolicy, errorPolicy, variables, context, extensions, }: SubscriptionOptions): Observable<FetchResult<T>>;
|
116 | stopQuery(queryId: string): void;
|
117 | private stopQueryNoBroadcast;
|
118 | removeQuery(queryId: string): void;
|
119 | broadcastQueries(): void;
|
120 | getLocalState(): LocalState<TStore>;
|
121 | protected inFlightLinkObservables: Trie<{
|
122 | observable?: Observable<FetchResult<any>>;
|
123 | }>;
|
124 | private getObservableFromLink;
|
125 | private getResultsFromLink;
|
126 | private fetchConcastWithInfo;
|
127 | refetchQueries<TResult>({ updateCache, include, optimistic, removeOptimistic, onQueryUpdated, }: InternalRefetchQueriesOptions<ApolloCache<TStore>, TResult>): InternalRefetchQueriesMap<TResult>;
|
128 | private fetchQueryByPolicy;
|
129 | private getQuery;
|
130 | private prepareContext;
|
131 | }
|
132 | export {};
|
133 |
|
\ | No newline at end of file |