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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/__cjs/cache/core/cache.cjs +2 -6
  3. package/__cjs/cache/core/cache.cjs.map +1 -1
  4. package/__cjs/cache/core/cache.d.cts +42 -13
  5. package/__cjs/cache/inmemory/entityStore.cjs +3 -3
  6. package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
  7. package/__cjs/cache/inmemory/entityStore.d.cts +1 -1
  8. package/__cjs/cache/inmemory/inMemoryCache.cjs +1 -1
  9. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  10. package/__cjs/cache/inmemory/types.d.cts +1 -1
  11. package/__cjs/core/ApolloClient.cjs +45 -7
  12. package/__cjs/core/ApolloClient.cjs.map +1 -1
  13. package/__cjs/core/ApolloClient.d.cts +17 -4
  14. package/__cjs/core/ObservableQuery.cjs +40 -10
  15. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  16. package/__cjs/core/ObservableQuery.d.cts +73 -9
  17. package/__cjs/core/types.d.cts +87 -10
  18. package/__cjs/link/http/HttpLink.cjs.map +1 -1
  19. package/__cjs/link/http/HttpLink.d.cts +11 -1
  20. package/__cjs/react/hooks/useBackgroundQuery.d.cts +4 -0
  21. package/__cjs/react/hooks/useFragment.cjs +4 -9
  22. package/__cjs/react/hooks/useFragment.cjs.map +1 -1
  23. package/__cjs/react/hooks/useLazyQuery.d.cts +5 -1
  24. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  25. package/__cjs/react/hooks/useLoadableQuery.d.cts +209 -10
  26. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  27. package/__cjs/react/hooks/useQuery.d.cts +270 -246
  28. package/__cjs/react/hooks/useQueryRefHandlers.d.cts +4 -0
  29. package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
  30. package/__cjs/react/hooks/useSubscription.d.cts +79 -62
  31. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  32. package/__cjs/react/hooks/useSuspenseQuery.d.cts +185 -161
  33. package/__cjs/react/index.cjs +1 -3
  34. package/__cjs/react/index.cjs.map +1 -1
  35. package/__cjs/react/index.d.cts +0 -1
  36. package/__cjs/react/internal/cache/FragmentReference.cjs +1 -1
  37. package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
  38. package/__cjs/react/types/types.documentation.d.cts +12 -1
  39. package/__cjs/utilities/internal/getStoreKeyName.cjs +8 -5
  40. package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
  41. package/__cjs/utilities/internal/index.cjs +4 -2
  42. package/__cjs/utilities/internal/index.cjs.map +1 -1
  43. package/__cjs/utilities/internal/index.d.cts +2 -0
  44. package/__cjs/utilities/internal/removeFragmentSpreads.cjs +14 -0
  45. package/__cjs/utilities/internal/removeFragmentSpreads.cjs.map +1 -0
  46. package/__cjs/utilities/internal/removeFragmentSpreads.d.cts +3 -0
  47. package/__cjs/utilities/internal/types/DocumentationTypes.cjs +3 -0
  48. package/__cjs/utilities/internal/types/DocumentationTypes.cjs.map +1 -0
  49. package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +82 -0
  50. package/__cjs/version.cjs +1 -1
  51. package/cache/core/cache.d.ts +42 -13
  52. package/cache/core/cache.js +2 -6
  53. package/cache/core/cache.js.map +1 -1
  54. package/cache/inmemory/entityStore.d.ts +1 -1
  55. package/cache/inmemory/entityStore.js +3 -3
  56. package/cache/inmemory/entityStore.js.map +1 -1
  57. package/cache/inmemory/inMemoryCache.js +1 -1
  58. package/cache/inmemory/inMemoryCache.js.map +1 -1
  59. package/cache/inmemory/types.d.ts +1 -1
  60. package/cache/inmemory/types.js.map +1 -1
  61. package/core/ApolloClient.d.ts +17 -4
  62. package/core/ApolloClient.js +46 -8
  63. package/core/ApolloClient.js.map +1 -1
  64. package/core/ObservableQuery.d.ts +73 -9
  65. package/core/ObservableQuery.js +40 -10
  66. package/core/ObservableQuery.js.map +1 -1
  67. package/core/types.d.ts +87 -10
  68. package/core/types.js.map +1 -1
  69. package/link/http/HttpLink.d.ts +11 -1
  70. package/link/http/HttpLink.js.map +1 -1
  71. package/package.json +1 -1
  72. package/react/hooks/useBackgroundQuery.d.ts +4 -0
  73. package/react/hooks/useFragment.js +4 -9
  74. package/react/hooks/useFragment.js.map +1 -1
  75. package/react/hooks/useLazyQuery.d.ts +5 -1
  76. package/react/hooks/useLoadableQuery.d.ts +209 -10
  77. package/react/hooks/useLoadableQuery.js.map +1 -1
  78. package/react/hooks/useQuery.d.ts +270 -246
  79. package/react/hooks/useQuery.js.map +1 -1
  80. package/react/hooks/useQueryRefHandlers.d.ts +4 -0
  81. package/react/hooks/useSubscription.d.ts +79 -62
  82. package/react/hooks/useSubscription.js.map +1 -1
  83. package/react/hooks/useSuspenseQuery.d.ts +185 -161
  84. package/react/hooks/useSuspenseQuery.js.map +1 -1
  85. package/react/hooks-compiled/useBackgroundQuery.d.ts +4 -0
  86. package/react/hooks-compiled/useFragment.js +4 -9
  87. package/react/hooks-compiled/useFragment.js.map +1 -1
  88. package/react/hooks-compiled/useLazyQuery.d.ts +5 -1
  89. package/react/hooks-compiled/useLoadableQuery.d.ts +209 -10
  90. package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
  91. package/react/hooks-compiled/useQuery.d.ts +270 -246
  92. package/react/hooks-compiled/useQuery.js.map +1 -1
  93. package/react/hooks-compiled/useQueryRefHandlers.d.ts +4 -0
  94. package/react/hooks-compiled/useSubscription.d.ts +79 -62
  95. package/react/hooks-compiled/useSubscription.js.map +1 -1
  96. package/react/hooks-compiled/useSuspenseQuery.d.ts +185 -161
  97. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  98. package/react/index.compiled.d.ts +0 -1
  99. package/react/index.compiled.js +0 -1
  100. package/react/index.compiled.js.map +1 -1
  101. package/react/index.d.ts +0 -1
  102. package/react/index.js +0 -1
  103. package/react/index.js.map +1 -1
  104. package/react/internal/cache/FragmentReference.js +1 -1
  105. package/react/internal/cache/FragmentReference.js.map +1 -1
  106. package/react/types/types.documentation.d.ts +12 -1
  107. package/react/types/types.documentation.js.map +1 -1
  108. package/utilities/internal/getStoreKeyName.js +8 -5
  109. package/utilities/internal/getStoreKeyName.js.map +1 -1
  110. package/utilities/internal/index.d.ts +2 -0
  111. package/utilities/internal/index.js +1 -0
  112. package/utilities/internal/index.js.map +1 -1
  113. package/utilities/internal/removeFragmentSpreads.d.ts +3 -0
  114. package/utilities/internal/removeFragmentSpreads.js +11 -0
  115. package/utilities/internal/removeFragmentSpreads.js.map +1 -0
  116. package/utilities/internal/types/DocumentationTypes.d.ts +82 -0
  117. package/utilities/internal/types/DocumentationTypes.js +2 -0
  118. package/utilities/internal/types/DocumentationTypes.js.map +1 -0
  119. package/version.js +1 -1
