@apollo/client 4.0.0-rc.3 → 4.0.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/__cjs/cache/core/cache.cjs +2 -6
  3. package/__cjs/cache/core/cache.cjs.map +1 -1
  4. package/__cjs/cache/core/cache.d.cts +42 -13
  5. package/__cjs/cache/inmemory/entityStore.cjs +3 -3
  6. package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
  7. package/__cjs/cache/inmemory/entityStore.d.cts +1 -1
  8. package/__cjs/cache/inmemory/inMemoryCache.cjs +1 -1
  9. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  10. package/__cjs/cache/inmemory/types.d.cts +1 -1
  11. package/__cjs/core/ApolloClient.cjs +45 -7
  12. package/__cjs/core/ApolloClient.cjs.map +1 -1
  13. package/__cjs/core/ApolloClient.d.cts +17 -4
  14. package/__cjs/core/ObservableQuery.cjs +40 -10
  15. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  16. package/__cjs/core/ObservableQuery.d.cts +73 -9
  17. package/__cjs/core/types.d.cts +87 -10
  18. package/__cjs/link/http/HttpLink.cjs.map +1 -1
  19. package/__cjs/link/http/HttpLink.d.cts +11 -1
  20. package/__cjs/react/hooks/useBackgroundQuery.d.cts +4 -0
  21. package/__cjs/react/hooks/useFragment.cjs +4 -5
  22. package/__cjs/react/hooks/useFragment.cjs.map +1 -1
  23. package/__cjs/react/hooks/useFragment.d.cts +4 -7
  24. package/__cjs/react/hooks/useLazyQuery.d.cts +5 -1
  25. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  26. package/__cjs/react/hooks/useLoadableQuery.d.cts +209 -10
  27. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  28. package/__cjs/react/hooks/useQuery.d.cts +270 -246
  29. package/__cjs/react/hooks/useQueryRefHandlers.d.cts +4 -0
  30. package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
  31. package/__cjs/react/hooks/useSubscription.d.cts +79 -62
  32. package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
  33. package/__cjs/react/hooks/useSuspenseFragment.d.cts +2 -2
  34. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  35. package/__cjs/react/hooks/useSuspenseQuery.d.cts +185 -161
  36. package/__cjs/react/index.cjs +1 -3
  37. package/__cjs/react/index.cjs.map +1 -1
  38. package/__cjs/react/index.d.cts +0 -1
  39. package/__cjs/react/internal/cache/FragmentReference.cjs +1 -1
  40. package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
  41. package/__cjs/react/types/types.documentation.d.cts +12 -1
  42. package/__cjs/utilities/internal/getStoreKeyName.cjs +8 -5
  43. package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
  44. package/__cjs/utilities/internal/index.cjs +4 -2
  45. package/__cjs/utilities/internal/index.cjs.map +1 -1
  46. package/__cjs/utilities/internal/index.d.cts +2 -0
  47. package/__cjs/utilities/internal/removeFragmentSpreads.cjs +14 -0
  48. package/__cjs/utilities/internal/removeFragmentSpreads.cjs.map +1 -0
  49. package/__cjs/utilities/internal/removeFragmentSpreads.d.cts +3 -0
  50. package/__cjs/utilities/internal/types/DocumentationTypes.cjs +3 -0
  51. package/__cjs/utilities/internal/types/DocumentationTypes.cjs.map +1 -0
  52. package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +82 -0
  53. package/__cjs/version.cjs +1 -1
  54. package/cache/core/cache.d.ts +42 -13
  55. package/cache/core/cache.js +2 -6
  56. package/cache/core/cache.js.map +1 -1
  57. package/cache/inmemory/entityStore.d.ts +1 -1
  58. package/cache/inmemory/entityStore.js +3 -3
  59. package/cache/inmemory/entityStore.js.map +1 -1
  60. package/cache/inmemory/inMemoryCache.js +1 -1
  61. package/cache/inmemory/inMemoryCache.js.map +1 -1
  62. package/cache/inmemory/types.d.ts +1 -1
  63. package/cache/inmemory/types.js.map +1 -1
  64. package/core/ApolloClient.d.ts +17 -4
  65. package/core/ApolloClient.js +46 -8
  66. package/core/ApolloClient.js.map +1 -1
  67. package/core/ObservableQuery.d.ts +73 -9
  68. package/core/ObservableQuery.js +40 -10
  69. package/core/ObservableQuery.js.map +1 -1
  70. package/core/types.d.ts +87 -10
  71. package/core/types.js.map +1 -1
  72. package/link/http/HttpLink.d.ts +11 -1
  73. package/link/http/HttpLink.js.map +1 -1
  74. package/package.json +1 -1
  75. package/react/hooks/useBackgroundQuery.d.ts +4 -0
  76. package/react/hooks/useFragment.d.ts +4 -7
  77. package/react/hooks/useFragment.js +4 -5
  78. package/react/hooks/useFragment.js.map +1 -1
  79. package/react/hooks/useLazyQuery.d.ts +5 -1
  80. package/react/hooks/useLoadableQuery.d.ts +209 -10
  81. package/react/hooks/useLoadableQuery.js.map +1 -1
  82. package/react/hooks/useQuery.d.ts +270 -246
  83. package/react/hooks/useQuery.js.map +1 -1
  84. package/react/hooks/useQueryRefHandlers.d.ts +4 -0
  85. package/react/hooks/useSubscription.d.ts +79 -62
  86. package/react/hooks/useSubscription.js.map +1 -1
  87. package/react/hooks/useSuspenseFragment.d.ts +2 -2
  88. package/react/hooks/useSuspenseFragment.js.map +1 -1
  89. package/react/hooks/useSuspenseQuery.d.ts +185 -161
  90. package/react/hooks/useSuspenseQuery.js.map +1 -1
  91. package/react/hooks-compiled/useBackgroundQuery.d.ts +4 -0
  92. package/react/hooks-compiled/useFragment.d.ts +4 -7
  93. package/react/hooks-compiled/useFragment.js +4 -5
  94. package/react/hooks-compiled/useFragment.js.map +1 -1
  95. package/react/hooks-compiled/useLazyQuery.d.ts +5 -1
  96. package/react/hooks-compiled/useLoadableQuery.d.ts +209 -10
  97. package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
  98. package/react/hooks-compiled/useQuery.d.ts +270 -246
  99. package/react/hooks-compiled/useQuery.js.map +1 -1
  100. package/react/hooks-compiled/useQueryRefHandlers.d.ts +4 -0
  101. package/react/hooks-compiled/useSubscription.d.ts +79 -62
  102. package/react/hooks-compiled/useSubscription.js.map +1 -1
  103. package/react/hooks-compiled/useSuspenseFragment.d.ts +2 -2
  104. package/react/hooks-compiled/useSuspenseFragment.js.map +1 -1
  105. package/react/hooks-compiled/useSuspenseQuery.d.ts +185 -161
  106. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  107. package/react/index.compiled.d.ts +0 -1
  108. package/react/index.compiled.js +0 -1
  109. package/react/index.compiled.js.map +1 -1
  110. package/react/index.d.ts +0 -1
  111. package/react/index.js +0 -1
  112. package/react/index.js.map +1 -1
  113. package/react/internal/cache/FragmentReference.js +1 -1
  114. package/react/internal/cache/FragmentReference.js.map +1 -1
  115. package/react/types/types.documentation.d.ts +12 -1
  116. package/react/types/types.documentation.js.map +1 -1
  117. package/utilities/internal/getStoreKeyName.js +8 -5
  118. package/utilities/internal/getStoreKeyName.js.map +1 -1
  119. package/utilities/internal/index.d.ts +2 -0
  120. package/utilities/internal/index.js +1 -0
  121. package/utilities/internal/index.js.map +1 -1
  122. package/utilities/internal/removeFragmentSpreads.d.ts +3 -0
  123. package/utilities/internal/removeFragmentSpreads.js +11 -0
  124. package/utilities/internal/removeFragmentSpreads.js.map +1 -0
  125. package/utilities/internal/types/DocumentationTypes.d.ts +82 -0
  126. package/utilities/internal/types/DocumentationTypes.js +2 -0
  127. package/utilities/internal/types/DocumentationTypes.js.map +1 -0
  128. package/version.js +1 -1
