UNPKG

5.71 kBTypeScriptView Raw
1import type { DocumentNode, OperationVariables, TypedDocumentNode } from "../../core/index.js";
2import type { QueryRef } from "../internal/index.js";
3import type { BackgroundQueryHookOptions, NoInfer } from "../types/types.js";
4import type { FetchMoreFunction, RefetchFunction, SubscribeToMoreFunction } from "./useSuspenseQuery.js";
5import type { DeepPartial } from "../../utilities/index.js";
6import type { SkipToken } from "./constants.js";
7export type UseBackgroundQueryResult<TData = unknown, TVariables extends OperationVariables = OperationVariables> = {
8 /**
9 * A function that enables you to execute a [subscription](https://www.apollographql.com/docs/react/data/subscriptions/), usually to subscribe to specific fields that were included in the query.
10 *
11 * This function returns _another_ function that you can call to terminate the subscription.
12 */
13 subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;
14 /**
15 * A function that helps you fetch the next set of results for a [paginated list field](https://www.apollographql.com/docs/react/pagination/core-api/).
16 */
17 fetchMore: FetchMoreFunction<TData, TVariables>;
18 /**
19 * Update the variables of this observable query, and fetch the new results. This method should be preferred over `setVariables` in most use cases.
20 *
21 * @param variables - The new set of variables. If there are missing variables, the previous values of those variables will be used.
22 */
23 refetch: RefetchFunction<TData, TVariables>;
24};
25type BackgroundQueryHookOptionsNoInfer<TData, TVariables extends OperationVariables> = BackgroundQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>;
26export declare function useBackgroundQuery<TData, TVariables extends OperationVariables, TOptions extends Omit<BackgroundQueryHookOptions<TData>, "variables">>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: BackgroundQueryHookOptionsNoInfer<TData, TVariables> & TOptions): [
27 (QueryRef<TOptions["errorPolicy"] extends "ignore" | "all" ? TOptions["returnPartialData"] extends true ? DeepPartial<TData> | undefined : TData | undefined : TOptions["returnPartialData"] extends true ? DeepPartial<TData> : TData, TVariables> | (TOptions["skip"] extends boolean ? undefined : never)),
28 UseBackgroundQueryResult<TData, TVariables>
29];
30export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: BackgroundQueryHookOptionsNoInfer<TData, TVariables> & {
31 returnPartialData: true;
32 errorPolicy: "ignore" | "all";
33}): [
34 QueryRef<DeepPartial<TData> | undefined, TVariables>,
35 UseBackgroundQueryResult<TData, TVariables>
36];
37export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: BackgroundQueryHookOptionsNoInfer<TData, TVariables> & {
38 errorPolicy: "ignore" | "all";
39}): [
40 QueryRef<TData | undefined, TVariables>,
41 UseBackgroundQueryResult<TData, TVariables>
42];
43export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: BackgroundQueryHookOptionsNoInfer<TData, TVariables> & {
44 skip: boolean;
45 returnPartialData: true;
46}): [
47 QueryRef<DeepPartial<TData>, TVariables> | undefined,
48 UseBackgroundQueryResult<TData, TVariables>
49];
50export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: BackgroundQueryHookOptionsNoInfer<TData, TVariables> & {
51 returnPartialData: true;
52}): [
53 QueryRef<DeepPartial<TData>, TVariables>,
54 UseBackgroundQueryResult<TData, TVariables>
55];
56export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: BackgroundQueryHookOptionsNoInfer<TData, TVariables> & {
57 skip: boolean;
58}): [
59 QueryRef<TData, TVariables> | undefined,
60 UseBackgroundQueryResult<TData, TVariables>
61];
62export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: BackgroundQueryHookOptionsNoInfer<TData, TVariables>): [QueryRef<TData, TVariables>, UseBackgroundQueryResult<TData, TVariables>];
63export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): [undefined, UseBackgroundQueryResult<TData, TVariables>];
64export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (BackgroundQueryHookOptionsNoInfer<TData, TVariables> & {
65 returnPartialData: true;
66})): [
67 QueryRef<DeepPartial<TData>, TVariables> | undefined,
68 UseBackgroundQueryResult<TData, TVariables>
69];
70export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: SkipToken | BackgroundQueryHookOptionsNoInfer<TData, TVariables>): [
71 QueryRef<TData, TVariables> | undefined,
72 UseBackgroundQueryResult<TData, TVariables>
73];
74export {};
75//# sourceMappingURL=useBackgroundQuery.d.ts.map
\No newline at end of file