@apollo/client 4.2.0-alpha.1 → 4.2.0-alpha.2

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 (93) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/__cjs/core/ApolloClient.cjs +16 -3
  3. package/__cjs/core/ApolloClient.cjs.map +1 -1
  4. package/__cjs/core/ApolloClient.d.cts +180 -131
  5. package/__cjs/core/QueryManager.cjs.map +1 -1
  6. package/__cjs/core/defaultOptions.cjs +3 -0
  7. package/__cjs/core/defaultOptions.cjs.map +1 -0
  8. package/__cjs/core/defaultOptions.d.cts +90 -0
  9. package/__cjs/core/index.cjs.map +1 -1
  10. package/__cjs/core/index.d.cts +2 -1
  11. package/__cjs/react/hooks/useBackgroundQuery.cjs +3 -3
  12. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  13. package/__cjs/react/hooks/useBackgroundQuery.d.cts +254 -822
  14. package/__cjs/react/hooks/useLazyQuery.cjs +3 -5
  15. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  16. package/__cjs/react/hooks/useLazyQuery.d.cts +93 -146
  17. package/__cjs/react/hooks/useLoadableQuery.cjs +8 -4
  18. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  19. package/__cjs/react/hooks/useLoadableQuery.d.cts +105 -233
  20. package/__cjs/react/hooks/useQuery.cjs +5 -5
  21. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  22. package/__cjs/react/hooks/useQuery.d.cts +138 -308
  23. package/__cjs/react/hooks/useSuspenseQuery.cjs +3 -3
  24. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  25. package/__cjs/react/hooks/useSuspenseQuery.d.cts +147 -436
  26. package/__cjs/react/internal/cache/getSuspenseCache.cjs.map +1 -1
  27. package/__cjs/react/internal/cache/getSuspenseCache.d.cts +7 -0
  28. package/__cjs/utilities/internal/LazyType.cjs +3 -0
  29. package/__cjs/utilities/internal/LazyType.cjs.map +1 -0
  30. package/__cjs/utilities/internal/LazyType.d.cts +10 -0
  31. package/__cjs/utilities/internal/index.cjs.map +1 -1
  32. package/__cjs/utilities/internal/index.d.cts +3 -0
  33. package/__cjs/utilities/internal/types/OptionWithFallback.cjs +3 -0
  34. package/__cjs/utilities/internal/types/OptionWithFallback.cjs.map +1 -0
  35. package/__cjs/utilities/internal/types/OptionWithFallback.d.cts +5 -0
  36. package/__cjs/utilities/internal/types/SignatureStyle.cjs +3 -0
  37. package/__cjs/utilities/internal/types/SignatureStyle.cjs.map +1 -0
  38. package/__cjs/utilities/internal/types/SignatureStyle.d.cts +24 -0
  39. package/__cjs/version.cjs +1 -1
  40. package/core/ApolloClient.d.ts +180 -131
  41. package/core/ApolloClient.js +16 -3
  42. package/core/ApolloClient.js.map +1 -1
  43. package/core/QueryManager.js.map +1 -1
  44. package/core/defaultOptions.d.ts +90 -0
  45. package/core/defaultOptions.js +2 -0
  46. package/core/defaultOptions.js.map +1 -0
  47. package/core/index.d.ts +2 -1
  48. package/core/index.js.map +1 -1
  49. package/package.json +1 -1
  50. package/react/hooks/useBackgroundQuery.d.ts +254 -822
  51. package/react/hooks/useBackgroundQuery.js +2 -2
  52. package/react/hooks/useBackgroundQuery.js.map +1 -1
  53. package/react/hooks/useLazyQuery.d.ts +93 -146
  54. package/react/hooks/useLazyQuery.js +2 -4
  55. package/react/hooks/useLazyQuery.js.map +1 -1
  56. package/react/hooks/useLoadableQuery.d.ts +105 -233
  57. package/react/hooks/useLoadableQuery.js +7 -3
  58. package/react/hooks/useLoadableQuery.js.map +1 -1
  59. package/react/hooks/useQuery.d.ts +138 -308
  60. package/react/hooks/useQuery.js +2 -2
  61. package/react/hooks/useQuery.js.map +1 -1
  62. package/react/hooks/useSuspenseQuery.d.ts +147 -436
  63. package/react/hooks/useSuspenseQuery.js +2 -2
  64. package/react/hooks/useSuspenseQuery.js.map +1 -1
  65. package/react/hooks-compiled/useBackgroundQuery.d.ts +254 -822
  66. package/react/hooks-compiled/useBackgroundQuery.js +2 -2
  67. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  68. package/react/hooks-compiled/useLazyQuery.d.ts +93 -146
  69. package/react/hooks-compiled/useLazyQuery.js +2 -4
  70. package/react/hooks-compiled/useLazyQuery.js.map +1 -1
  71. package/react/hooks-compiled/useLoadableQuery.d.ts +105 -233
  72. package/react/hooks-compiled/useLoadableQuery.js +2 -2
  73. package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
  74. package/react/hooks-compiled/useQuery.d.ts +138 -308
  75. package/react/hooks-compiled/useQuery.js +2 -2
  76. package/react/hooks-compiled/useQuery.js.map +1 -1
  77. package/react/hooks-compiled/useSuspenseQuery.d.ts +147 -436
  78. package/react/hooks-compiled/useSuspenseQuery.js +2 -2
  79. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  80. package/react/internal/cache/getSuspenseCache.d.ts +7 -0
  81. package/react/internal/cache/getSuspenseCache.js.map +1 -1
  82. package/utilities/internal/LazyType.d.ts +10 -0
  83. package/utilities/internal/LazyType.js +2 -0
  84. package/utilities/internal/LazyType.js.map +1 -0
  85. package/utilities/internal/index.d.ts +3 -0
  86. package/utilities/internal/index.js.map +1 -1
  87. package/utilities/internal/types/OptionWithFallback.d.ts +5 -0
  88. package/utilities/internal/types/OptionWithFallback.js +2 -0
  89. package/utilities/internal/types/OptionWithFallback.js.map +1 -0
  90. package/utilities/internal/types/SignatureStyle.d.ts +24 -0
  91. package/utilities/internal/types/SignatureStyle.js +2 -0
  92. package/utilities/internal/types/SignatureStyle.js.map +1 -0
  93. package/version.js +1 -1