@@ -1,254 +1,278 @@
1
1
  import type { ApolloClient, ApolloQueryResult, DataState, DefaultContext, DocumentNode, ErrorLike, ErrorPolicy, FetchMoreOptions, GetDataState, ObservableQuery, OperationVariables, QueryResult, RefetchWritePolicy, SubscribeToMoreFunction, TypedDocumentNode, UpdateQueryMapFn, WatchQueryFetchPolicy, WatchQueryOptions } from "@apollo/client";
2
2
  import { NetworkStatus } from "@apollo/client";
3
3
  import type { MaybeMasked } from "@apollo/client/masking";
4
- import type { NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
4
+ import type { DocumentationTypes as UtilityDocumentationTypes, NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
5
5
  import type { NextFetchPolicyContext } from "../../core/watchQueryOptions.js";
6
6
  export declare namespace useQuery {
7
- type Options<TData = unknown, TVariables extends OperationVariables = OperationVariables> = {
8
- /**
9
- * Specifies how the query interacts with the Apollo Client cache during execution (for example, whether it checks the cache for results before sending a request to the server).
10
- *
11
- * For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).
12
- *
13
- * The default value is `cache-first`.
14
- *
15
- * @docGroup
16
- *
17
- * 3. Caching options
18
- */
19
- fetchPolicy?: WatchQueryFetchPolicy;
20
- /**
21
- * Specifies the `FetchPolicy` to be used after this query has completed.
22
- *
23
- * @docGroup
24
- *
25
- * 3. Caching options
26
- */
27
- nextFetchPolicy?: WatchQueryFetchPolicy | ((this: WatchQueryOptions<TVariables, TData>, currentFetchPolicy: WatchQueryFetchPolicy, context: NextFetchPolicyContext<TData, TVariables>) => WatchQueryFetchPolicy);
28
- /**
29
- * Defaults to the initial value of options.fetchPolicy, but can be explicitly configured to specify the WatchQueryFetchPolicy to revert back to whenever variables change (unless nextFetchPolicy intervenes).
30
- *
31
- * @docGroup
32
- *
33
- * 3. Caching options
34
- */
35
- initialFetchPolicy?: WatchQueryFetchPolicy;
36
- /**
37
- * Specifies whether a `NetworkStatus.refetch` operation should merge incoming field data with existing data, or overwrite the existing data. Overwriting is probably preferable, but merging is currently the default behavior, for backwards compatibility with Apollo Client 3.x.
38
- *
39
- * @docGroup
40
- *
41
- * 3. Caching options
42
- */
43
- refetchWritePolicy?: RefetchWritePolicy;
44
- /**
45
- * Specifies how the query handles a response that returns both GraphQL errors and partial results.
46
- *
47
- * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).
48
- *
49
- * The default value is `none`, meaning that the query result includes error details but not partial results.
50
- *
51
- * @docGroup
52
- *
53
- * 1. Operation options
54
- */
55
- errorPolicy?: ErrorPolicy;
56
- /**
57
- * Specifies the interval (in milliseconds) at which the query polls for updated results.
58
- *
59
- * The default value is `0` (no polling).
60
- *
61
- * @docGroup
62
- *
63
- * 2. Networking options
64
- */
65
- pollInterval?: number;
66
- /**
67
- * If `true`, the in-progress query's associated component re-renders whenever the network status changes or a network error occurs.
68
- *
69
- * The default value is `true`.
70
- *
71
- * @docGroup
72
- *
73
- * 2. Networking options
74
- */
75
- notifyOnNetworkStatusChange?: boolean;
76
- /**
77
- * If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.
78
- *
79
- * The default value is `false`.
80
- *
81
- * @docGroup
82
- *
83
- * 3. Caching options
84
- */
85
- returnPartialData?: boolean;
86
- /**
87
- * A callback function that's called whenever a refetch attempt occurs while polling. If the function returns `true`, the refetch is skipped and not reattempted until the next poll interval.
88
- *
89
- * @docGroup
90
- *
91
- * 2. Networking options
92
- */
93
- skipPollAttempt?: () => boolean;
94
- /**
95
- * Pass `false` to skip executing the query during [server-side rendering](https://www.apollographql.com/docs/react/performance/server-side-rendering/).
96
- *
97
- * @docGroup
98
- *
99
- * 2. Networking options
100
- */
101
- ssr?: boolean;
102
- /**
103
- * The instance of `ApolloClient` to use to execute the query.
104
- *
105
- * By default, the instance that's passed down via context is used, but you can provide a different instance here.
106
- *
107
- * @docGroup
108
- *
109
- * 1. Operation options
110
- */
111
- client?: ApolloClient;
112
- /**
113
- * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.
114
- *
115
- * @docGroup
116
- *
117
- * 2. Networking options
118
- */
119
- context?: DefaultContext;
120
- /**
121
- * If true, the query is not executed.
122
- *
123
- * The default value is `false`.
124
- *
125
- * @docGroup
126
- *
127
- * 1. Operation options
128
- */
129
- skip?: boolean;
130
- } & VariablesOption<TVariables>;
131
- type Result<TData = unknown, TVariables extends OperationVariables = OperationVariables, TStates extends DataState<TData>["dataState"] = DataState<TData>["dataState"]> = {
132
- /**
133
- * The instance of Apollo Client that executed the query. Can be useful for manually executing followup queries or writing data to the cache.
134
- *
135
- * @docGroup
136
- *
137
- * 2. Network info
138
- */
139
- client: ApolloClient;
140
- /**
141
- * A reference to the internal `ObservableQuery` used by the hook.
142
- */
143
- observable: ObservableQuery<TData, TVariables>;
144
- /**
145
- * An object containing the result from the most recent _previous_ execution of this query.
146
- *
147
- * This value is `undefined` if this is the query's first execution.
148
- *
149
- * @docGroup
150
- *
151
- * 1. Operation data
152
- */
153
- previousData?: MaybeMasked<TData>;
154
- /**
155
- * If the query produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.
156
- *
157
- * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
158
- *
159
- * @docGroup
160
- *
161
- * 1. Operation data
162
- */
163
- error?: ErrorLike;
164
- /**
165
- * If `true`, the query is still in flight and results have not yet been returned.
166
- *
167
- * @docGroup
168
- *
169
- * 2. Network info
170
- */
171
- loading: boolean;
172
- /**
173
- * A number indicating the current network state of the query's associated request. [See possible values.](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/core/networkStatus.ts#L4)
174
- *
175
- * Used in conjunction with the [`notifyOnNetworkStatusChange`](#notifyonnetworkstatuschange) option.
176
- *
177
- * @docGroup
178
- *
179
- * 2. Network info
180
- */
181
- networkStatus: NetworkStatus;
182
- /**
183
- * A function that instructs the query to begin re-executing at a specified interval (in milliseconds).
184
- *
185
- *
186
- * @docGroup
187
- *
188
- * 3. Helper functions
189
- */
190
- startPolling: (pollInterval: number) => void;
191
- /**
192
- * A function that instructs the query to stop polling after a previous call to `startPolling`.
193
- *
194
- *
195
- * @docGroup
196
- *
197
- * 3. Helper functions
198
- */
199
- stopPolling: () => void;
200
- /**
201
- * 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.
202
- *
203
- * This function returns _another_ function that you can call to terminate the subscription.
204
- *
205
- *
206
- * @docGroup
207
- *
208
- * 3. Helper functions
209
- */
210
- subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;
211
- /**
212
- * A function that enables you to update the query's cached result without executing a followup GraphQL operation.
213
- *
214
- * See [using updateQuery and updateFragment](https://www.apollographql.com/docs/react/caching/cache-interaction/#using-updatequery-and-updatefragment) for additional information.
215
- *
216
- *
217
- * @docGroup
218
- *
219
- * 3. Helper functions
220
- */
221
- updateQuery: (mapFn: UpdateQueryMapFn<TData, TVariables>) => void;
222
- /**
223
- * A function that enables you to re-execute the query, optionally passing in new `variables`.
224
- *
225
- * To guarantee that the refetch performs a network request, its `fetchPolicy` is set to `network-only` (unless the original query's `fetchPolicy` is `no-cache` or `cache-and-network`, which also guarantee a network request).
226
- *
227
- * See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching).
228
- *
229
- * @docGroup
230
- *
231
- * 3. Helper functions
232
- */
233
- refetch: (variables?: Partial<TVariables>) => Promise<QueryResult<MaybeMasked<TData>>>;
234
- /**
235
- * An object containing the variables that were provided for the query.
236
- *
237
- * @docGroup
238
- *
239
- * 1. Operation data
240
- */
241
- variables: TVariables;
242
- /**
243
- * 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/).
244
- *
245
- *
246
- * @docGroup
247
- *
248
- * 3. Helper functions
249
- */
250
- fetchMore: <TFetchData = TData, TFetchVars extends OperationVariables = TVariables>(fetchMoreOptions: FetchMoreOptions<TData, TVariables, TFetchData, TFetchVars>) => Promise<QueryResult<MaybeMasked<TFetchData>>>;
251
- } & GetDataState<MaybeMasked<TData>, TStates>;
7
+ namespace Base {
8
+ interface Options<TData = unknown, TVariables extends OperationVariables = OperationVariables> {
9
+ /**
10
+ * Specifies how the query interacts with the Apollo Client cache during execution (for example, whether it checks the cache for results before sending a request to the server).
11
+ *
12
+ * For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).
13
+ *
14
+ * The default value is `cache-first`.
15
+ *
16
+ * @docGroup
17
+ *
18
+ * 3. Caching options
19
+ */
20
+ fetchPolicy?: WatchQueryFetchPolicy;
21
+ /**
22
+ * Specifies the `FetchPolicy` to be used after this query has completed.
23
+ *
24
+ * @docGroup
25
+ *
26
+ * 3. Caching options
27
+ */
28
+ nextFetchPolicy?: WatchQueryFetchPolicy | ((this: WatchQueryOptions<TVariables, TData>, currentFetchPolicy: WatchQueryFetchPolicy, context: NextFetchPolicyContext<TData, TVariables>) => WatchQueryFetchPolicy);
29
+ /**
30
+ * Defaults to the initial value of options.fetchPolicy, but can be explicitly configured to specify the WatchQueryFetchPolicy to revert back to whenever variables change (unless nextFetchPolicy intervenes).
31
+ *
32
+ * @docGroup
33
+ *
34
+ * 3. Caching options
35
+ */
36
+ initialFetchPolicy?: WatchQueryFetchPolicy;
37
+ /**
38
+ * Specifies whether a `NetworkStatus.refetch` operation should merge incoming field data with existing data, or overwrite the existing data. Overwriting is probably preferable, but merging is currently the default behavior, for backwards compatibility with Apollo Client 3.x.
39
+ *
40
+ * @docGroup
41
+ *
42
+ * 3. Caching options
43
+ */
44
+ refetchWritePolicy?: RefetchWritePolicy;
45
+ /**
46
+ * Specifies how the query handles a response that returns both GraphQL errors and partial results.
47
+ *
48
+ * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).
49
+ *
50
+ * The default value is `none`, meaning that the query result includes error details but not partial results.
51
+ *
52
+ * @docGroup
53
+ *
54
+ * 1. Operation options
55
+ */
56
+ errorPolicy?: ErrorPolicy;
57
+ /**
58
+ * Specifies the interval (in milliseconds) at which the query polls for updated results.
59
+ *
60
+ * The default value is `0` (no polling).
61
+ *
62
+ * @docGroup
63
+ *
64
+ * 2. Networking options
65
+ */
66
+ pollInterval?: number;
67
+ /**
68
+ * If `true`, the in-progress query's associated component re-renders whenever the network status changes or a network error occurs.
69
+ *
70
+ * The default value is `true`.
71
+ *
72
+ * @docGroup
73
+ *
74
+ * 2. Networking options
75
+ */
76
+ notifyOnNetworkStatusChange?: boolean;
77
+ /**
78
+ * If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.
79
+ *
80
+ * The default value is `false`.
81
+ *
82
+ * @docGroup
83
+ *
84
+ * 3. Caching options
85
+ */
86
+ returnPartialData?: boolean;
87
+ /**
88
+ * A callback function that's called whenever a refetch attempt occurs while polling. If the function returns `true`, the refetch is skipped and not reattempted until the next poll interval.
89
+ *
90
+ * @docGroup
91
+ *
92
+ * 2. Networking options
93
+ */
94
+ skipPollAttempt?: () => boolean;
95
+ /**
96
+ * Pass `false` to skip executing the query during [server-side rendering](https://www.apollographql.com/docs/react/performance/server-side-rendering/).
97
+ *
98
+ * @docGroup
99
+ *
100
+ * 2. Networking options
101
+ */
102
+ ssr?: boolean;
103
+ /**
104
+ * The instance of `ApolloClient` to use to execute the query.
105
+ *
106
+ * By default, the instance that's passed down via context is used, but you can provide a different instance here.
107
+ *
108
+ * @docGroup
109
+ *
110
+ * 1. Operation options
111
+ */
112
+ client?: ApolloClient;
113
+ /**
114
+ * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.
115
+ *
116
+ * @docGroup
117
+ *
118
+ * 2. Networking options
119
+ */
120
+ context?: DefaultContext;
121
+ /**
122
+ * If true, the query is not executed.
123
+ *
124
+ * The default value is `false`.
125
+ *
126
+ * @docGroup
127
+ *
128
+ * 1. Operation options
129
+ */
130
+ skip?: boolean;
131
+ }
132
+ }
133
+ type Options<TData = unknown, TVariables extends OperationVariables = OperationVariables> = Base.Options<TData, TVariables> & VariablesOption<TVariables>;
134
+ namespace DocumentationTypes {
135
+ interface Options<TData = unknown, TVariables extends OperationVariables = OperationVariables> extends Base.Options<TData, TVariables> {
136
+ /**
137
+ * An object containing all of the GraphQL variables your query requires to execute.
138
+ *
139
+ * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.
140
+ *
141
+ * @docGroup
142
+ *
143
+ * 1. Operation options
144
+ */
145
+ variables?: TVariables;
146
+ }
147
+ }
148
+ namespace Base {
149
+ interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> {
150
+ /**
151
+ * The instance of Apollo Client that executed the query. Can be useful for manually executing followup queries or writing data to the cache.
152
+ *
153
+ * @docGroup
154
+ *
155
+ * 2. Network info
156
+ */
157
+ client: ApolloClient;
158
+ /**
159
+ * A reference to the internal `ObservableQuery` used by the hook.
160
+ */
161
+ observable: ObservableQuery<TData, TVariables>;
162
+ /**
163
+ * An object containing the result from the most recent _previous_ execution of this query.
164
+ *
165
+ * This value is `undefined` if this is the query's first execution.
166
+ *
167
+ * @docGroup
168
+ *
169
+ * 1. Operation data
170
+ */
171
+ previousData?: MaybeMasked<TData>;
172
+ /**
173
+ * A single ErrorLike object describing the error that occured during the latest query execution.
174
+ *
175
+ * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
176
+ *
177
+ * @docGroup
178
+ *
179
+ * 1. Operation data
180
+ */
181
+ error?: ErrorLike;
182
+ /**
183
+ * If `true`, the query is still in flight and results have not yet been returned.
184
+ *
185
+ * @docGroup
186
+ *
187
+ * 2. Network info
188
+ */
189
+ loading: boolean;
190
+ /**
191
+ * A number indicating the current network state of the query's associated request. [See possible values.](https://github.com/apollographql/apollo-client/blob/d96f4578f89b933c281bb775a39503f6cdb59ee8/src/core/networkStatus.ts#L4)
192
+ *
193
+ * Used in conjunction with the [`notifyOnNetworkStatusChange`](#notifyonnetworkstatuschange) option.
194
+ *
195
+ * @docGroup
196
+ *
197
+ * 2. Network info
198
+ */
199
+ networkStatus: NetworkStatus;
200
+ /**
201
+ * A function that instructs the query to begin re-executing at a specified interval (in milliseconds).
202
+ *
203
+ *
204
+ * @docGroup
205
+ *
206
+ * 3. Helper functions
207
+ */
208
+ startPolling: (pollInterval: number) => void;
209
+ /**
210
+ * A function that instructs the query to stop polling after a previous call to `startPolling`.
211
+ *
212
+ *
213
+ * @docGroup
214
+ *
215
+ * 3. Helper functions
216
+ */
217
+ stopPolling: () => void;
218
+ /**
219
+ * 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.
220
+ *
221
+ * This function returns _another_ function that you can call to terminate the subscription.
222
+ *
223
+ *
224
+ * @docGroup
225
+ *
226
+ * 3. Helper functions
227
+ */
228
+ subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;
229
+ /**
230
+ * A function that enables you to update the query's cached result without executing a followup GraphQL operation.
231
+ *
232
+ * See [using updateQuery and updateFragment](https://www.apollographql.com/docs/react/caching/cache-interaction/#using-updatequery-and-updatefragment) for additional information.
233
+ *
234
+ *
235
+ * @docGroup
236
+ *
237
+ * 3. Helper functions
238
+ */
239
+ updateQuery: (mapFn: UpdateQueryMapFn<TData, TVariables>) => void;
240
+ /**
241
+ * A function that enables you to re-execute the query, optionally passing in new `variables`.
242
+ *
243
+ * To guarantee that the refetch performs a network request, its `fetchPolicy` is set to `network-only` (unless the original query's `fetchPolicy` is `no-cache` or `cache-and-network`, which also guarantee a network request).
244
+ *
245
+ * See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching).
246
+ *
247
+ * @docGroup
248
+ *
249
+ * 3. Helper functions
250
+ */
251
+ refetch: (variables?: Partial<TVariables>) => Promise<QueryResult<MaybeMasked<TData>>>;
252
+ /**
253
+ * An object containing the variables that were provided for the query.
254
+ *
255
+ * @docGroup
256
+ *
257
+ * 1. Operation data
258
+ */
259
+ variables: TVariables;
260
+ /**
261
+ * 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/).
262
+ *
263
+ *
264
+ * @docGroup
265
+ *
266
+ * 3. Helper functions
267
+ */
268
+ fetchMore: <TFetchData = TData, TFetchVars extends OperationVariables = TVariables>(fetchMoreOptions: FetchMoreOptions<TData, TVariables, TFetchData, TFetchVars>) => Promise<QueryResult<MaybeMasked<TFetchData>>>;
269
+ }
270
+ }
271
+ type Result<TData = unknown, TVariables extends OperationVariables = OperationVariables, TStates extends DataState<TData>["dataState"] = DataState<TData>["dataState"]> = Base.Result<TData, TVariables> & GetDataState<MaybeMasked<TData>, TStates>;
272
+ namespace DocumentationTypes {
273
+ interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> extends Base.Result<TData, TVariables>, UtilityDocumentationTypes.DataState<TData> {
274
+ }
275
+ }
252
276
  }
253
277
  export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
254
278
  returnPartialData: true;