@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
@@ -1,5 +1,6 @@
1
1
  import type { DocumentNode } from "graphql";
2
2
  import type { Observable } from "rxjs";
3
+ import type { InternalTypes } from "@apollo/client";
3
4
  import type { ApolloCache, Cache, IgnoreModifier, Reference } from "@apollo/client/cache";
4
5
  import type { Incremental } from "@apollo/client/incremental";
5
6
  import type { ApolloLink } from "@apollo/client/link";
@@ -7,18 +8,34 @@ import type { ClientAwarenessLink } from "@apollo/client/link/client-awareness";
7
8
  import type { LocalState } from "@apollo/client/local-state";
8
9
  import type { MaybeMasked, Unmasked } from "@apollo/client/masking";
9
10
  import { DocumentTransform } from "@apollo/client/utilities";
10
- import type { VariablesOption, variablesUnknownSymbol } from "@apollo/client/utilities/internal";
11
+ import type { LazyType, OptionWithFallback, SignatureStyle, VariablesOption, variablesUnknownSymbol } from "@apollo/client/utilities/internal";
11
12
  import { getApolloClientMemoryInternals } from "@apollo/client/utilities/internal";
13
+ import type { DeclareDefaultOptions, DefaultOptions } from "./defaultOptions.cjs";
12
14
  import type { ObservableQuery } from "./ObservableQuery.cjs";
13
15
  import type { DefaultContext, ErrorLike, InternalRefetchQueriesInclude, InternalRefetchQueriesResult, MutationQueryReducersMap, MutationUpdaterFunction, NormalizedExecutionResult, OnQueryUpdated, OperationVariables, RefetchQueriesInclude, RefetchQueriesPromiseResults, SubscriptionObservable, TypedDocumentNode } from "./types.cjs";
14
16
  import type { ErrorPolicy, FetchPolicy, MutationFetchPolicy, NextFetchPolicyContext, RefetchWritePolicy, WatchQueryFetchPolicy } from "./watchQueryOptions.cjs";