@@ -2,7 +2,7 @@ import type { ApolloClient, DataState, DefaultContext, DocumentNode, ErrorLike,
2
2
  import type { SubscribeToMoreFunction } from "@apollo/client";
3
3
  import { NetworkStatus } from "@apollo/client";
4
4
  import type { FetchMoreFunction, RefetchFunction } from "@apollo/client/react/internal";
5
- import type { DocumentationTypes as UtilityDocumentationTypes, NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
5
+ import type { DocumentationTypes as UtilityDocumentationTypes, NoInfer, OptionWithFallback, SignatureStyle, VariablesOption } from "@apollo/client/utilities/internal";
6
6
  import type { SkipToken } from "./constants.cjs";
7
7
  export declare namespace useSuspenseQuery {
8
8
  type FetchPolicy = Extract<WatchQueryFetchPolicy, "cache-first" | "network-only" | "no-cache" | "cache-and-network">;
@@ -172,6 +172,12 @@ export declare namespace useSuspenseQuery {
172
172
  }
173
173
  }
174
174
  type Result<TData = unknown, TVariables extends OperationVariables = OperationVariables, TStates extends DataState<TData>["dataState"] = DataState<TData>["dataState"]> = Base.Result<TData, TVariables> & GetDataState<MaybeMasked<TData>, TStates>;
175
+ interface DefaultOptions extends ApolloClient.DefaultOptions.WatchQuery.Calculated {
176
+ skip: false;
177
+ }
178
+ type ResultForOptions<TData, TVariables extends OperationVariables, TOptions extends Record<string, never> | Options<TVariables> | SkipToken> = Result<TData, TVariables, "complete" | "streaming" | (TOptions extends any ? TOptions extends SkipToken ? "empty" : (OptionWithFallback<TOptions, DefaultOptions, "errorPolicy"> extends "none" ? never : "empty") | (OptionWithFallback<TOptions, DefaultOptions, "skip"> extends (false) ? never : "empty") | (OptionWithFallback<TOptions, DefaultOptions, "returnPartialData"> extends false ? never : "partial") : never) | ([TOptions] extends [SkipToken] ? DefaultOptions extends {
179
+ returnPartialData: false;
180
+ } ? never : "partial" : never)>;
175
181
  namespace DocumentationTypes {
176
182
  namespace useSuspenseQuery {
177
183
  interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> extends Base.Result<TData, TVariables>, UtilityDocumentationTypes.DataState<TData> {
@@ -180,446 +186,151 @@ export declare namespace useSuspenseQuery {
180
186
  }
181
187
  namespace DocumentationTypes {
182
188
  /**
183
- * Test
184
- * For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
185
- *
186
- * @example
187
- *
188
- * ```jsx
189
- * import { Suspense } from "react";
190
- * import { useSuspenseQuery } from "@apollo/client";
191
- *
192
- * const listQuery = gql`
193
- * query {
194
- * list {
195
- * id
196
- * }
197
- * }
198
- * `;
199
- *
200
- * function App() {
201
- * return (
202
- * <Suspense fallback={<Spinner />}>
203
- * <List />
204
- * </Suspense>
205
- * );
206
- * }
207
- *
208
- * function List() {
209
- * const { data } = useSuspenseQuery(listQuery);
189
+ * For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
190
+ *
191
+ * @example
192
+ *
193
+ * ```jsx
194
+ * import { Suspense } from "react";
195
+ * import { useSuspenseQuery } from "@apollo/client";
196
+ *
197
+ * const listQuery = gql`
198
+ * query {
199
+ * list {
200
+ * id
201
+ * }
202
+ * }
203
+ * `;
204
+ *
205
+ * function App() {
206
+ * return (
207
+ * <Suspense fallback={<Spinner />}>
208
+ * <List />
209
+ * </Suspense>
210
+ * );
211
+ * }
212
+ *
213
+ * function List() {
214
+ * const { data } = useSuspenseQuery(listQuery);
215
+ *
216
+ * return (
217
+ * <ol>
218
+ * {data.list.map((item) => (
219
+ * <Item key={item.id} id={item.id} />
220
+ * ))}
221
+ * </ol>
222
+ * );
223
+ * }
224
+ * ```
225
+ *
226
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
227
+ * @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
228
+ */
229
+ interface useSuspenseQuery {
230
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: useSuspenseQuery.Options<TVariables>): useSuspenseQuery.Result<TData, TVariables>;
231
+ }
232
+ /**
233
+ * @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
234
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
235
+ */
236
+ interface useSuspenseQuery_Deprecated {
237
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: useSuspenseQuery.Options<TVariables>): useSuspenseQuery.Result<TData, TVariables>;
238
+ }
239
+ }
240
+ namespace Signatures {
241
+ /**
210
242
  *
211
- * return (
212
- * <ol>
213
- * {data.list.map((item) => (
214
- * <Item key={item.id} id={item.id} />
215
- * ))}
216
- * </ol>
217
- * );
218
- * }
219
- * ```
243
+ */
244
+ interface Classic {
245
+ /**
246
+ *
247
+ */
248
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
249
+ returnPartialData: true;
250
+ errorPolicy: "ignore" | "all";
251
+ }): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "partial" | "empty">;
252
+ /**
253
+ *
254
+ */
255
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
256
+ errorPolicy: "ignore" | "all";
257
+ }): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
258
+ /**
259
+ *
260
+ */
261
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
262
+ skip: boolean;
263
+ returnPartialData: true;
264
+ }): useSuspenseQuery.Result<TData, TVariables, "complete" | "empty" | "streaming" | "partial">;
265
+ /**
266
+ *
267
+ */
268
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
269
+ returnPartialData: true;
270
+ }): useSuspenseQuery.Result<TData, TVariables, "partial" | "streaming" | "complete">;
271
+ /**
272
+ *
273
+ */
274
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
275
+ skip: boolean;
276
+ }): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
277
+ /**
278
+ *
279
+ */
280
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useSuspenseQuery.Options<NoInfer<TVariables>> & {
281
+ returnPartialData: true;
282
+ })): useSuspenseQuery.Result<TData, TVariables, "empty" | "streaming" | "complete" | "partial">;
283
+ /**
284
+ *
285
+ */
286
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
287
+ options?: useSuspenseQuery.Options<NoInfer<TVariables>>
288
+ ] : [options: useSuspenseQuery.Options<NoInfer<TVariables>>]): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming">;
289
+ /**
290
+ *
291
+ */
292
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
293
+ options?: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>
294
+ ] : [options: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>]): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
295
+ /**
296
+ *
297
+ */
298
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
299
+ }
300
+ /**
220
301
  *
221
- * @param query - A GraphQL query document parsed into an AST by `gql`.
222
- * @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
223
302
  */
