UNPKG

5.52 kBTypeScriptView Raw
1import type { ApolloClient, ApolloQueryResult, DocumentNode, OperationVariables, TypedDocumentNode, FetchMoreQueryOptions, WatchQueryOptions } from "../../core/index.js";
2import { ApolloError, NetworkStatus } from "../../core/index.js";
3import type { DeepPartial } from "../../utilities/index.js";
4import type { SuspenseQueryHookOptions, ObservableQueryFields, NoInfer } from "../types/types.js";
5import type { SkipToken } from "./constants.js";
6export interface UseSuspenseQueryResult<TData = unknown, TVariables extends OperationVariables = OperationVariables> {
7 client: ApolloClient<any>;
8 data: TData;
9 error: ApolloError | undefined;
10 fetchMore: FetchMoreFunction<TData, TVariables>;
11 networkStatus: NetworkStatus;
12 refetch: RefetchFunction<TData, TVariables>;
13 subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;
14}
15export type FetchMoreFunction<TData, TVariables extends OperationVariables> = (fetchMoreOptions: FetchMoreQueryOptions<TVariables, TData> & {
16 updateQuery?: (previousQueryResult: TData, options: {
17 fetchMoreResult: TData;
18 variables: TVariables;
19 }) => TData;
20}) => Promise<ApolloQueryResult<TData>>;
21export type RefetchFunction<TData, TVariables extends OperationVariables> = ObservableQueryFields<TData, TVariables>["refetch"];
22export type SubscribeToMoreFunction<TData, TVariables extends OperationVariables> = ObservableQueryFields<TData, TVariables>["subscribeToMore"];
23export declare function useSuspenseQuery<TData, TVariables extends OperationVariables, TOptions extends Omit<SuspenseQueryHookOptions<TData>, "variables">>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & TOptions): UseSuspenseQueryResult<TOptions["errorPolicy"] extends "ignore" | "all" ? TOptions["returnPartialData"] extends true ? DeepPartial<TData> | undefined : TData | undefined : TOptions["returnPartialData"] extends true ? TOptions["skip"] extends boolean ? DeepPartial<TData> | undefined : DeepPartial<TData> : TOptions["skip"] extends boolean ? TData | undefined : TData, TVariables>;
24export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {
25 returnPartialData: true;
26 errorPolicy: "ignore" | "all";
27}): UseSuspenseQueryResult<DeepPartial<TData> | undefined, TVariables>;
28export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {
29 errorPolicy: "ignore" | "all";
30}): UseSuspenseQueryResult<TData | undefined, TVariables>;
31export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {
32 skip: boolean;
33 returnPartialData: true;
34}): UseSuspenseQueryResult<DeepPartial<TData> | undefined, TVariables>;
35export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {
36 returnPartialData: true;
37}): UseSuspenseQueryResult<DeepPartial<TData>, TVariables>;
38export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {
39 skip: boolean;
40}): UseSuspenseQueryResult<TData | undefined, TVariables>;
41export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>): UseSuspenseQueryResult<TData, TVariables>;
42export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {
43 returnPartialData: true;
44})): UseSuspenseQueryResult<DeepPartial<TData> | undefined, TVariables>;
45export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: SkipToken | SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>): UseSuspenseQueryResult<TData | undefined, TVariables>;
46export declare function toApolloError(result: ApolloQueryResult<any>): ApolloError | undefined;
47interface UseWatchQueryOptionsHookOptions<TData, TVariables extends OperationVariables> {
48 client: ApolloClient<unknown>;
49 query: DocumentNode | TypedDocumentNode<TData, TVariables>;
50 options: SkipToken | SuspenseQueryHookOptions<TData, TVariables>;
51}
52export declare function useWatchQueryOptions<TData, TVariables extends OperationVariables>({ client, query, options, }: UseWatchQueryOptionsHookOptions<TData, TVariables>): WatchQueryOptions<TVariables, TData>;
53export {};
54//# sourceMappingURL=useSuspenseQuery.d.ts.map
\No newline at end of file