17
+ /**
18
+ * @knipignore
19
+ * @internal
20
+ * For some reason, without this export the build stop drops references to `DefaultOptions` and `DeclareDefaultOptions`, resulting in a broken build.
21
+ * Adding this fixes that, although it's not particularly elegant.
22
+ *
23
+ * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
24
+ */
25
+ export interface ReferenceToAvoidDroppingImportOnBuild {
26
+ _1: DeclareDefaultOptions.Mutate;
27
+ _2: DefaultOptions;
28
+ }
15
29
  export declare namespace ApolloClient {
16
- interface DefaultOptions {
17
- watchQuery?: Partial<ApolloClient.WatchQueryOptions<any, any>>;
18
- query?: Partial<ApolloClient.QueryOptions<any, any>>;
19
- mutate?: Partial<ApolloClient.MutateOptions<any, any, any>>;
30
+ export type { DeclareDefaultOptions, DefaultOptions };
31
+ export namespace DocumentationTypes {
32
+ interface DefaultOptions {
33
+ watchQuery?: Partial<ApolloClient.WatchQueryOptions<any, any>>;
34
+ query?: Partial<ApolloClient.QueryOptions<any, any>>;
35
+ mutate?: Partial<ApolloClient.MutateOptions<any, any, any>>;
36
+ }
20
37
  }
21
- interface Options {
38
+ export interface Options extends InternalTypes.DefaultOptionsParentObject {
22
39
  /**
23
40
  * An `ApolloLink` instance to serve as Apollo Client's network layer. For more information, see [Advanced HTTP networking](https://www.apollographql.com/docs/react/networking/advanced-http-networking/).
24
41
  */
@@ -47,12 +64,6 @@ export declare namespace ApolloClient {
47
64
  * @defaultValue `true`
48
65
  */
49
66
  queryDeduplication?: boolean;
50
- /**
51
- * Provide this object to set application-wide default values for options you can provide to the `watchQuery`, `query`, and `mutate` functions. See below for an example object.
52
- *
53
- * See this [example object](https://www.apollographql.com/docs/react/api/core/ApolloClient#example-defaultoptions-object).
54
- */
55
- defaultOptions?: ApolloClient.DefaultOptions;
56
67
  defaultContext?: Partial<DefaultContext>;
57
68
  /**
58
69
  * If `true`, Apollo Client will assume results read from the cache are never mutated by application code, which enables substantial performance optimizations.
@@ -96,7 +107,7 @@ export declare namespace ApolloClient {
96
107
  */
97
108
  experiments?: ApolloClient.Experiment[];
98
109
  }
99
- interface DevtoolsOptions {
110
+ export interface DevtoolsOptions {
100
111
  /**
101
112
  * If `true`, the [Apollo Client Devtools](https://www.apollographql.com/docs/react/development-testing/developer-tooling/#apollo-client-devtools) browser extension can connect to this `ApolloClient` instance.
102
113
  *
@@ -110,7 +121,7 @@ export declare namespace ApolloClient {
110
121
  */
111
122
  name?: string;
112
123
  }
113
- type MutateOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables, TCache extends ApolloCache = ApolloCache> = {
124
+ export type MutateOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables, TCache extends ApolloCache = ApolloCache> = {
114
125
  /**
115
126
  * By providing either an object or a callback function that, when invoked after
116
127
  * a mutation, allows you to return optimistic data and optionally skip updates
@@ -212,28 +223,122 @@ export declare namespace ApolloClient {
212
223
  */
213
224
  mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;
214
225
  } & VariablesOption<NoInfer<TVariables>>;
215
- interface MutateResult<TData = unknown> {
216
- /**
217
- * The data returned from your mutation. Can be `undefined` if the `errorPolicy`
218
- * is `all` or `ignore` and the server returns a GraphQL response with `errors`
219
- * but not `data` or a network error is returned.
220
- */
221
- data: TData | undefined;
226
+ export namespace mutate {
227
+ interface DefaultOptions extends ApolloClient.DefaultOptions.Mutate.Calculated {
228
+ }
229
+ type ResultForOptions<TData, TVariables extends OperationVariables, TCache extends ApolloCache, TOptions extends Record<string, unknown> | MutateOptions<any, TVariables, TCache>> = LazyType<MutateResult<MaybeMasked<TData>, OptionWithFallback<TOptions, DefaultOptions, "errorPolicy"> & ErrorPolicy>>;
230
+ namespace Signatures {
231
+ interface Classic {
232
+ /**
233
+ * @deprecated Avoid manually specifying generics on `client.mutate`.
234
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your mutation results.
235
+ *
236
+ *
237
+ * This resolves a single mutation according to the options specified and returns a
238
+ * Promise which is either resolved with the resulting data or rejected with an
239
+ * error. In some cases both `data` and `errors` might be undefined, for example
240
+ * when `errorPolicy` is set to `'ignore'`.
241
+ *
242
+ * It takes options as an object with the following keys and values:
243
+ */
244
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables, TCache extends ApolloCache = ApolloCache>(options: ApolloClient.MutateOptions<TData, TVariables, TCache>): Promise<ApolloClient.MutateResult<MaybeMasked<TData>>>;
245
+ }
246
+ interface Modern {
247
+ /**
248
+ * This resolves a single mutation according to the options specified and returns a
249
+ * Promise which is either resolved with the resulting data or rejected with an
250
+ * error. In some cases both `data` and `errors` might be undefined, for example
251
+ * when `errorPolicy` is set to `'ignore'`.
252
+ *
253
+ * It takes options as an object with the following keys and values:
254
+ */
255
+ <TData, TVariables extends OperationVariables, TCache extends ApolloCache, TOptions extends ApolloClient.MutateOptions<NoInfer<TData>, NoInfer<TVariables>, TCache> & VariablesOption<TVariables & {
256
+ [K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
257
+ }>>(options: TOptions & {
258
+ mutation: TypedDocumentNode<TData, TVariables>;
259
+ }): Promise<ApolloClient.mutate.ResultForOptions<TData, TVariables, TCache, TOptions>>;
260
+ }
261
+ type Evaluated = SignatureStyle extends "classic" ? Classic : Modern;
262
+ }
222
263
  /**
223
- * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.
264
+ * This resolves a single mutation according to the options specified and returns a
265
+ * Promise which is either resolved with the resulting data or rejected with an
266
+ * error. In some cases both `data` and `errors` might be undefined, for example
267
+ * when `errorPolicy` is set to `'ignore'`.
224
268
  *
225
- * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
269
+ * It takes options as an object with the following keys and values:
226
270
  */
227
- error?: ErrorLike;
271
+ interface Signature extends Signatures.Evaluated {
272
+ }
273
+ }
274
+ export type MutateResultMap<TData = unknown> = {
275
+ none: {
276
+ /**
277
+ * The data returned from your mutation. Can be `undefined` if the `errorPolicy`
278
+ * is `all` or `ignore` and the server returns a GraphQL response with `errors`
279
+ * but not `data` or a network error is returned.
280
+ */
281
+ data: TData;
282
+ /**
283
+ * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.
284
+ *
285
+ * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
286
+ */
287
+ error?: never;
288
+ };
289
+ all: {
290
+ /**
291
+ * The data returned from your mutation. Can be `undefined` if the `errorPolicy`
292
+ * is `all` or `ignore` and the server returns a GraphQL response with `errors`
293
+ * but not `data` or a network error is returned.
294
+ */
295
+ data: TData | undefined;
296
+ /**
297
+ * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.
298
+ *
299
+ * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
300
+ */
301
+ error?: ErrorLike;
302
+ };
303
+ ignore: {
304
+ /**
305
+ * The data returned from your mutation. Can be `undefined` if the `errorPolicy`
306
+ * is `all` or `ignore` and the server returns a GraphQL response with `errors`
307
+ * but not `data` or a network error is returned.
308
+ */
309
+ data: TData | undefined;
310
+ /**
311
+ * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.
312
+ *
313
+ * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
314
+ */
315
+ error?: never;
316
+ };
317
+ undefined: {
318
+ /**
319
+ * The data returned from your mutation. Can be `undefined` if the `errorPolicy`
320
+ * is `all` or `ignore` and the server returns a GraphQL response with `errors`
321
+ * but not `data` or a network error is returned.
322
+ */
323
+ data: TData | undefined;
324
+ /**
325
+ * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.
326
+ *
327
+ * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
328
+ */
329
+ error?: ErrorLike;
330
+ };
331
+ };
332
+ export type MutateResult<TData = unknown, TErrorPolicy extends ErrorPolicy | undefined = undefined> = MutateResultMap<TData>[`${TErrorPolicy}`] & {
228
333
  /**
229
334
  * Custom extensions returned from the GraphQL server
230
335
  */
231
336
  extensions?: Record<string, unknown>;
232
- }
337
+ };
233
338
  /**
234
339
  * Query options.
235
340
  */
236
- type QueryOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables> = {
341
+ export type QueryOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables> = {
237
342
  /**
238
343
  * A GraphQL query string parsed into an AST with the gql template literal.
239
344
  *
@@ -267,83 +372,140 @@ export declare namespace ApolloClient {
267
372
  */
268
373
  fetchPolicy?: FetchPolicy;
269
374
  } & VariablesOption<NoInfer<TVariables>>;
270
- type QueryResult<TData = unknown, TErrorPolicy extends ErrorPolicy | undefined = undefined> = TErrorPolicy extends "none" ? {
271
- /**
272
- * An object containing the result of your GraphQL query after it completes.
273
- *
274
- * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).
275
- *
276
- * @docGroup 1. Operation data
277
- */
278
- data: TData;
279
- /**
280
- * A single ErrorLike object describing the error that occurred during the latest
281
- * query execution.
282
- *
283
- * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
284
- *
285
- * @docGroup 1. Operation data
286
- */
287
- error?: never;
288
- } : TErrorPolicy extends "all" ? {
289
- /**
290
- * An object containing the result of your GraphQL query after it completes.
291
- *
292
- * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).
293
- *
294
- * @docGroup 1. Operation data
295
- */
296
- data: TData | undefined;
297
- /**
298
- * A single ErrorLike object describing the error that occurred during the latest
299
- * query execution.
300
- *
301
- * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
302
- *
303
- * @docGroup 1. Operation data
304
- */
305
- error?: ErrorLike;
306
- } : TErrorPolicy extends "ignore" ? {
307
- /**
308
- * An object containing the result of your GraphQL query after it completes.
309
- *
310
- * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).
311
- *
312
- * @docGroup 1. Operation data
313
- */
314
- data: TData | undefined;
315
- /**
316
- * A single ErrorLike object describing the error that occurred during the latest
317
- * query execution.
318
- *
319
- * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
320
- *
321
- * @docGroup 1. Operation data
322
- */
323
- error?: never;
324
- } : {
325
- /**
326
- * An object containing the result of your GraphQL query after it completes.
327
- *
328
- * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).
329
- *
330
- * @docGroup 1. Operation data
331
- */
332
- data: TData | undefined;
375
+ export type QueryResultMap<TData = unknown> = {
376
+ none: {
377
+ /**
378
+ * An object containing the result of your GraphQL query after it completes.
379
+ *
380
+ * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).
381
+ *
382
+ * @docGroup 1. Operation data
383
+ */
384
+ data: TData;
385
+ /**
386
+ * A single ErrorLike object describing the error that occurred during the latest
387
+ * query execution.
388
+ *
389
+ * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
390
+ *
391
+ * @docGroup 1. Operation data
392
+ */
393
+ error?: never;
394
+ };
395
+ all: {
396
+ /**
397
+ * An object containing the result of your GraphQL query after it completes.
398
+ *
399
+ * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).
400
+ *
401
+ * @docGroup 1. Operation data
402
+ */
403
+ data: TData | undefined;
404
+ /**
405
+ * A single ErrorLike object describing the error that occurred during the latest
406
+ * query execution.
407
+ *
408
+ * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
409
+ *
410
+ * @docGroup 1. Operation data
411
+ */
412
+ error?: ErrorLike;
413
+ };
414
+ ignore: {
415
+ /**
416
+ * An object containing the result of your GraphQL query after it completes.
417
+ *
418
+ * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).
419
+ *
420
+ * @docGroup 1. Operation data
421
+ */
422
+ data: TData | undefined;
423
+ /**
424
+ * A single ErrorLike object describing the error that occurred during the latest
425
+ * query execution.
426
+ *
427
+ * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
428
+ *
429
+ * @docGroup 1. Operation data
430
+ */
431
+ error?: never;
432
+ };
433
+ undefined: {
434
+ /**
435
+ * An object containing the result of your GraphQL query after it completes.
436
+ *
437
+ * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).
438
+ *
439
+ * @docGroup 1. Operation data
440
+ */
441
+ data: TData | undefined;
442
+ /**
443
+ * A single ErrorLike object describing the error that occurred during the latest
444
+ * query execution.
445
+ *
446
+ * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
447
+ *
448
+ * @docGroup 1. Operation data
449
+ */
450
+ error?: ErrorLike;
451
+ };
452
+ };
453
+ export type QueryResult<TData = unknown, TErrorPolicy extends ErrorPolicy | undefined = undefined> = QueryResultMap<TData>[`${TErrorPolicy}`];
454
+ export namespace query {
455
+ interface DefaultOptions extends ApolloClient.DefaultOptions.Query.Calculated {
456
+ }
457
+ type ResultForOptions<TData, TVariables extends OperationVariables, TOptions extends Record<string, unknown> | QueryOptions<any, TVariables>> = LazyType<QueryResult<MaybeMasked<TData>, OptionWithFallback<TOptions, DefaultOptions, "errorPolicy"> & ErrorPolicy>>;
458
+ namespace Signatures {
459
+ interface Classic {
460
+ /**
461
+ * @deprecated Avoid manually specifying generics on `client.query`.
462
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
463
+ *
464
+ *
465
+ * This resolves a single query according to the options specified and
466
+ * returns a `Promise` which is either resolved with the resulting data
467
+ * or rejected with an error.
468
+ *
469
+ * @param options - An object of type `QueryOptions` that allows us to
470
+ * describe how this query should be treated e.g. whether it should hit the
471
+ * server at all or just resolve from the cache, etc.
472
+ */
473
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.QueryOptions<TData, TVariables>): Promise<ApolloClient.QueryResult<MaybeMasked<TData>>>;
474
+ }
475
+ interface Modern {
476
+ /**
477
+ * This resolves a single query according to the options specified and
478
+ * returns a `Promise` which is either resolved with the resulting data
479
+ * or rejected with an error.
480
+ *
481
+ * @param options - An object of type `QueryOptions` that allows us to
482
+ * describe how this query should be treated e.g. whether it should hit the
483
+ * server at all or just resolve from the cache, etc.
484
+ */
485
+ <TData, TVariables extends OperationVariables, TOptions extends ApolloClient.QueryOptions<NoInfer<TData>, NoInfer<TVariables>> & VariablesOption<TVariables & {
486
+ [K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
487
+ }>>(options: TOptions & {
488
+ query: TypedDocumentNode<TData, TVariables>;
489
+ }): Promise<ApolloClient.query.ResultForOptions<TData, TVariables, TOptions>>;
490
+ }
491
+ type Evaluated = SignatureStyle extends "classic" ? Classic : Modern;
492
+ }
333
493
  /**
334
- * A single ErrorLike object describing the error that occurred during the latest
335
- * query execution.
494
+ * This resolves a single query according to the options specified and
495
+ * returns a `Promise` which is either resolved with the resulting data
496
+ * or rejected with an error.
336
497
  *
337
- * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
338
- *
339
- * @docGroup 1. Operation data
498
+ * @param options - An object of type `QueryOptions` that allows us to
499
+ * describe how this query should be treated e.g. whether it should hit the
500
+ * server at all or just resolve from the cache, etc.
340
501
  */
341
- error?: ErrorLike;
342
- };
502
+ interface Signature extends Signatures.Evaluated {
503
+ }
504
+ }
343
505
  /**
344
506
  * Options object for the `client.refetchQueries` method.
345
507
  */
346
- interface RefetchQueriesOptions<TCache extends ApolloCache, TResult> {
508
+ export interface RefetchQueriesOptions<TCache extends ApolloCache, TResult> {
347
509
  /**
348
510
  * Optional function that updates cached fields to trigger refetches of queries that include those fields.
349
511
  */
@@ -377,9 +539,9 @@ export declare namespace ApolloClient {
377
539
  * immediately by examining the additional `queries` and `results` properties of
378
540
  * the `RefetchQueriesResult<TResult> object`.
379
541
  */
380
- interface RefetchQueriesResult<TResult> extends Promise<RefetchQueriesPromiseResults<TResult>>, RefetchQueriesResult.AdditionalProperties<TResult> {
542
+ export interface RefetchQueriesResult<TResult> extends Promise<RefetchQueriesPromiseResults<TResult>>, RefetchQueriesResult.AdditionalProperties<TResult> {
381
543
  }
382
- namespace RefetchQueriesResult {
544
+ export namespace RefetchQueriesResult {
383
545
  interface AdditionalProperties<TResult> {
384
546
  /**
385
547
  * An array of ObservableQuery objects corresponding 1:1 to TResult values
@@ -396,7 +558,7 @@ export declare namespace ApolloClient {
396
558
  results: InternalRefetchQueriesResult<TResult>[];
397
559
  }
398
560
  }
399
- type SubscribeOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables> = {
561
+ export type SubscribeOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables> = {
400
562
  /**
401
563
  * A GraphQL document, often created with `gql` from the `graphql-tag`
402
564
  * package, that contains a single subscription inside of it.
@@ -419,7 +581,7 @@ export declare namespace ApolloClient {
419
581
  */
420
582
  extensions?: Record<string, any>;
421
583
  } & VariablesOption<NoInfer<TVariables>>;
422
- interface SubscribeResult<TData = unknown> {
584
+ export interface SubscribeResult<TData = unknown> {
423
585
  /**
424
586
  * The data returned from your mutation. Can be `undefined` if the `errorPolicy`
425
587
  * is `all` or `ignore` and the server returns a GraphQL response with `errors`
@@ -437,9 +599,9 @@ export declare namespace ApolloClient {
437
599
  */
438
600
  extensions?: Record<string, unknown>;
439
601
  }
440
- type WatchFragmentOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables> = ApolloCache.WatchFragmentOptions<TData, TVariables>;
441
- type WatchFragmentResult<TData = unknown> = ApolloCache.WatchFragmentResult<MaybeMasked<TData>>;
442
- interface ObservableFragment<TData = unknown> extends Observable<ApolloClient.WatchFragmentResult<TData>> {
602
+ export type WatchFragmentOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables> = ApolloCache.WatchFragmentOptions<TData, TVariables>;
603
+ export type WatchFragmentResult<TData = unknown> = ApolloCache.WatchFragmentResult<MaybeMasked<TData>>;
604
+ export interface ObservableFragment<TData = unknown> extends Observable<ApolloClient.WatchFragmentResult<TData>> {
443
605
  /**
444
606
  * Return the current result for the fragment.
445
607
  */
@@ -448,7 +610,7 @@ export declare namespace ApolloClient {
448
610
  /**
449
611
  * Watched query options.
450
612
  */
451
- type WatchQueryOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables> = {
613
+ export type WatchQueryOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables> = {
452
614
  /**
453
615
  * 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).
454
616
  *
@@ -580,8 +742,8 @@ export declare namespace ApolloClient {
580
742
  optimistic?: boolean;
581
743
  }
582
744
  }
583
- type ReadQueryOptions<TData, TVariables extends OperationVariables> = Base.ReadQueryOptions<TData, TVariables> & VariablesOption<TVariables>;
584
- namespace DocumentationTypes {
745
+ export type ReadQueryOptions<TData, TVariables extends OperationVariables> = Base.ReadQueryOptions<TData, TVariables> & VariablesOption<TVariables>;
746
+ export namespace DocumentationTypes {
585
747
  interface ReadQueryOptions<TData, TVariables extends OperationVariables> extends Base.ReadQueryOptions<TData, TVariables> {
586
748
  /**
587
749
  * Any variables that the GraphQL query may depend on.
@@ -619,7 +781,7 @@ export declare namespace ApolloClient {
619
781
  optimistic?: boolean;
620
782
  }
621
783
  }
622
- namespace DocumentationTypes {
784
+ export namespace DocumentationTypes {
623
785
  interface ReadFragmentOptions<TData, TVariables extends OperationVariables> extends Base.ReadFragmentOptions<TData, TVariables> {
624
786
  /**
625
787
  * The root id to be used. This id should take the same form as the
@@ -639,8 +801,8 @@ export declare namespace ApolloClient {
639
801
  from?: ApolloCache.FromOptionValue<TData>;
640
802
  }
641
803
  }
642
- type ReadFragmentOptions<TData, TVariables extends OperationVariables> = Base.ReadFragmentOptions<TData, TVariables> & VariablesOption<TVariables> & Cache.CacheIdentifierOption<TData>;
643
- namespace DocumentationTypes {
804
+ export type ReadFragmentOptions<TData, TVariables extends OperationVariables> = Base.ReadFragmentOptions<TData, TVariables> & VariablesOption<TVariables> & Cache.CacheIdentifierOption<TData>;
805
+ export namespace DocumentationTypes {
644
806
  interface WriteQueryOptions<TData, TVariables extends OperationVariables> extends Base.WriteQueryOptions<TData, TVariables> {
645
807
  /**
646
808
  * Any variables that your GraphQL fragments depend on.
@@ -684,8 +846,8 @@ export declare namespace ApolloClient {
684
846
  extensions?: Record<string, unknown>;
685
847
  }
686
848
  }
687
- type WriteQueryOptions<TData, TVariables extends OperationVariables> = Base.WriteQueryOptions<TData, TVariables> & VariablesOption<TVariables>;
688
- namespace DocumentationTypes {
849
+ export type WriteQueryOptions<TData, TVariables extends OperationVariables> = Base.WriteQueryOptions<TData, TVariables> & VariablesOption<TVariables>;
850
+ export namespace DocumentationTypes {
689
851
  interface WriteQueryOptions<TData, TVariables extends OperationVariables> extends Base.WriteQueryOptions<TData, TVariables> {
690
852
  /**
691
853
  * Any variables that the GraphQL query may depend on.
@@ -726,8 +888,8 @@ export declare namespace ApolloClient {
726
888
  overwrite?: boolean;
727
889
  }
728
890
  }
729
- type WriteFragmentOptions<TData, TVariables extends OperationVariables> = Base.WriteFragmentOptions<TData, TVariables> & VariablesOption<TVariables> & Cache.CacheIdentifierOption<TData>;
730
- namespace DocumentationTypes {
891
+ export type WriteFragmentOptions<TData, TVariables extends OperationVariables> = Base.WriteFragmentOptions<TData, TVariables> & VariablesOption<TVariables> & Cache.CacheIdentifierOption<TData>;
892
+ export namespace DocumentationTypes {
731
893
  interface WriteFragmentOptions<TData, TVariables extends OperationVariables> extends Base.WriteFragmentOptions<TData, TVariables> {
732
894
  /**
733
895
  * The root id to be used. This id should take the same form as the
@@ -751,10 +913,31 @@ export declare namespace ApolloClient {
751
913
  variables?: TVariables;
752
914
  }
753
915
  }
754
- interface Experiment {
916
+ export interface Experiment {
755
917
  (this: ApolloClient, options: ApolloClient.Options): void;
756
918
  v: 1;
757
919
  }
920
+ export namespace DocumentationTypes {
921
+ /**
922
+ * This resolves a single query according to the options specified and
923
+ * returns a `Promise` which is either resolved with the resulting data
924
+ * or rejected with an error.
925
+ *
926
+ * @param options - An object of type `QueryOptions` that allows us to
927
+ * describe how this query should be treated e.g. whether it should hit the
928
+ * server at all or just resolve from the cache, etc.
929
+ */
930
+ function query<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.QueryOptions<TData, TVariables>): Promise<ApolloClient.QueryResult<MaybeMasked<TData>>>;
931
+ /**
932
+ * This resolves a single mutation according to the options specified and returns a
933
+ * Promise which is either resolved with the resulting data or rejected with an
934
+ * error. In some cases both `data` and `errors` might be undefined, for example
935
+ * when `errorPolicy` is set to `'ignore'`.
936
+ *
937
+ * It takes options as an object with the following keys and values:
938
+ */
939
+ function mutate<TData = unknown, TVariables extends OperationVariables = OperationVariables, TCache extends ApolloCache = ApolloCache>(options: ApolloClient.MutateOptions<TData, TVariables, TCache>): Promise<ApolloClient.MutateResult<MaybeMasked<TData>>>;
940
+ }
758
941
  }
759
942
  /**
760
943
  * This is the primary Apollo Client class. It is used to send GraphQL documents (i.e. queries
@@ -856,18 +1039,6 @@ export declare class ApolloClient {
856
1039
  * a description of store reactivity.
857
1040
  */
858
1041
  watchQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchQueryOptions<TData, TVariables>): ObservableQuery<TData, TVariables>;
859
- /**
860
- * This resolves a single query according to the options specified and
861
- * returns a `Promise` which is either resolved with the resulting data
862
- * or rejected with an error.
863
- *
864
- * @param options - An object of type `QueryOptions` that allows us to
865
- * describe how this query should be treated e.g. whether it should hit the
866
- * server at all or just resolve from the cache, etc.
867
- */
868
- query<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.QueryOptions<TData, TVariables> & {
869
- errorPolicy: "all";
870
- }): Promise<ApolloClient.QueryResult<MaybeMasked<TData>, "all">>;
871
1042
  /**
872
1043
  * This resolves a single query according to the options specified and
873
1044
  * returns a `Promise` which is either resolved with the resulting data
@@ -877,28 +1048,16 @@ export declare class ApolloClient {
877
1048
  * describe how this query should be treated e.g. whether it should hit the
878
1049
  * server at all or just resolve from the cache, etc.
879
1050
  */
880
- query<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.QueryOptions<TData, TVariables> & {
881
- errorPolicy: "ignore";
882
- }): Promise<ApolloClient.QueryResult<MaybeMasked<TData>, "ignore">>;
1051
+ query: ApolloClient.query.Signature;
883
1052
  /**
884
- * This resolves a single query according to the options specified and
885
- * returns a `Promise` which is either resolved with the resulting data
886
- * or rejected with an error.
1053
+ * This resolves a single mutation according to the options specified and returns a
1054
+ * Promise which is either resolved with the resulting data or rejected with an
1055
+ * error. In some cases both `data` and `errors` might be undefined, for example
1056
+ * when `errorPolicy` is set to `'ignore'`.
887
1057
  *
888
- * @param options - An object of type `QueryOptions` that allows us to
889
- * describe how this query should be treated e.g. whether it should hit the
890
- * server at all or just resolve from the cache, etc.
1058
+ * It takes options as an object with the following keys and values:
891
1059
  */
892
- query<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.QueryOptions<TData, TVariables>): Promise<ApolloClient.QueryResult<MaybeMasked<TData>, "none">>;
893
- /**
894
- * This resolves a single mutation according to the options specified and returns a
895
- * Promise which is either resolved with the resulting data or rejected with an
896
- * error. In some cases both `data` and `errors` might be undefined, for example
897
- * when `errorPolicy` is set to `'ignore'`.
898
- *
899
- * It takes options as an object with the following keys and values:
900
- */
901
- mutate<TData = unknown, TVariables extends OperationVariables = OperationVariables, TCache extends ApolloCache = ApolloCache>(options: ApolloClient.MutateOptions<TData, TVariables, TCache>): Promise<ApolloClient.MutateResult<MaybeMasked<TData>>>;
1060
+ mutate: ApolloClient.mutate.Signature;
902
1061
  /**
903
1062
  * This subscribes to a graphql subscription according to the options specified and returns an
904
1063
  * `Observable` which either emits received data or an error.