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

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 (131) hide show
  1. package/CHANGELOG.md +209 -0
  2. package/__cjs/core/ApolloClient.cjs +25 -12
  3. package/__cjs/core/ApolloClient.cjs.map +1 -1
  4. package/__cjs/core/ApolloClient.d.cts +305 -146
  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/link/ws/index.cjs +9 -1
  12. package/__cjs/link/ws/index.cjs.map +1 -1
  13. package/__cjs/link/ws/index.d.cts +1 -1
  14. package/__cjs/react/hooks/useBackgroundQuery.cjs +3 -3
  15. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  16. package/__cjs/react/hooks/useBackgroundQuery.d.cts +1598 -765
  17. package/__cjs/react/hooks/useLazyQuery.cjs +3 -5
  18. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  19. package/__cjs/react/hooks/useLazyQuery.d.cts +369 -115
  20. package/__cjs/react/hooks/useLoadableQuery.cjs +8 -4
  21. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  22. package/__cjs/react/hooks/useLoadableQuery.d.cts +507 -192
  23. package/__cjs/react/hooks/useMutation.cjs +5 -48
  24. package/__cjs/react/hooks/useMutation.cjs.map +1 -1
  25. package/__cjs/react/hooks/useMutation.d.cts +239 -130
  26. package/__cjs/react/hooks/useQuery.cjs +5 -5
  27. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  28. package/__cjs/react/hooks/useQuery.d.cts +636 -276
  29. package/__cjs/react/hooks/useSubscription.cjs +1 -1
  30. package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
  31. package/__cjs/react/hooks/useSubscription.d.cts +2 -2
  32. package/__cjs/react/hooks/useSuspenseQuery.cjs +3 -3
  33. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  34. package/__cjs/react/hooks/useSuspenseQuery.d.cts +799 -399
  35. package/__cjs/react/internal/cache/getSuspenseCache.cjs.map +1 -1
  36. package/__cjs/react/internal/cache/getSuspenseCache.d.cts +7 -0
  37. package/__cjs/utilities/internal/LazyType.cjs +3 -0
  38. package/__cjs/utilities/internal/LazyType.cjs.map +1 -0
  39. package/__cjs/utilities/internal/LazyType.d.cts +10 -0
  40. package/__cjs/utilities/internal/index.cjs.map +1 -1
  41. package/__cjs/utilities/internal/index.d.cts +3 -0
  42. package/__cjs/utilities/internal/types/OptionWithFallback.cjs +3 -0
  43. package/__cjs/utilities/internal/types/OptionWithFallback.cjs.map +1 -0
  44. package/__cjs/utilities/internal/types/OptionWithFallback.d.cts +5 -0
  45. package/__cjs/utilities/internal/types/SignatureStyle.cjs +3 -0
  46. package/__cjs/utilities/internal/types/SignatureStyle.cjs.map +1 -0
  47. package/__cjs/utilities/internal/types/SignatureStyle.d.cts +24 -0
  48. package/__cjs/version.cjs +1 -1
  49. package/core/ApolloClient.d.ts +305 -146
  50. package/core/ApolloClient.js +25 -12
  51. package/core/ApolloClient.js.map +1 -1
  52. package/core/QueryManager.js.map +1 -1
  53. package/core/defaultOptions.d.ts +90 -0
  54. package/core/defaultOptions.js +2 -0
  55. package/core/defaultOptions.js.map +1 -0
  56. package/core/index.d.ts +2 -1
  57. package/core/index.js.map +1 -1
  58. package/link/ws/index.d.ts +1 -1
  59. package/link/ws/index.js +9 -1
  60. package/link/ws/index.js.map +1 -1
  61. package/package.json +3 -7
  62. package/react/hooks/useBackgroundQuery.d.ts +1598 -765
  63. package/react/hooks/useBackgroundQuery.js +2 -2
  64. package/react/hooks/useBackgroundQuery.js.map +1 -1
  65. package/react/hooks/useLazyQuery.d.ts +369 -115
  66. package/react/hooks/useLazyQuery.js +2 -4
  67. package/react/hooks/useLazyQuery.js.map +1 -1
  68. package/react/hooks/useLoadableQuery.d.ts +507 -192
  69. package/react/hooks/useLoadableQuery.js +7 -3
  70. package/react/hooks/useLoadableQuery.js.map +1 -1
  71. package/react/hooks/useMutation.d.ts +239 -130
  72. package/react/hooks/useMutation.js +5 -48
  73. package/react/hooks/useMutation.js.map +1 -1
  74. package/react/hooks/useQuery.d.ts +636 -276
  75. package/react/hooks/useQuery.js +2 -2
  76. package/react/hooks/useQuery.js.map +1 -1
  77. package/react/hooks/useSubscription.d.ts +2 -2
  78. package/react/hooks/useSubscription.js +1 -1
  79. package/react/hooks/useSubscription.js.map +1 -1
  80. package/react/hooks/useSuspenseQuery.d.ts +799 -399
  81. package/react/hooks/useSuspenseQuery.js +2 -2
  82. package/react/hooks/useSuspenseQuery.js.map +1 -1
  83. package/react/hooks-compiled/useBackgroundQuery.d.ts +1598 -765
  84. package/react/hooks-compiled/useBackgroundQuery.js +2 -2
  85. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  86. package/react/hooks-compiled/useLazyQuery.d.ts +369 -115
  87. package/react/hooks-compiled/useLazyQuery.js +2 -4
  88. package/react/hooks-compiled/useLazyQuery.js.map +1 -1
  89. package/react/hooks-compiled/useLoadableQuery.d.ts +507 -192
  90. package/react/hooks-compiled/useLoadableQuery.js +2 -2
  91. package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
  92. package/react/hooks-compiled/useMutation.d.ts +239 -130
  93. package/react/hooks-compiled/useMutation.js +4 -47
  94. package/react/hooks-compiled/useMutation.js.map +1 -1
  95. package/react/hooks-compiled/useQuery.d.ts +636 -276
  96. package/react/hooks-compiled/useQuery.js +2 -2
  97. package/react/hooks-compiled/useQuery.js.map +1 -1
  98. package/react/hooks-compiled/useSubscription.d.ts +2 -2
  99. package/react/hooks-compiled/useSubscription.js +1 -1
  100. package/react/hooks-compiled/useSubscription.js.map +1 -1
  101. package/react/hooks-compiled/useSuspenseQuery.d.ts +799 -399
  102. package/react/hooks-compiled/useSuspenseQuery.js +2 -2
  103. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  104. package/react/internal/cache/getSuspenseCache.d.ts +7 -0
  105. package/react/internal/cache/getSuspenseCache.js.map +1 -1
  106. package/skills/apollo-client/SKILL.md +168 -0
  107. package/skills/apollo-client/references/caching.md +560 -0
  108. package/skills/apollo-client/references/error-handling.md +350 -0
  109. package/skills/apollo-client/references/fragments.md +804 -0
  110. package/skills/apollo-client/references/integration-client.md +336 -0
  111. package/skills/apollo-client/references/integration-nextjs.md +325 -0
  112. package/skills/apollo-client/references/integration-react-router.md +256 -0
  113. package/skills/apollo-client/references/integration-tanstack-start.md +378 -0
  114. package/skills/apollo-client/references/mutations.md +549 -0
  115. package/skills/apollo-client/references/queries.md +416 -0
  116. package/skills/apollo-client/references/state-management.md +428 -0
  117. package/skills/apollo-client/references/suspense-hooks.md +773 -0
  118. package/skills/apollo-client/references/troubleshooting.md +487 -0
  119. package/skills/apollo-client/references/typescript-codegen.md +133 -0
  120. package/utilities/internal/LazyType.d.ts +10 -0
  121. package/utilities/internal/LazyType.js +2 -0
  122. package/utilities/internal/LazyType.js.map +1 -0
  123. package/utilities/internal/index.d.ts +3 -0
  124. package/utilities/internal/index.js.map +1 -1
  125. package/utilities/internal/types/OptionWithFallback.d.ts +5 -0
  126. package/utilities/internal/types/OptionWithFallback.js +2 -0
  127. package/utilities/internal/types/OptionWithFallback.js.map +1 -0
  128. package/utilities/internal/types/SignatureStyle.d.ts +24 -0
  129. package/utilities/internal/types/SignatureStyle.js +2 -0
  130. package/utilities/internal/types/SignatureStyle.js.map +1 -0
  131. package/version.js +1 -1
