1 | import { ReactNode } from 'react';
|
2 | import { DocumentNode } from 'graphql';
|
3 | import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
4 | import { Observable, ObservableSubscription } from '../../utilities';
|
5 | import { FetchResult } from '../../link/core';
|
6 | import { ApolloError } from '../../errors';
|
7 | import { ApolloCache, ApolloClient, DefaultContext, FetchPolicy, MutationOptions, NetworkStatus, ObservableQuery, OperationVariables, InternalRefetchQueriesInclude, WatchQueryOptions } from '../../core';
|
8 | export type { DefaultContext as Context } from "../../core";
|
9 | export type CommonOptions<TOptions> = TOptions & {
|
10 | client?: ApolloClient<object>;
|
11 | };
|
12 | export interface BaseQueryOptions<TVariables extends OperationVariables = OperationVariables> extends Omit<WatchQueryOptions<TVariables>, "query"> {
|
13 | ssr?: boolean;
|
14 | client?: ApolloClient<any>;
|
15 | context?: DefaultContext;
|
16 | }
|
17 | export interface QueryFunctionOptions<TData = any, TVariables extends OperationVariables = OperationVariables> extends BaseQueryOptions<TVariables> {
|
18 | skip?: boolean;
|
19 | onCompleted?: (data: TData) => void;
|
20 | onError?: (error: ApolloError) => void;
|
21 | defaultOptions?: Partial<WatchQueryOptions<TVariables, TData>>;
|
22 | }
|
23 | export type ObservableQueryFields<TData, TVariables extends OperationVariables> = Pick<ObservableQuery<TData, TVariables>, 'startPolling' | 'stopPolling' | 'subscribeToMore' | 'updateQuery' | 'refetch' | 'reobserve' | 'variables' | 'fetchMore'>;
|
24 | export interface QueryResult<TData = any, TVariables extends OperationVariables = OperationVariables> extends ObservableQueryFields<TData, TVariables> {
|
25 | client: ApolloClient<any>;
|
26 | observable: ObservableQuery<TData, TVariables>;
|
27 | data: TData | undefined;
|
28 | previousData?: TData;
|
29 | error?: ApolloError;
|
30 | loading: boolean;
|
31 | networkStatus: NetworkStatus;
|
32 | called: boolean;
|
33 | }
|
34 | export interface QueryDataOptions<TData = any, TVariables extends OperationVariables = OperationVariables> extends QueryFunctionOptions<TData, TVariables> {
|
35 | children?: (result: QueryResult<TData, TVariables>) => ReactNode;
|
36 | query: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
37 | }
|
38 | export interface QueryHookOptions<TData = any, TVariables extends OperationVariables = OperationVariables> extends QueryFunctionOptions<TData, TVariables> {
|
39 | query?: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
40 | }
|
41 | export interface LazyQueryHookOptions<TData = any, TVariables extends OperationVariables = OperationVariables> extends Omit<QueryHookOptions<TData, TVariables>, 'skip'> {
|
42 | }
|
43 | export interface QueryLazyOptions<TVariables> {
|
44 | variables?: TVariables;
|
45 | context?: DefaultContext;
|
46 | }
|
47 | export type LazyQueryResult<TData, TVariables extends OperationVariables> = QueryResult<TData, TVariables>;
|
48 | export type QueryTuple<TData, TVariables extends OperationVariables> = LazyQueryResultTuple<TData, TVariables>;
|
49 | export type LazyQueryExecFunction<TData, TVariables extends OperationVariables> = (options?: Partial<LazyQueryHookOptions<TData, TVariables>>) => Promise<QueryResult<TData, TVariables>>;
|
50 | export type LazyQueryResultTuple<TData, TVariables extends OperationVariables> = [
|
51 | LazyQueryExecFunction<TData, TVariables>,
|
52 | QueryResult<TData, TVariables>
|
53 | ];
|
54 | export type RefetchQueriesFunction = (...args: any[]) => InternalRefetchQueriesInclude;
|
55 | export interface BaseMutationOptions<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>> extends Omit<MutationOptions<TData, TVariables, TContext, TCache>, "mutation"> {
|
56 | client?: ApolloClient<object>;
|
57 | notifyOnNetworkStatusChange?: boolean;
|
58 | onCompleted?: (data: TData, clientOptions?: BaseMutationOptions) => void;
|
59 | onError?: (error: ApolloError, clientOptions?: BaseMutationOptions) => void;
|
60 | ignoreResults?: boolean;
|
61 | }
|
62 | export interface MutationFunctionOptions<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>> extends BaseMutationOptions<TData, TVariables, TContext, TCache> {
|
63 | mutation?: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
64 | }
|
65 | export interface MutationResult<TData = any> {
|
66 | data?: TData | null;
|
67 | error?: ApolloError;
|
68 | loading: boolean;
|
69 | called: boolean;
|
70 | client: ApolloClient<object>;
|
71 | reset(): void;
|
72 | }
|
73 | export declare type MutationFunction<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>> = (options?: MutationFunctionOptions<TData, TVariables, TContext, TCache>) => Promise<FetchResult<TData>>;
|
74 | export interface MutationHookOptions<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>> extends BaseMutationOptions<TData, TVariables, TContext, TCache> {
|
75 | mutation?: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
76 | }
|
77 | export interface MutationDataOptions<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>> extends BaseMutationOptions<TData, TVariables, TContext, TCache> {
|
78 | mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
79 | }
|
80 | export type MutationTuple<TData, TVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>> = [
|
81 | (options?: MutationFunctionOptions<TData, TVariables, TContext, TCache>) => Promise<FetchResult<TData>>,
|
82 | MutationResult<TData>
|
83 | ];
|
84 | export interface OnDataOptions<TData = any> {
|
85 | client: ApolloClient<object>;
|
86 | data: SubscriptionResult<TData>;
|
87 | }
|
88 | export interface OnSubscriptionDataOptions<TData = any> {
|
89 | client: ApolloClient<object>;
|
90 | subscriptionData: SubscriptionResult<TData>;
|
91 | }
|
92 | export interface BaseSubscriptionOptions<TData = any, TVariables extends OperationVariables = OperationVariables> {
|
93 | variables?: TVariables;
|
94 | fetchPolicy?: FetchPolicy;
|
95 | shouldResubscribe?: boolean | ((options: BaseSubscriptionOptions<TData, TVariables>) => boolean);
|
96 | client?: ApolloClient<object>;
|
97 | skip?: boolean;
|
98 | context?: DefaultContext;
|
99 | onComplete?: () => void;
|
100 | onData?: (options: OnDataOptions<TData>) => any;
|
101 | onSubscriptionData?: (options: OnSubscriptionDataOptions<TData>) => any;
|
102 | onError?: (error: ApolloError) => void;
|
103 | onSubscriptionComplete?: () => void;
|
104 | }
|
105 | export interface SubscriptionResult<TData = any, TVariables = any> {
|
106 | loading: boolean;
|
107 | data?: TData;
|
108 | error?: ApolloError;
|
109 | variables?: TVariables;
|
110 | }
|
111 | export interface SubscriptionHookOptions<TData = any, TVariables extends OperationVariables = OperationVariables> extends BaseSubscriptionOptions<TData, TVariables> {
|
112 | subscription?: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
113 | }
|
114 | export interface SubscriptionDataOptions<TData = any, TVariables extends OperationVariables = OperationVariables> extends BaseSubscriptionOptions<TData, TVariables> {
|
115 | subscription: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
116 | children?: null | ((result: SubscriptionResult<TData>) => JSX.Element | null);
|
117 | }
|
118 | export interface SubscriptionCurrentObservable {
|
119 | query?: Observable<any>;
|
120 | subscription?: ObservableSubscription;
|
121 | }
|
122 | //# sourceMappingURL=types.d.ts.map |
\ | No newline at end of file |