224
- function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: useSuspenseQuery.Options<TVariables>): useSuspenseQuery.Result<TData, TVariables>;
303
+ interface Modern {
304
+ /**
305
+ *
306
+ */
307
+ <TData, TVariables extends OperationVariables, Options extends never>(query: {} extends TVariables ? DocumentNode | TypedDocumentNode<TData, TVariables> : never): useSuspenseQuery.ResultForOptions<TData, TVariables, Record<string, never>>;
308
+ /**
309
+ *
310
+ */
311
+ <TData, TVariables extends OperationVariables, TOptions extends never>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, skipToken: SkipToken): useSuspenseQuery.ResultForOptions<TData, TVariables, SkipToken>;
312
+ /**
313
+ *
314
+ */
315
+ <TData, TVariables extends OperationVariables, TOptions extends useSuspenseQuery.Options<NoInfer<TVariables>> & VariablesOption<TVariables & {
316
+ [K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
317
+ }>>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [options?: TOptions] : [options: TOptions]): useSuspenseQuery.ResultForOptions<TData, TVariables, TOptions>;
318
+ /**
319
+ *
320
+ */
321
+ <TData, TVariables extends OperationVariables, TOptions extends useSuspenseQuery.Options<NoInfer<TVariables>> & VariablesOption<TVariables & {
322
+ [K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
323
+ }>>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [options?: TOptions | SkipToken] : [options: TOptions | SkipToken]): useSuspenseQuery.ResultForOptions<TData, TVariables, TOptions | SkipToken>;
324
+ }
325
+ type Evaluated = SignatureStyle extends "classic" ? Classic : Modern;
326
+ }
327
+ /**
328
+ *
329
+ */
330
+ interface Signature extends Signatures.Evaluated {
225
331
  }