@@ -2,6 +2,7 @@ import type { ApolloClient, DataState, DefaultContext, DocumentNode, ErrorPolicy
2
2
  import type { SubscribeToMoreFunction } from "@apollo/client";
3
3
  import type { QueryRef } from "@apollo/client/react";
4
4
  import type { FetchMoreFunction, RefetchFunction } from "@apollo/client/react/internal";
5
+ import type { OptionWithFallback, SignatureStyle } from "@apollo/client/utilities/internal";
5
6
  type ResetFunction = () => void;
6
7
  export declare namespace useLoadableQuery {
7
8
  type LoadQueryFunction<TVariables extends OperationVariables> = (...args: {} extends TVariables ? [variables?: TVariables] : [variables: TVariables]) => void;
@@ -109,7 +110,370 @@ export declare namespace useLoadableQuery {
109
110
  */
110
111
  returnPartialData?: boolean;
111
112
  }
113
+ interface DefaultOptions extends ApolloClient.DefaultOptions.WatchQuery.Calculated {
114
+ }
115
+ type ResultForOptions<TData, TVariables extends OperationVariables, TOptions extends Record<string, never> | Options> = Result<TData, TVariables, "complete" | "streaming" | (OptionWithFallback<TOptions, DefaultOptions, "errorPolicy"> extends ("none") ? never : "empty") | (OptionWithFallback<TOptions, DefaultOptions, "returnPartialData"> extends false ? never : "partial")>;
112
116
  namespace DocumentationTypes {
117
+ interface useLoadableQuery {
118
+ /**
119
+ * A hook for imperatively loading a query, such as responding to a user
120
+ * interaction.
121
+ *
122
+ * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.
123
+ *
124
+ * @example
125
+ *
126
+ * ```jsx
127
+ * import { gql, useLoadableQuery } from "@apollo/client";
128
+ *
129
+ * const GET_GREETING = gql`
130
+ * query GetGreeting($language: String!) {
131
+ * greeting(language: $language) {
132
+ * message
133
+ * }
134
+ * }
135
+ * `;
136
+ *
137
+ * function App() {
138
+ * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);
139
+ *
140
+ * return (
141
+ * <>
142
+ * <button onClick={() => loadGreeting({ language: "english" })}>
143
+ * Load greeting
144
+ * </button>
145
+ * <Suspense fallback={<div>Loading...</div>}>
146
+ * {queryRef && <Hello queryRef={queryRef} />}
147
+ * </Suspense>
148
+ * </>
149
+ * );
150
+ * }
151
+ *
152
+ * function Hello({ queryRef }) {
153
+ * const { data } = useReadQuery(queryRef);
154
+ *
155
+ * return <div>{data.greeting.message}</div>;
156
+ * }
157
+ * ```
158
+ *
159
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
160
+ * @param options - Options to control how the query is executed.
161
+ * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
162
+ */
163
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useLoadableQuery.Options): useLoadableQuery.Result<TData, TVariables>;
164
+ }
165
+ interface useLoadableQuery_Deprecated {
166
+ /**
167
+ * @deprecated Avoid manually specifying generics on `useLoadableQuery`.
168
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
169
+ *
170
+ *
171
+ * A hook for imperatively loading a query, such as responding to a user
172
+ * interaction.
173
+ *
174
+ * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.
175
+ *
176
+ * @example
177
+ *
178
+ * ```jsx
179
+ * import { gql, useLoadableQuery } from "@apollo/client";
180
+ *
181
+ * const GET_GREETING = gql`
182
+ * query GetGreeting($language: String!) {
183
+ * greeting(language: $language) {
184
+ * message
185
+ * }
186
+ * }
187
+ * `;
188
+ *
189
+ * function App() {
190
+ * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);
191
+ *
192
+ * return (
193
+ * <>
194
+ * <button onClick={() => loadGreeting({ language: "english" })}>
195
+ * Load greeting
196
+ * </button>
197
+ * <Suspense fallback={<div>Loading...</div>}>
198
+ * {queryRef && <Hello queryRef={queryRef} />}
199
+ * </Suspense>
200
+ * </>
201
+ * );
202
+ * }
203
+ *
204
+ * function Hello({ queryRef }) {
205
+ * const { data } = useReadQuery(queryRef);
206
+ *
207
+ * return <div>{data.greeting.message}</div>;
208
+ * }
209
+ * ```
210
+ *
211
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
212
+ * @param options - Options to control how the query is executed.
213
+ * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
214
+ */
215
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useLoadableQuery.Options): useLoadableQuery.Result<TData, TVariables>;
216
+ }
217
+ }
218
+ namespace Signatures {
219
+ /**
220
+ * @deprecated Avoid manually specifying generics on `useLoadableQuery`.
221
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
222
+ *
223
+ *
224
+ * A hook for imperatively loading a query, such as responding to a user
225
+ * interaction.
226
+ *
227
+ * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.
228
+ *
229
+ * @example
230
+ *
231
+ * ```jsx
232
+ * import { gql, useLoadableQuery } from "@apollo/client";
233
+ *
234
+ * const GET_GREETING = gql`
235
+ * query GetGreeting($language: String!) {
236
+ * greeting(language: $language) {
237
+ * message
238
+ * }
239
+ * }
240
+ * `;
241
+ *
242
+ * function App() {
243
+ * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);
244
+ *
245
+ * return (
246
+ * <>
247
+ * <button onClick={() => loadGreeting({ language: "english" })}>
248
+ * Load greeting
249
+ * </button>
250
+ * <Suspense fallback={<div>Loading...</div>}>
251
+ * {queryRef && <Hello queryRef={queryRef} />}
252
+ * </Suspense>
253
+ * </>
254
+ * );
255
+ * }
256
+ *
257
+ * function Hello({ queryRef }) {
258
+ * const { data } = useReadQuery(queryRef);
259
+ *
260
+ * return <div>{data.greeting.message}</div>;
261
+ * }
262
+ * ```
263
+ *
264
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
265
+ * @param options - Options to control how the query is executed.
266
+ * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
267
+ */
268
+ interface Classic {
269
+ /**
270
+ * @deprecated Avoid manually specifying generics on `useLoadableQuery`.
271
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
272
+ *
273
+ *
274
+ * A hook for imperatively loading a query, such as responding to a user
275
+ * interaction.
276
+ *
277
+ * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.
278
+ *
279
+ * @example
280
+ *
281
+ * ```jsx
282
+ * import { gql, useLoadableQuery } from "@apollo/client";
283
+ *
284
+ * const GET_GREETING = gql`
285
+ * query GetGreeting($language: String!) {
286
+ * greeting(language: $language) {
287
+ * message
288
+ * }
289
+ * }
290
+ * `;
291
+ *
292
+ * function App() {
293
+ * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);
294
+ *
295
+ * return (
296
+ * <>
297
+ * <button onClick={() => loadGreeting({ language: "english" })}>
298
+ * Load greeting
299
+ * </button>
300
+ * <Suspense fallback={<div>Loading...</div>}>
301
+ * {queryRef && <Hello queryRef={queryRef} />}
302
+ * </Suspense>
303
+ * </>
304
+ * );
305
+ * }
306
+ *
307
+ * function Hello({ queryRef }) {
308
+ * const { data } = useReadQuery(queryRef);
309
+ *
310
+ * return <div>{data.greeting.message}</div>;
311
+ * }
312
+ * ```
313
+ *
314
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
315
+ * @param options - Options to control how the query is executed.
316
+ * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
317
+ */
318
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useLoadableQuery.Options & {
319
+ returnPartialData: true;
320
+ errorPolicy: "ignore" | "all";
321
+ }): useLoadableQuery.Result<TData, TVariables, "complete" | "streaming" | "partial" | "empty">;
322
+ /**
323
+ * @deprecated Avoid manually specifying generics on `useLoadableQuery`.
324
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
325
+ *
326
+ *
327
+ * A hook for imperatively loading a query, such as responding to a user
328
+ * interaction.
329
+ *
330
+ * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.
331
+ *
332
+ * @example
333
+ *
334
+ * ```jsx
335
+ * import { gql, useLoadableQuery } from "@apollo/client";
336
+ *
337
+ * const GET_GREETING = gql`
338
+ * query GetGreeting($language: String!) {
339
+ * greeting(language: $language) {
340
+ * message
341
+ * }
342
+ * }
343
+ * `;
344
+ *
345
+ * function App() {
346
+ * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);
347
+ *
348
+ * return (
349
+ * <>
350
+ * <button onClick={() => loadGreeting({ language: "english" })}>
351
+ * Load greeting
352
+ * </button>
353
+ * <Suspense fallback={<div>Loading...</div>}>
354
+ * {queryRef && <Hello queryRef={queryRef} />}
355
+ * </Suspense>
356
+ * </>
357
+ * );
358
+ * }
359
+ *
360
+ * function Hello({ queryRef }) {
361
+ * const { data } = useReadQuery(queryRef);
362
+ *
363
+ * return <div>{data.greeting.message}</div>;
364
+ * }
365
+ * ```
366
+ *
367
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
368
+ * @param options - Options to control how the query is executed.
369
+ * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
370
+ */
371
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useLoadableQuery.Options & {
372
+ errorPolicy: "ignore" | "all";
373
+ }): useLoadableQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
374
+ /**
375
+ * @deprecated Avoid manually specifying generics on `useLoadableQuery`.
376
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
377
+ *
378
+ *
379
+ * A hook for imperatively loading a query, such as responding to a user
380
+ * interaction.
381
+ *
382
+ * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.
383
+ *
384
+ * @example
385
+ *
386
+ * ```jsx
387
+ * import { gql, useLoadableQuery } from "@apollo/client";
388
+ *
389
+ * const GET_GREETING = gql`
390
+ * query GetGreeting($language: String!) {
391
+ * greeting(language: $language) {
392
+ * message
393
+ * }
394
+ * }
395
+ * `;
396
+ *
397
+ * function App() {
398
+ * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);
399
+ *
400
+ * return (
401
+ * <>
402
+ * <button onClick={() => loadGreeting({ language: "english" })}>
403
+ * Load greeting
404
+ * </button>
405
+ * <Suspense fallback={<div>Loading...</div>}>
406
+ * {queryRef && <Hello queryRef={queryRef} />}
407
+ * </Suspense>
408
+ * </>
409
+ * );
410
+ * }
411
+ *
412
+ * function Hello({ queryRef }) {
413
+ * const { data } = useReadQuery(queryRef);
414
+ *
415
+ * return <div>{data.greeting.message}</div>;
416
+ * }
417
+ * ```
418
+ *
419
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
420
+ * @param options - Options to control how the query is executed.
421
+ * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
422
+ */
423
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useLoadableQuery.Options & {
424
+ returnPartialData: true;
425
+ }): useLoadableQuery.Result<TData, TVariables, "complete" | "streaming" | "partial">;
426
+ /**
427
+ * @deprecated Avoid manually specifying generics on `useLoadableQuery`.
428
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
429
+ *
430
+ *
431
+ * A hook for imperatively loading a query, such as responding to a user
432
+ * interaction.
433
+ *
434
+ * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.
435
+ *
436
+ * @example
437
+ *
438
+ * ```jsx
439
+ * import { gql, useLoadableQuery } from "@apollo/client";
440
+ *
441
+ * const GET_GREETING = gql`
442
+ * query GetGreeting($language: String!) {
443
+ * greeting(language: $language) {
444
+ * message
445
+ * }
446
+ * }
447
+ * `;
448
+ *
449
+ * function App() {
450
+ * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);
451
+ *
452
+ * return (
453
+ * <>
454
+ * <button onClick={() => loadGreeting({ language: "english" })}>
455
+ * Load greeting
456
+ * </button>
457
+ * <Suspense fallback={<div>Loading...</div>}>
458
+ * {queryRef && <Hello queryRef={queryRef} />}
459
+ * </Suspense>
460
+ * </>
461
+ * );
462
+ * }
463
+ *
464
+ * function Hello({ queryRef }) {
465
+ * const { data } = useReadQuery(queryRef);
466
+ *
467
+ * return <div>{data.greeting.message}</div>;
468
+ * }
469
+ * ```
470
+ *
471
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
472
+ * @param options - Options to control how the query is executed.
473
+ * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
474
+ */
475
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: useLoadableQuery.Options): useLoadableQuery.Result<TData, TVariables, "complete" | "streaming">;
476
+ }
113
477
  /**
114
478
  * A hook for imperatively loading a query, such as responding to a user
115
479
  * interaction.
@@ -155,199 +519,150 @@ export declare namespace useLoadableQuery {
155
519
  * @param options - Options to control how the query is executed.
156
520
  * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
157
521
  */
