@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
@@ -170,7 +170,32 @@ class ObservableQuery {
170
170
  // We can't use Observable['subscribe'] here as the type as it conflicts with
171
171
  // the ability to infer T from Subscribable<T>. This limits the surface area
172
172
  // to the non-deprecated signature which works properly with type inference.
173
+ /**
174
+ * Subscribes to the `ObservableQuery`.
175
+ * @param observerOrNext - Either an RxJS `Observer` with some or all callback methods,
176
+ * or the `next` handler that is called for each value emitted from the subscribed Observable.
177
+ * @returns A subscription reference to the registered handlers.
178
+ */
173
179
  subscribe;
180
+ /**
181
+ * Used to stitch together functional operators into a chain.
182
+ *
183
+ * @example
184
+ *
185
+ * ```ts
186
+ * import { filter, map } from 'rxjs';
187
+ *
188
+ * observableQuery
189
+ * .pipe(
190
+ * filter(...),
191
+ * map(...),
192
+ * )
193
+ * .subscribe(x => console.log(x));
194
+ * ```
195
+ *
196
+ * @returns The Observable result of all the operators having been called
197
+ * in the order they were passed in.
198
+ */
174
199
  pipe;
175
200
  [Symbol.observable];
176
201
  ["@@observable"];
@@ -326,6 +351,13 @@ class ObservableQuery {
326
351
  * Update the variables of this observable query, and fetch the new results.
327
352
  * This method should be preferred over `setVariables` in most use cases.
328
353
  *
354
+ * Returns a `ResultPromise` with an additional `.retain()` method. Calling
355
+ * `.retain()` keeps the network operation running even if the `ObservableQuery`
356
+ * no longer requires the result.
357
+ *
358
+ * Note: `refetch()` guarantees that a value will be emitted from the
359
+ * observable, even if the result is deep equal to the previous value.
360
+ *
329
361
  * @param variables - The new set of variables. If there are missing variables,
330
362
  * the previous values of those variables will be used.
331
363
  */
@@ -361,9 +393,6 @@ class ObservableQuery {
361
393
  newNetworkStatus: networkStatus_js_1.NetworkStatus.refetch,
362
394
  });
363
395
  }
364
- /**
365
- * 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/).
366
- */
367
396
  fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
368
397
  (0, invariant_1.invariant)(
369
398
  this.options.fetchPolicy !== "cache-only",
@@ -568,14 +597,12 @@ class ObservableQuery {
568
597
  * `setVariables` in order to to be properly notified of results even when
569
598
  * they come from the cache.
570
599
  *
571
- * Note: the `next` callback will *not* fire if the variables have not changed
572
- * or if the result is coming from cache.
573
- *
574
- * Note: the promise will return the old results immediately if the variables
575
- * have not changed.
600
+ * Note: `setVariables()` guarantees that a value will be emitted from the
601
+ * observable, even if the result is deeply equal to the previous value.
576
602
  *
577
- * Note: the promise will return the last result immediately if the query is not active
578
- * (there are no subscribers).
603
+ * Note: the promise will resolve with the last emitted result
604
+ * when either the variables match the current variables or there
605
+ * are no subscribers to the query.
579
606
  *
580
607
  * @param variables - The new set of variables. If there are missing variables,
581
608
  * the previous values of those variables will be used.
@@ -831,6 +858,9 @@ class ObservableQuery {
831
858
  /**
832
859
  * Reevaluate the query, optionally against new options. New options will be
833
860
  * merged with the current options when given.
861
+ *
862
+ * Note: `variables` can be reset back to their defaults (typically empty) by calling `reobserve` with
863
+ * `variables: undefined`.
834
864
  */
835
865
  reobserve(newOptions) {
836
866
  return this._reobserve(newOptions);