import { Trie } from "@wry/trie"; import type { DocumentNode } from "graphql"; import { OperationTypeNode } from "graphql"; import { Observable } from "rxjs"; import type { ApolloCache, Cache } from "@apollo/client/cache"; import type { Incremental } from "@apollo/client/incremental"; import type { ApolloLink } from "@apollo/client/link"; import type { LocalState } from "@apollo/client/local-state"; import type { MaybeMasked } from "@apollo/client/masking"; import { DocumentTransform } from "@apollo/client/utilities"; import type { ExtensionsWithStreamInfo } from "@apollo/client/utilities/internal"; import { extensionsSymbol } from "@apollo/client/utilities/internal"; import type { ApolloClient } from "./ApolloClient.js"; import { NetworkStatus } from "./networkStatus.js"; import { ObservableQuery } from "./ObservableQuery.js"; import type { DataState, DefaultContext, InternalRefetchQueriesInclude, InternalRefetchQueriesMap, InternalRefetchQueriesOptions, OperationVariables, QueryNotification, SubscriptionObservable } from "./types.js"; import type { ErrorPolicy, MutationFetchPolicy, WatchQueryFetchPolicy } from "./watchQueryOptions.js"; interface MutationStoreValue { mutation: DocumentNode; variables: Record; loading: boolean; error: Error | null; } interface TransformCacheEntry { hasClientExports: boolean; hasForcedResolvers: boolean; hasNonreactiveDirective: boolean; hasIncrementalDirective: boolean; nonReactiveQuery: DocumentNode; clientQuery: DocumentNode | null; serverQuery: DocumentNode | null; defaultVars: OperationVariables; asQuery: DocumentNode; operationType: OperationTypeNode | undefined; violation?: Error | undefined; } interface MaskFragmentOptions { fragment: DocumentNode; data: TData; fragmentName?: string; } interface MaskOperationOptions { document: DocumentNode; data: TData; /** * Can be used to identify the cause to prevent warning for the same cause twice. * This would be an object like e.g. an `ObervableQuery`. * If the `cause` is not provided, we will warn every time. */ cause?: object; fetchPolicy?: WatchQueryFetchPolicy; } interface QueryManagerOptions { client: ApolloClient; clientOptions: ApolloClient.Options; defaultOptions: ApolloClient.DefaultOptions; documentTransform: DocumentTransform | null | undefined; queryDeduplication: boolean; onBroadcast: undefined | (() => void); ssrMode: boolean; assumeImmutableResults: boolean; defaultContext: Partial | undefined; dataMasking: boolean; localState: LocalState | undefined; incrementalHandler: Incremental.Handler; } export declare namespace QueryManager { type Result["dataState"] = DataState["dataState"]> = ObservableQuery.Result & { [extensionsSymbol]?: ExtensionsWithStreamInfo; }; } export declare class QueryManager { defaultOptions: ApolloClient.DefaultOptions; readonly client: ApolloClient; /** * The options that were passed to the ApolloClient constructor. */ readonly clientOptions: ApolloClient.Options; readonly assumeImmutableResults: boolean; readonly documentTransform: DocumentTransform; readonly ssrMode: boolean; readonly defaultContext: Partial; readonly dataMasking: boolean; readonly incrementalHandler: Incremental.Handler; localState: LocalState | undefined; private queryDeduplication; /** * Whether to prioritize cache values over network results when * `fetchObservableWithInfo` is called. * This will essentially turn a `"network-only"` or `"cache-and-network"` * fetchPolicy into a `"cache-first"` fetchPolicy, but without influencing * the `fetchPolicy` of the `ObservableQuery`. * * This can e.g. be used to prioritize the cache during the first render after * SSR. */ prioritizeCacheValues: boolean; private onBroadcast?; mutationStore?: { [mutationId: string]: MutationStoreValue; }; /** * All ObservableQueries that currently have at least one subscriber. */ obsQueries: Set>; protected fetchCancelFns: Map any>; constructor(options: QueryManagerOptions); get link(): ApolloLink; get cache(): ApolloCache; /** * Call this method to terminate any active query processes, making it safe * to dispose of this QueryManager instance. */ stop(): void; private cancelPendingFetches; mutate({ mutation, variables, optimisticResponse, updateQueries, refetchQueries, awaitRefetchQueries, update: updateWithProxyFn, onQueryUpdated, fetchPolicy, errorPolicy, keepRootFields, context, }: ApolloClient.MutateOptions & { errorPolicy: ErrorPolicy; fetchPolicy: MutationFetchPolicy; }): Promise>>; fetchQuery(options: ApolloClient.WatchQueryOptions, networkStatus?: NetworkStatus): Promise>; transform(document: DocumentNode): DocumentNode; private transformCache; getDocumentInfo(document: DocumentNode): TransformCacheEntry; getVariables(document: DocumentNode, variables?: TVariables): TVariables; watchQuery(options: ApolloClient.WatchQueryOptions): ObservableQuery; query(options: ApolloClient.QueryOptions): Promise>>; private requestIdCounter; generateRequestId(): number; clearStore(options?: Cache.ResetOptions): Promise; getObservableQueries(include?: InternalRefetchQueriesInclude): Set>; refetchObservableQueries(includeStandby?: boolean): Promise[]>; startGraphQLSubscription(options: ApolloClient.SubscribeOptions): SubscriptionObservable>; broadcastQueries(): void; protected inFlightLinkObservables: Trie<{ observable?: Observable>; restart?: () => void; }>; private getObservableFromLink; private getResultsFromLink; fetchObservableWithInfo(options: ApolloClient.WatchQueryOptions, { networkStatus, query, fetchQueryOperator, onCacheHit, observableQuery, exposeExtensions, }: { networkStatus?: NetworkStatus; query?: DocumentNode; fetchQueryOperator?: (source: Observable) => Observable; onCacheHit?: () => void; observableQuery?: ObservableQuery | undefined; /** * Attach `extensions` to the result object so that it is accessible by * the calling code without being exposed to the emitted result. * * @remarks * Used by e.g. `fetchMore` to add `extensions` to the `cache.writeQuery` * call since it uses a `no-cache` query and cannot be written in * `QueryInfo`. */ exposeExtensions?: boolean; }): ObservableAndInfo; refetchQueries({ updateCache, include, optimistic, removeOptimistic, onQueryUpdated, }: InternalRefetchQueriesOptions): InternalRefetchQueriesMap; private noCacheWarningsByCause; maskOperation(options: MaskOperationOptions): MaybeMasked; maskFragment(options: MaskFragmentOptions): TData; private fetchQueryByPolicy; } interface ObservableAndInfo { fromLink: boolean; observable: Observable>; } export {}; //# sourceMappingURL=QueryManager.d.ts.map