@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.
- package/CHANGELOG.md +45 -0
- package/__cjs/cache/core/cache.cjs +2 -6
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +42 -13
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/entityStore.d.cts +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/types.d.cts +1 -1
- package/__cjs/core/ApolloClient.cjs +45 -7
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +17 -4
- package/__cjs/core/ObservableQuery.cjs +40 -10
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +73 -9
- package/__cjs/core/types.d.cts +87 -10
- package/__cjs/link/http/HttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.d.cts +11 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +4 -0
- package/__cjs/react/hooks/useFragment.cjs +4 -9
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +5 -1
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +209 -10
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +270 -246
- package/__cjs/react/hooks/useQueryRefHandlers.d.cts +4 -0
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +79 -62
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +185 -161
- package/__cjs/react/index.cjs +1 -3
- package/__cjs/react/index.cjs.map +1 -1
- package/__cjs/react/index.d.cts +0 -1
- package/__cjs/react/internal/cache/FragmentReference.cjs +1 -1
- package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
- package/__cjs/react/types/types.documentation.d.cts +12 -1
- package/__cjs/utilities/internal/getStoreKeyName.cjs +8 -5
- package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
- package/__cjs/utilities/internal/index.cjs +4 -2
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +2 -0
- package/__cjs/utilities/internal/removeFragmentSpreads.cjs +14 -0
- package/__cjs/utilities/internal/removeFragmentSpreads.cjs.map +1 -0
- package/__cjs/utilities/internal/removeFragmentSpreads.d.cts +3 -0
- package/__cjs/utilities/internal/types/DocumentationTypes.cjs +3 -0
- package/__cjs/utilities/internal/types/DocumentationTypes.cjs.map +1 -0
- package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +82 -0
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.d.ts +42 -13
- package/cache/core/cache.js +2 -6
- package/cache/core/cache.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/inMemoryCache.js +1 -1
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/types.d.ts +1 -1
- package/cache/inmemory/types.js.map +1 -1
- package/core/ApolloClient.d.ts +17 -4
- package/core/ApolloClient.js +46 -8
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +73 -9
- package/core/ObservableQuery.js +40 -10
- package/core/ObservableQuery.js.map +1 -1
- package/core/types.d.ts +87 -10
- package/core/types.js.map +1 -1
- package/link/http/HttpLink.d.ts +11 -1
- package/link/http/HttpLink.js.map +1 -1
- package/package.json +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +4 -0
- package/react/hooks/useFragment.js +4 -9
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +5 -1
- package/react/hooks/useLoadableQuery.d.ts +209 -10
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts +270 -246
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +4 -0
- package/react/hooks/useSubscription.d.ts +79 -62
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +185 -161
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +4 -0
- package/react/hooks-compiled/useFragment.js +4 -9
- package/react/hooks-compiled/useFragment.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +5 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +209 -10
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +270 -246
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useQueryRefHandlers.d.ts +4 -0
- package/react/hooks-compiled/useSubscription.d.ts +79 -62
- package/react/hooks-compiled/useSubscription.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +185 -161
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/index.compiled.d.ts +0 -1
- package/react/index.compiled.js +0 -1
- package/react/index.compiled.js.map +1 -1
- package/react/index.d.ts +0 -1
- package/react/index.js +0 -1
- package/react/index.js.map +1 -1
- package/react/internal/cache/FragmentReference.js +1 -1
- package/react/internal/cache/FragmentReference.js.map +1 -1
- package/react/types/types.documentation.d.ts +12 -1
- package/react/types/types.documentation.js.map +1 -1
- package/utilities/internal/getStoreKeyName.js +8 -5
- package/utilities/internal/getStoreKeyName.js.map +1 -1
- package/utilities/internal/index.d.ts +2 -0
- package/utilities/internal/index.js +1 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/removeFragmentSpreads.d.ts +3 -0
- package/utilities/internal/removeFragmentSpreads.js +11 -0
- package/utilities/internal/removeFragmentSpreads.js.map +1 -0
- package/utilities/internal/types/DocumentationTypes.d.ts +82 -0
- package/utilities/internal/types/DocumentationTypes.js +2 -0
- package/utilities/internal/types/DocumentationTypes.js.map +1 -0
- package/version.js +1 -1
package/core/ObservableQuery.js
CHANGED
|
@@ -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:
|
|
564
|
-
*
|
|
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
|
|
570
|
-
*
|
|
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);
|