226
332
  }
227
- /**
228
- * For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
229
- *
230
- * @example
231
- *
232
- * ```jsx
233
- * import { Suspense } from "react";
234
- * import { useSuspenseQuery } from "@apollo/client";
235
- *
236
- * const listQuery = gql`
237
- * query {
238
- * list {
239
- * id
240
- * }
241
- * }
242
- * `;
243
- *
244
- * function App() {
245
- * return (
246
- * <Suspense fallback={<Spinner />}>
247
- * <List />
248
- * </Suspense>
249
- * );
250
- * }
251
- *
252
- * function List() {
253
- * const { data } = useSuspenseQuery(listQuery);
254
- *
255
- * return (
256
- * <ol>
257
- * {data.list.map((item) => (
258
- * <Item key={item.id} id={item.id} />
259
- * ))}
260
- * </ol>
261
- * );
262
- * }
263
- * ```
264
- *
265
- * @param query - A GraphQL query document parsed into an AST by `gql`.
266
- * @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
267
- */
268
- export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
269
- returnPartialData: true;
270
- errorPolicy: "ignore" | "all";
271
- }): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "partial" | "empty">;
272
- /**
273
- * For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
274
- *
275
- * @example
276
- *
277
- * ```jsx
278
- * import { Suspense } from "react";
279
- * import { useSuspenseQuery } from "@apollo/client";
280
- *
281
- * const listQuery = gql`
282
- * query {
283
- * list {
284
- * id
285
- * }
286
- * }
287
- * `;
288
- *
289
- * function App() {
290
- * return (
291
- * <Suspense fallback={<Spinner />}>
292
- * <List />
293
- * </Suspense>
294
- * );
295
- * }
296
- *
297
- * function List() {
298
- * const { data } = useSuspenseQuery(listQuery);
299
- *
300
- * return (
301
- * <ol>
302
- * {data.list.map((item) => (
303
- * <Item key={item.id} id={item.id} />
304
- * ))}
305
- * </ol>
306
- * );
307
- * }
308
- * ```
309
- *
310
- * @param query - A GraphQL query document parsed into an AST by `gql`.
311
- * @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
312
- */
313
- export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
314
- errorPolicy: "ignore" | "all";
315
- }): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
316
- /**
317
- * For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
318
- *
319
- * @example
320
- *
321
- * ```jsx
322
- * import { Suspense } from "react";
323
- * import { useSuspenseQuery } from "@apollo/client";
324
- *
325
- * const listQuery = gql`
326
- * query {
327
- * list {
328
- * id
329
- * }
330
- * }
331
- * `;
332
- *
333
- * function App() {
334
- * return (
335
- * <Suspense fallback={<Spinner />}>
336
- * <List />
337
- * </Suspense>
338
- * );
339
- * }
340
- *
341
- * function List() {
342
- * const { data } = useSuspenseQuery(listQuery);
343
- *
344
- * return (
345
- * <ol>
346
- * {data.list.map((item) => (
347
- * <Item key={item.id} id={item.id} />
348
- * ))}
349
- * </ol>
350
- * );
351
- * }
352
- * ```
353
- *
354
- * @param query - A GraphQL query document parsed into an AST by `gql`.
355
- * @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
356
- */
357
- export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
358
- skip: boolean;
359
- returnPartialData: true;
360
- }): useSuspenseQuery.Result<TData, TVariables, "complete" | "empty" | "streaming" | "partial">;
361
- /**
362
- * For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
363
- *
364
- * @example
365
- *
366
- * ```jsx
367
- * import { Suspense } from "react";
368
- * import { useSuspenseQuery } from "@apollo/client";
369
- *
370
- * const listQuery = gql`
371
- * query {
372
- * list {
373
- * id
374
- * }
375
- * }
376
- * `;
377
- *
378
- * function App() {
379
- * return (
380
- * <Suspense fallback={<Spinner />}>
381
- * <List />
382
- * </Suspense>
383
- * );
384
- * }
385
- *
386
- * function List() {
387
- * const { data } = useSuspenseQuery(listQuery);
388
- *
389
- * return (
390
- * <ol>
391
- * {data.list.map((item) => (
392
- * <Item key={item.id} id={item.id} />
393
- * ))}
394
- * </ol>
395
- * );
396
- * }
397
- * ```
398
- *
399
- * @param query - A GraphQL query document parsed into an AST by `gql`.
400
- * @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
401
- */
402
- export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
403
- returnPartialData: true;
404
- }): useSuspenseQuery.Result<TData, TVariables, "partial" | "streaming" | "complete">;
405
- /**
406
- * For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
407
- *
408
- * @example
409
- *
410
- * ```jsx
411
- * import { Suspense } from "react";
412
- * import { useSuspenseQuery } from "@apollo/client";
413
- *
414
- * const listQuery = gql`
415
- * query {
416
- * list {
417
- * id
418
- * }
419
- * }
420
- * `;
421
- *
422
- * function App() {
423
- * return (
424
- * <Suspense fallback={<Spinner />}>
425
- * <List />
426
- * </Suspense>
427
- * );
428
- * }
429
- *
430
- * function List() {
431
- * const { data } = useSuspenseQuery(listQuery);
432
- *
433
- * return (
434
- * <ol>
435
- * {data.list.map((item) => (
436
- * <Item key={item.id} id={item.id} />
437
- * ))}
438
- * </ol>
439
- * );
440
- * }
441
- * ```
442
- *
443
- * @param query - A GraphQL query document parsed into an AST by `gql`.
444
- * @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
445
- */
446
- export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
447
- skip: boolean;
448
- }): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
449
- /**
450
- * For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
451
- *
452
- * @example
453
- *
454
- * ```jsx
455
- * import { Suspense } from "react";
456
- * import { useSuspenseQuery } from "@apollo/client";
457
- *
458
- * const listQuery = gql`
459
- * query {
460
- * list {
461
- * id
462
- * }
463
- * }
464
- * `;
465
- *
466
- * function App() {
467
- * return (
468
- * <Suspense fallback={<Spinner />}>
469
- * <List />
470
- * </Suspense>
471
- * );
472
- * }
473
- *
474
- * function List() {
475
- * const { data } = useSuspenseQuery(listQuery);
476
- *
477
- * return (
478
- * <ol>
479
- * {data.list.map((item) => (
480
- * <Item key={item.id} id={item.id} />
481
- * ))}
482
- * </ol>
483
- * );
484
- * }
485
- * ```
486
- *
487
- * @param query - A GraphQL query document parsed into an AST by `gql`.
488
- * @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
489
- */
490
- export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useSuspenseQuery.Options<NoInfer<TVariables>> & {
491
- returnPartialData: true;
492
- })): useSuspenseQuery.Result<TData, TVariables, "empty" | "streaming" | "complete" | "partial">;
493
- /**
494
- * For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
495
- *
496
- * @example
497
- *
498
- * ```jsx
499
- * import { Suspense } from "react";
500
- * import { useSuspenseQuery } from "@apollo/client";
501
- *
502
- * const listQuery = gql`
503
- * query {
504
- * list {
505
- * id
506
- * }
507
- * }
508
- * `;
509
- *
510
- * function App() {
511
- * return (
512
- * <Suspense fallback={<Spinner />}>
513
- * <List />
514
- * </Suspense>
515
- * );
516
- * }
517
- *
518
- * function List() {
519
- * const { data } = useSuspenseQuery(listQuery);
520
- *
521
- * return (
522
- * <ol>
523
- * {data.list.map((item) => (
524
- * <Item key={item.id} id={item.id} />
525
- * ))}
526
- * </ol>
527
- * );
528
- * }
529
- * ```
530
- *
531
- * @param query - A GraphQL query document parsed into an AST by `gql`.
532
- * @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
533
- */
534
- export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
535
- options?: useSuspenseQuery.Options<NoInfer<TVariables>>
536
- ] : [options: useSuspenseQuery.Options<NoInfer<TVariables>>]): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming">;
537
- /**
538
- * For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
539
- *
540
- * @example
541
- *
542
- * ```jsx
543
- * import { Suspense } from "react";
544
- * import { useSuspenseQuery } from "@apollo/client";
545
- *
546
- * const listQuery = gql`
547
- * query {
548
- * list {
549
- * id
550
- * }
551
- * }
552
- * `;
553
- *
554
- * function App() {
555
- * return (
556
- * <Suspense fallback={<Spinner />}>
557
- * <List />
558
- * </Suspense>
559
- * );
560
- * }
561
- *
562
- * function List() {
563
- * const { data } = useSuspenseQuery(listQuery);
564
- *
565
- * return (
566
- * <ol>
567
- * {data.list.map((item) => (
568
- * <Item key={item.id} id={item.id} />
569
- * ))}
570
- * </ol>
571
- * );
572
- * }
573
- * ```
574
- *
575
- * @param query - A GraphQL query document parsed into an AST by `gql`.
576
- * @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
577
- */
578
- export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
579
- options?: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>
580
- ] : [options: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>]): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
581
- /**
582
- * For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
583
- *
584
- * @example
585
- *
586
- * ```jsx
587
- * import { Suspense } from "react";
588
- * import { useSuspenseQuery } from "@apollo/client";
589
- *
590
- * const listQuery = gql`
591
- * query {
592
- * list {
593
- * id
594
- * }
595
- * }
596
- * `;
597
- *
598
- * function App() {
599
- * return (
600
- * <Suspense fallback={<Spinner />}>
601
- * <List />
602
- * </Suspense>
603
- * );
604
- * }
605
- *
606
- * function List() {
607
- * const { data } = useSuspenseQuery(listQuery);
608
- *
609
- * return (
610
- * <ol>
611
- * {data.list.map((item) => (
612
- * <Item key={item.id} id={item.id} />
613
- * ))}
614
- * </ol>
615
- * );
616
- * }
617
- * ```
618
- *
619
- * @param query - A GraphQL query document parsed into an AST by `gql`.
620
- * @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
621
- */
622
- export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
333
+ export declare const useSuspenseQuery: useSuspenseQuery.Signature;
623
334
  interface UseWatchQueryOptionsHookOptions<TData, TVariables extends OperationVariables> {
624
335
  client: ApolloClient;
625
336
  query: DocumentNode | TypedDocumentNode<TData, TVariables>;
@@ -1 +1 @@
1
- {"version":3,"file":"getSuspenseCache.cjs","sources":["../../../../../src/react/internal/cache/getSuspenseCache.ts"],"sourcesContent":["import type { ApolloClient } from \"@apollo/client\";\nimport type { SuspenseCacheOptions } from \"@apollo/client/react/internal\";\n\nimport { SuspenseCache } from \"./SuspenseCache.js\";\n\ndeclare module \"@apollo/client\" {\n namespace ApolloClient {\n interface DefaultOptions {\n react?: {\n suspense?: Readonly<SuspenseCacheOptions>;\n };\n }\n }\n}\n\nconst suspenseCacheSymbol = Symbol.for(\"apollo.suspenseCache\");\n\nexport function getSuspenseCache(\n client: ApolloClient & {\n [suspenseCacheSymbol]?: SuspenseCache;\n }\n) {\n if (!client[suspenseCacheSymbol]) {\n client[suspenseCacheSymbol] = new SuspenseCache(\n client.defaultOptions.react?.suspense\n );\n }\n\n return client[suspenseCacheSymbol];\n}\n"],"names":[],"mappings":";;AAiBA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAdA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,C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CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmD,CAC7C,CADN,CAAA,CAAA,CAAA,CAAA,CACY,CAAC,CADb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAC2B,CAAC,CAD5B,CAAA,CAAA,CAAA,CACiC,CADjC,CACmC,CADnC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAC2C,CACtC;IACH;IAEA,CAAF,CAAA,CAAA,CAAA,CAAA,EAAS,CAAT,CAAA,CAAA,CAAA,CAAA,CAAe,CAAC,CAAhB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmC,CAAC;AACpC;"}
1
+ {"version":3,"file":"getSuspenseCache.cjs","sources":["../../../../../src/react/internal/cache/getSuspenseCache.ts"],"sourcesContent":["import type { ApolloClient } from \"@apollo/client\";\nimport type { SuspenseCacheOptions } from \"@apollo/client/react/internal\";\n\nimport { SuspenseCache } from \"./SuspenseCache.js\";\n\ndeclare module \"@apollo/client\" {\n namespace ApolloClient {\n interface DefaultOptions {\n react?: {\n suspense?: Readonly<SuspenseCacheOptions>;\n };\n }\n namespace DefaultOptions {\n interface Input {\n react?: {\n suspense?: Readonly<SuspenseCacheOptions>;\n };\n }\n }\n }\n}\n\nconst suspenseCacheSymbol = Symbol.for(\"apollo.suspenseCache\");\n\nexport function getSuspenseCache(\n client: ApolloClient & {\n [suspenseCacheSymbol]?: SuspenseCache;\n }\n) {\n if (!client[suspenseCacheSymbol]) {\n client[suspenseCacheSymbol] = new SuspenseCache(\n client.defaultOptions.react?.suspense\n );\n }\n\n return client[suspenseCacheSymbol];\n}\n"],"names":[],"mappings":";;AAwBA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,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,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA8B,EAA9B,EAAkC,CAAlC,CAAA,EAAsC,CAAtC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmD,CAC7C,CADN,CAAA,CAAA,CAAA,CAAA,CACY,CAAC,CADb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAC2B,CAAC,CAD5B,CAAA,CAAA,CAAA,CACiC,CADjC,CACmC,CADnC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAC2C,CACtC;IACH;IAEA,CAAF,CAAA,CAAA,CAAA,CAAA,EAAS,CAAT,CAAA,CAAA,CAAA,CAAA,CAAe,CAAC,CAAhB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmC,CAAC;AACpC;"}
@@ -8,6 +8,13 @@ declare module "@apollo/client" {
8
8
  suspense?: Readonly<SuspenseCacheOptions>;
9
9
  };
10
10
  }
11
+ namespace DefaultOptions {
12
+ interface Input {
13
+ react?: {
14
+ suspense?: Readonly<SuspenseCacheOptions>;
15
+ };
16
+ }
17
+ }
11
18
  }
12
19
  }
13
20
  declare const suspenseCacheSymbol: unique symbol;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=LazyType.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LazyType.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This circular type (that never actually gets evaluated) is needed to prevent
3
+ * TypeScript from eagerly inlining the `ApolloClient.QueryResultForOptions`
4
+ * type, which would cause problems with global types getting evaluated
5
+ * on build of userland wrapping libraries, and not in the final userland project.
6
+ */
7
+ export type LazyType<T> = T & {
8
+ [K in "" as never]: LazyType<never>;
9
+ };
10
+ //# sourceMappingURL=LazyType.d.cts.map