158
- function useLoadableQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useLoadableQuery.Options): useLoadableQuery.Result<TData, TVariables>;
522
+ interface Modern {
523
+ /**
524
+ * A hook for imperatively loading a query, such as responding to a user
525
+ * interaction.
526
+ *
527
+ * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.
528
+ *
529
+ * @example
530
+ *
531
+ * ```jsx
532
+ * import { gql, useLoadableQuery } from "@apollo/client";
533
+ *
534
+ * const GET_GREETING = gql`
535
+ * query GetGreeting($language: String!) {
536
+ * greeting(language: $language) {
537
+ * message
538
+ * }
539
+ * }
540
+ * `;
541
+ *
542
+ * function App() {
543
+ * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);
544
+ *
545
+ * return (
546
+ * <>
547
+ * <button onClick={() => loadGreeting({ language: "english" })}>
548
+ * Load greeting
549
+ * </button>
550
+ * <Suspense fallback={<div>Loading...</div>}>
551
+ * {queryRef && <Hello queryRef={queryRef} />}
552
+ * </Suspense>
553
+ * </>
554
+ * );
555
+ * }
556
+ *
557
+ * function Hello({ queryRef }) {
558
+ * const { data } = useReadQuery(queryRef);
559
+ *
560
+ * return <div>{data.greeting.message}</div>;
561
+ * }
562
+ * ```
563
+ *
564
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
565
+ * @param options - Options to control how the query is executed.
566
+ * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
567
+ */
568
+ <TData, TVariables extends OperationVariables, TOptions extends never>(query: DocumentNode | TypedDocumentNode<TData, TVariables>): useLoadableQuery.ResultForOptions<TData, TVariables, Record<string, never>>;
569
+ /**
570
+ * A hook for imperatively loading a query, such as responding to a user
571
+ * interaction.
572
+ *
573
+ * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.
574
+ *
575
+ * @example
576
+ *
577
+ * ```jsx
578
+ * import { gql, useLoadableQuery } from "@apollo/client";
579
+ *
580
+ * const GET_GREETING = gql`
581
+ * query GetGreeting($language: String!) {
582
+ * greeting(language: $language) {
583
+ * message
584
+ * }
585
+ * }
586
+ * `;
587
+ *
588
+ * function App() {
589
+ * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);
590
+ *
591
+ * return (
592
+ * <>
593
+ * <button onClick={() => loadGreeting({ language: "english" })}>
594
+ * Load greeting
595
+ * </button>
596
+ * <Suspense fallback={<div>Loading...</div>}>
597
+ * {queryRef && <Hello queryRef={queryRef} />}
598
+ * </Suspense>
599
+ * </>
600
+ * );
601
+ * }
602
+ *
603
+ * function Hello({ queryRef }) {
604
+ * const { data } = useReadQuery(queryRef);
605
+ *
606
+ * return <div>{data.greeting.message}</div>;
607
+ * }
608
+ * ```
609
+ *
610
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
611
+ * @param options - Options to control how the query is executed.
612
+ * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
613
+ */
614
+ <TData, TVariables extends OperationVariables, TOptions extends useLoadableQuery.Options>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: TOptions): useLoadableQuery.ResultForOptions<TData, TVariables, TOptions>;
615
+ }
616
+ type Evaluated = SignatureStyle extends "classic" ? Classic : Modern;
617
+ }
618
+ /**
619
+ * A hook for imperatively loading a query, such as responding to a user
620
+ * interaction.
621
+ *
622
+ * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.
623
+ *
624
+ * @example
625
+ *
626
+ * ```jsx
627
+ * import { gql, useLoadableQuery } from "@apollo/client";
628
+ *
629
+ * const GET_GREETING = gql`
630
+ * query GetGreeting($language: String!) {
631
+ * greeting(language: $language) {
632
+ * message
633
+ * }
634
+ * }
635
+ * `;
636
+ *
637
+ * function App() {
638
+ * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);
639
+ *
640
+ * return (
641
+ * <>
642
+ * <button onClick={() => loadGreeting({ language: "english" })}>
643
+ * Load greeting
644
+ * </button>
645
+ * <Suspense fallback={<div>Loading...</div>}>
646
+ * {queryRef && <Hello queryRef={queryRef} />}
647
+ * </Suspense>
648
+ * </>
649
+ * );
650
+ * }
651
+ *
652
+ * function Hello({ queryRef }) {
653
+ * const { data } = useReadQuery(queryRef);
654
+ *
655
+ * return <div>{data.greeting.message}</div>;
656
+ * }
657
+ * ```
658
+ *
659
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
660
+ * @param options - Options to control how the query is executed.
661
+ * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
662
+ */
663
+ interface Signature extends Signatures.Evaluated {
159
664
  }