@@ -162,7 +162,32 @@ export class ObservableQuery {
162
162
  // We can't use Observable['subscribe'] here as the type as it conflicts with
163
163
  // the ability to infer T from Subscribable<T>. This limits the surface area
164
164
  // to the non-deprecated signature which works properly with type inference.
165
+ /**
166
+ * Subscribes to the `ObservableQuery`.
167
+ * @param observerOrNext - Either an RxJS `Observer` with some or all callback methods,
168
+ * or the `next` handler that is called for each value emitted from the subscribed Observable.
169
+ * @returns A subscription reference to the registered handlers.
170
+ */
165
171
  subscribe;
172
+ /**
173
+ * Used to stitch together functional operators into a chain.
174
+ *
175
+ * @example
176
+ *
177
+ * ```ts
178
+ * import { filter, map } from 'rxjs';
179
+ *
180
+ * observableQuery
181
+ * .pipe(
182
+ * filter(...),
183
+ * map(...),
184
+ * )
185
+ * .subscribe(x => console.log(x));
186
+ * ```
187
+ *
188
+ * @returns The Observable result of all the operators having been called
189
+ * in the order they were passed in.
190
+ */
166
191
  pipe;
167
192
  [Symbol.observable];
168
193
  ["@@observable"];
@@ -318,6 +343,13 @@ export class ObservableQuery {
318
343
  * Update the variables of this observable query, and fetch the new results.
319
344
  * This method should be preferred over `setVariables` in most use cases.
320
345
  *
346
+ * Returns a `ResultPromise` with an additional `.retain()` method. Calling
347
+ * `.retain()` keeps the network operation running even if the `ObservableQuery`
348
+ * no longer requires the result.
349
+ *
350
+ * Note: `refetch()` guarantees that a value will be emitted from the
351
+ * observable, even if the result is deep equal to the previous value.
352
+ *
321
353
  * @param variables - The new set of variables. If there are missing variables,
322
354
  * the previous values of those variables will be used.
323
355
  */
@@ -353,9 +385,6 @@ export class ObservableQuery {
353
385
  newNetworkStatus: NetworkStatus.refetch,
354
386
  });
355
387
  }
356
- /**
357
- * A function that helps you fetch the next set of results for a [paginated list field](https://www.apollographql.com/docs/react/pagination/core-api/).
358
- */
359
388
  fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
360
389
  invariant(
361
390
  this.options.fetchPolicy !== "cache-only",
@@ -560,14 +589,12 @@ export class ObservableQuery {
560
589
  * `setVariables` in order to to be properly notified of results even when
561
590
  * they come from the cache.
562
591
  *
563
- * Note: the `next` callback will *not* fire if the variables have not changed
564
- * or if the result is coming from cache.
565
- *
566
- * Note: the promise will return the old results immediately if the variables
567
- * have not changed.
592
+ * Note: `setVariables()` guarantees that a value will be emitted from the
593
+ * observable, even if the result is deeply equal to the previous value.
568
594
  *
569
- * Note: the promise will return the last result immediately if the query is not active
570
- * (there are no subscribers).
595
+ * Note: the promise will resolve with the last emitted result
596
+ * when either the variables match the current variables or there
597
+ * are no subscribers to the query.
571
598
  *
572
599
  * @param variables - The new set of variables. If there are missing variables,
573
600
  * the previous values of those variables will be used.
@@ -823,6 +850,9 @@ export class ObservableQuery {
823
850
  /**
824
851
  * Reevaluate the query, optionally against new options. New options will be
825
852
  * merged with the current options when given.
853
+ *
854
+ * Note: `variables` can be reset back to their defaults (typically empty) by calling `reobserve` with
855
+ * `variables: undefined`.
826
856
  */
827
857
  reobserve(newOptions) {
828
858
  return this._reobserve(newOptions);