160
665
  }
161
- /**
162
- * A hook for imperatively loading a query, such as responding to a user
163
- * interaction.
164
- *
165
- * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.
166
- *
167
- * @example
168
- *
169
- * ```jsx
170
- * import { gql, useLoadableQuery } from "@apollo/client";
171
- *
172
- * const GET_GREETING = gql`
173
- * query GetGreeting($language: String!) {
174
- * greeting(language: $language) {
175
- * message
176
- * }
177
- * }
178
- * `;
179
- *
180
- * function App() {
181
- * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);
182
- *
183
- * return (
184
- * <>
185
- * <button onClick={() => loadGreeting({ language: "english" })}>
186
- * Load greeting
187
- * </button>
188
- * <Suspense fallback={<div>Loading...</div>}>
189
- * {queryRef && <Hello queryRef={queryRef} />}
190
- * </Suspense>
191
- * </>
192
- * );
193
- * }
194
- *
195
- * function Hello({ queryRef }) {
196
- * const { data } = useReadQuery(queryRef);
197
- *
198
- * return <div>{data.greeting.message}</div>;
199
- * }
200
- * ```
201
- *
202
- * @param query - A GraphQL query document parsed into an AST by `gql`.
203
- * @param options - Options to control how the query is executed.
204
- * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
205
- */
206
- export declare function useLoadableQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useLoadableQuery.Options & {
207
- returnPartialData: true;
208
- errorPolicy: "ignore" | "all";
209
- }): useLoadableQuery.Result<TData, TVariables, "complete" | "streaming" | "partial" | "empty">;
210
- /**
211
- * A hook for imperatively loading a query, such as responding to a user
212
- * interaction.
213
- *
214
- * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.
215
- *
216
- * @example
217
- *
218
- * ```jsx
219
- * import { gql, useLoadableQuery } from "@apollo/client";
220
- *
221
- * const GET_GREETING = gql`
222
- * query GetGreeting($language: String!) {
223
- * greeting(language: $language) {
224
- * message
225
- * }
226
- * }
227
- * `;
228
- *
229
- * function App() {
230
- * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);
231
- *
232
- * return (
233
- * <>
234
- * <button onClick={() => loadGreeting({ language: "english" })}>
235
- * Load greeting
236
- * </button>
237
- * <Suspense fallback={<div>Loading...</div>}>
238
- * {queryRef && <Hello queryRef={queryRef} />}
239
- * </Suspense>
240
- * </>
241
- * );
242
- * }
243
- *
244
- * function Hello({ queryRef }) {
245
- * const { data } = useReadQuery(queryRef);
246
- *
247
- * return <div>{data.greeting.message}</div>;
248
- * }
249
- * ```
250
- *
251
- * @param query - A GraphQL query document parsed into an AST by `gql`.
252
- * @param options - Options to control how the query is executed.
253
- * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
254
- */
255
- export declare function useLoadableQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useLoadableQuery.Options & {
256
- errorPolicy: "ignore" | "all";
257
- }): useLoadableQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
258
- /**
259
- * A hook for imperatively loading a query, such as responding to a user
260
- * interaction.
261
- *
262
- * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.
263
- *
264
- * @example
265
- *
266
- * ```jsx
267
- * import { gql, useLoadableQuery } from "@apollo/client";
268
- *
269
- * const GET_GREETING = gql`
270
- * query GetGreeting($language: String!) {
271
- * greeting(language: $language) {
272
- * message
273
- * }
274
- * }
275
- * `;
276
- *
277
- * function App() {
278
- * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);
279
- *
280
- * return (
281
- * <>
282
- * <button onClick={() => loadGreeting({ language: "english" })}>
283
- * Load greeting
284
- * </button>
285
- * <Suspense fallback={<div>Loading...</div>}>
286
- * {queryRef && <Hello queryRef={queryRef} />}
287
- * </Suspense>
288
- * </>
289
- * );
290
- * }
291
- *
292
- * function Hello({ queryRef }) {
293
- * const { data } = useReadQuery(queryRef);
294
- *
295
- * return <div>{data.greeting.message}</div>;
296
- * }
297
- * ```
298
- *
299
- * @param query - A GraphQL query document parsed into an AST by `gql`.
300
- * @param options - Options to control how the query is executed.
301
- * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
302
- */
303
- export declare function useLoadableQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useLoadableQuery.Options & {
304
- returnPartialData: true;
305
- }): useLoadableQuery.Result<TData, TVariables, "complete" | "streaming" | "partial">;
306
- /**
307
- * A hook for imperatively loading a query, such as responding to a user
308
- * interaction.
309
- *
310
- * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`.
311
- *
312
- * @example
313
- *
314
- * ```jsx
315
- * import { gql, useLoadableQuery } from "@apollo/client";
316
- *
317
- * const GET_GREETING = gql`
318
- * query GetGreeting($language: String!) {
319
- * greeting(language: $language) {
320
- * message
321
- * }
322
- * }
323
- * `;
324
- *
325
- * function App() {
326
- * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING);
327
- *
328
- * return (
329
- * <>
330
- * <button onClick={() => loadGreeting({ language: "english" })}>
331
- * Load greeting
332
- * </button>
333
- * <Suspense fallback={<div>Loading...</div>}>
334
- * {queryRef && <Hello queryRef={queryRef} />}
335
- * </Suspense>
336
- * </>
337
- * );
338
- * }
339
- *
340
- * function Hello({ queryRef }) {
341
- * const { data } = useReadQuery(queryRef);
342
- *
343
- * return <div>{data.greeting.message}</div>;
344
- * }
345
- * ```
346
- *
347
- * @param query - A GraphQL query document parsed into an AST by `gql`.
348
- * @param options - Options to control how the query is executed.
349
- * @returns A tuple in the form of `[loadQuery, queryRef, handlers]`
350
- */
351
- export declare function useLoadableQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: useLoadableQuery.Options): useLoadableQuery.Result<TData, TVariables, "complete" | "streaming">;
666
+ export declare const useLoadableQuery: useLoadableQuery.Signature;
352
667
  export {};
353
668
  //# sourceMappingURL=useLoadableQuery.d.cts.map