@apollo/client 4.1.0-alpha.8 → 4.1.0-rc.0
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 +67 -0
- package/__cjs/cache/core/cache.cjs +64 -24
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +47 -0
- package/__cjs/cache/core/types/Cache.d.cts +39 -0
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs +47 -0
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +47 -0
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +76 -17
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +33 -6
- package/__cjs/cache/inmemory/readFromStore.cjs +3 -3
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/types.d.cts +3 -0
- package/__cjs/cache/inmemory/writeToStore.cjs +24 -9
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +1 -1
- package/__cjs/core/ApolloClient.cjs +14 -14
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +21 -1
- package/__cjs/core/ObservableQuery.cjs +22 -8
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +1 -0
- package/__cjs/core/QueryInfo.cjs +9 -1
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +4 -3
- package/__cjs/core/QueryManager.cjs +40 -20
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +19 -2
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs +39 -0
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +1 -0
- package/__cjs/incremental/types.d.cts +9 -0
- package/__cjs/invariantErrorCodes.cjs +39 -33
- package/__cjs/link/error/index.cjs +1 -1
- package/__cjs/link/error/index.cjs.map +1 -1
- package/__cjs/link/error/index.d.cts +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.cjs +1 -0
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.cjs +7 -4
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs +2 -0
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.cjs +41 -1
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/utilities/internal/checkDocument.cjs +2 -4
- package/__cjs/utilities/internal/checkDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/constants.cjs +26 -0
- package/__cjs/utilities/internal/constants.cjs.map +1 -0
- package/__cjs/utilities/internal/constants.d.cts +23 -0
- package/__cjs/utilities/internal/index.cjs +7 -1
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +4 -0
- package/__cjs/utilities/internal/mapObservableFragment.cjs +27 -0
- package/__cjs/utilities/internal/mapObservableFragment.cjs.map +1 -0
- package/__cjs/utilities/internal/mapObservableFragment.d.cts +3 -0
- package/__cjs/utilities/internal/memoize.cjs +31 -0
- package/__cjs/utilities/internal/memoize.cjs.map +1 -0
- package/__cjs/utilities/internal/memoize.d.cts +8 -0
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.cjs +61 -0
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.cjs.map +1 -0
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.d.cts +11 -0
- package/__cjs/utilities/internal/ponyfills/index.cjs +6 -0
- package/__cjs/utilities/internal/ponyfills/index.cjs.map +1 -0
- package/__cjs/utilities/internal/ponyfills/index.d.cts +3 -0
- package/__cjs/utilities/internal/ponyfills/index.react-native.cjs +6 -0
- package/__cjs/utilities/internal/ponyfills/index.react-native.cjs.map +1 -0
- package/__cjs/utilities/internal/ponyfills/index.react-native.d.cts +2 -0
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.cjs +3 -0
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.cjs.map +1 -0
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.d.cts +12 -0
- package/__cjs/utilities/internal/types/StreamInfoTrie.cjs +3 -0
- package/__cjs/utilities/internal/types/StreamInfoTrie.cjs.map +1 -0
- package/__cjs/utilities/internal/types/StreamInfoTrie.d.cts +16 -0
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/cache/core/cache.d.ts +47 -0
- package/cache/core/cache.js +65 -25
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +39 -0
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/index.d.ts +1 -1
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +47 -0
- package/cache/inmemory/inMemoryCache.js +47 -0
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.d.ts +33 -6
- package/cache/inmemory/policies.js +65 -7
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +3 -3
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +3 -0
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +1 -1
- package/cache/inmemory/writeToStore.js +26 -11
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +21 -1
- package/core/ApolloClient.js +15 -15
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +1 -0
- package/core/ObservableQuery.js +23 -9
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +4 -3
- package/core/QueryInfo.js +10 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +19 -2
- package/core/QueryManager.js +41 -21
- package/core/QueryManager.js.map +1 -1
- package/incremental/handlers/graphql17Alpha9.d.ts +1 -0
- package/incremental/handlers/graphql17Alpha9.js +40 -1
- package/incremental/handlers/graphql17Alpha9.js.map +1 -1
- package/incremental/types.d.ts +9 -0
- package/incremental/types.js.map +1 -1
- package/invariantErrorCodes.js +39 -33
- package/legacyEntryPoints/utilities/internal/ponyfills/index.d.ts +1 -0
- package/legacyEntryPoints/utilities/internal/ponyfills/index.js +1 -0
- package/legacyEntryPoints/utilities/internal/ponyfills/ponyfills.cjs +1 -0
- package/legacyEntryPoints/utilities/internal/ponyfills/ponyfills.d.cts +1 -0
- package/link/error/index.d.ts +1 -1
- package/link/error/index.js +1 -1
- package/link/error/index.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/package.json +15 -1
- package/react/hooks/useLazyQuery.js +2 -1
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useQuery.js +8 -5
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +2 -0
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.js +2 -1
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useQuery.js +9 -5
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.js +3 -1
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.js +41 -1
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/utilities/internal/checkDocument.js +2 -4
- package/utilities/internal/checkDocument.js.map +1 -1
- package/utilities/internal/constants.d.ts +23 -0
- package/utilities/internal/constants.js +23 -0
- package/utilities/internal/constants.js.map +1 -0
- package/utilities/internal/index.d.ts +4 -0
- package/utilities/internal/index.js +2 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/mapObservableFragment.d.ts +3 -0
- package/utilities/internal/mapObservableFragment.js +24 -0
- package/utilities/internal/mapObservableFragment.js.map +1 -0
- package/utilities/internal/memoize.d.ts +8 -0
- package/utilities/internal/memoize.js +28 -0
- package/utilities/internal/memoize.js.map +1 -0
- package/utilities/internal/ponyfills/FinalizationRegistry.d.ts +11 -0
- package/utilities/internal/ponyfills/FinalizationRegistry.js +57 -0
- package/utilities/internal/ponyfills/FinalizationRegistry.js.map +1 -0
- package/utilities/internal/ponyfills/index.d.ts +3 -0
- package/utilities/internal/ponyfills/index.js +3 -0
- package/utilities/internal/ponyfills/index.js.map +1 -0
- package/utilities/internal/ponyfills/index.react-native.d.ts +2 -0
- package/utilities/internal/ponyfills/index.react-native.js +2 -0
- package/utilities/internal/ponyfills/index.react-native.js.map +1 -0
- package/utilities/internal/types/ExtensionsWithStreamDetails.d.ts +12 -0
- package/utilities/internal/types/ExtensionsWithStreamDetails.js +2 -0
- package/utilities/internal/types/ExtensionsWithStreamDetails.js.map +1 -0
- package/utilities/internal/types/StreamInfoTrie.d.ts +16 -0
- package/utilities/internal/types/StreamInfoTrie.js +2 -0
- package/utilities/internal/types/StreamInfoTrie.js.map +1 -0
- package/version.js +1 -1
- package/version.js.map +1 -1
|
@@ -7,7 +7,7 @@ import type { ClientAwarenessLink } from "@apollo/client/link/client-awareness";
|
|
|
7
7
|
import type { LocalState } from "@apollo/client/local-state";
|
|
8
8
|
import type { MaybeMasked, Unmasked } from "@apollo/client/masking";
|
|
9
9
|
import { DocumentTransform } from "@apollo/client/utilities";
|
|
10
|
-
import type { VariablesOption } from "@apollo/client/utilities/internal";
|
|
10
|
+
import type { VariablesOption, variablesUnknownSymbol } from "@apollo/client/utilities/internal";
|
|
11
11
|
import { getApolloClientMemoryInternals } from "@apollo/client/utilities/internal";
|
|
12
12
|
import type { ObservableQuery } from "./ObservableQuery.cjs";
|
|
13
13
|
import type { DefaultContext, ErrorLike, InternalRefetchQueriesInclude, InternalRefetchQueriesResult, MutationQueryReducersMap, MutationUpdaterFunction, NormalizedExecutionResult, OnQueryUpdated, OperationVariables, RefetchQueriesInclude, RefetchQueriesPromiseResults, SubscriptionObservable, TypedDocumentNode } from "./types.cjs";
|
|
@@ -482,6 +482,21 @@ export declare namespace ApolloClient {
|
|
|
482
482
|
* @docGroup 1. Operation options
|
|
483
483
|
*/
|
|
484
484
|
query: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
|
485
|
+
/**
|
|
486
|
+
* @internal This API is meant for framework integrations only.
|
|
487
|
+
* Do not use for everyday use.
|
|
488
|
+
*
|
|
489
|
+
* Indicates that the variables are unknown at the time of query creation.
|
|
490
|
+
* This option can only be set when `fetchPolicy` is `'standby'`.
|
|
491
|
+
* Setting this to `true` will prevent `client.refetchQueries` from refetching
|
|
492
|
+
* this query before it has left the `'standby'` state, either by setting a
|
|
493
|
+
* `fetchPolicy`, or by calling `observableQuery.refetch()` explicitly.
|
|
494
|
+
*
|
|
495
|
+
* Changing this option after the query has been created will have no effect.
|
|
496
|
+
*
|
|
497
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
498
|
+
*/
|
|
499
|
+
[variablesUnknownSymbol]?: boolean;
|
|
485
500
|
} & VariablesOption<NoInfer<TVariables>>;
|
|
486
501
|
namespace Base {
|
|
487
502
|
interface ReadQueryOptions<TData, TVariables extends OperationVariables> {
|
|
@@ -608,6 +623,11 @@ export declare namespace ApolloClient {
|
|
|
608
623
|
* @defaultValue false
|
|
609
624
|
*/
|
|
610
625
|
overwrite?: boolean;
|
|
626
|
+
/**
|
|
627
|
+
* GraphQL extensions for the write operation. Any provided `extensions`
|
|
628
|
+
* are available in `merge` functions.
|
|
629
|
+
*/
|
|
630
|
+
extensions?: Record<string, unknown>;
|
|
611
631
|
}
|
|
612
632
|
}
|
|
613
633
|
type WriteQueryOptions<TData, TVariables extends OperationVariables> = Base.WriteQueryOptions<TData, TVariables> & VariablesOption<TVariables>;
|
|
@@ -31,6 +31,7 @@ const empty = {
|
|
|
31
31
|
class ObservableQuery {
|
|
32
32
|
options;
|
|
33
33
|
queryName;
|
|
34
|
+
variablesUnknown = false;
|
|
34
35
|
/**
|
|
35
36
|
* @internal will be read and written from `QueryInfo`
|
|
36
37
|
*
|
|
@@ -82,6 +83,10 @@ class ObservableQuery {
|
|
|
82
83
|
const { fetchPolicy = defaultFetchPolicy,
|
|
83
84
|
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
84
85
|
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
86
|
+
if (options[internal_1.variablesUnknownSymbol]) {
|
|
87
|
+
(0, invariant_1.invariant)(fetchPolicy === "standby", 80);
|
|
88
|
+
this.variablesUnknown = true;
|
|
89
|
+
}
|
|
85
90
|
this.lastQuery = transformedQuery;
|
|
86
91
|
this.options = {
|
|
87
92
|
...options,
|
|
@@ -383,7 +388,7 @@ class ObservableQuery {
|
|
|
383
388
|
const queryDef = (0, internal_1.getQueryDefinition)(this.query);
|
|
384
389
|
const vars = queryDef.variableDefinitions;
|
|
385
390
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
386
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
391
|
+
__DEV__ && invariant_1.invariant.warn(81, variables, queryDef.name?.value || queryDef);
|
|
387
392
|
}
|
|
388
393
|
}
|
|
389
394
|
if (variables && !(0, equality_1.equal)(this.variables, variables)) {
|
|
@@ -399,7 +404,7 @@ class ObservableQuery {
|
|
|
399
404
|
fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
|
|
400
405
|
(0, invariant_1.invariant)(
|
|
401
406
|
this.options.fetchPolicy !== "cache-only",
|
|
402
|
-
|
|
407
|
+
82,
|
|
403
408
|
(0, internal_1.getOperationName)(this.query, "(anonymous)")
|
|
404
409
|
);
|
|
405
410
|
const combinedOptions = {
|
|
@@ -433,7 +438,7 @@ class ObservableQuery {
|
|
|
433
438
|
let wasUpdated = false;
|
|
434
439
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
435
440
|
if (!isCached) {
|
|
436
|
-
(0, invariant_1.invariant)(updateQuery,
|
|
441
|
+
(0, invariant_1.invariant)(updateQuery, 83);
|
|
437
442
|
}
|
|
438
443
|
const { finalize, pushNotification } = this.pushOperation(networkStatus_js_1.NetworkStatus.fetchMore);
|
|
439
444
|
pushNotification({
|
|
@@ -442,13 +447,14 @@ class ObservableQuery {
|
|
|
442
447
|
value: {},
|
|
443
448
|
}, { shouldEmit: 3 /* EmitBehavior.networkStatusChange */ });
|
|
444
449
|
const { promise, operator } = getTrackingOperatorPromise();
|
|
445
|
-
const { observable } = this.queryManager.fetchObservableWithInfo(combinedOptions, { networkStatus: networkStatus_js_1.NetworkStatus.fetchMore });
|
|
450
|
+
const { observable } = this.queryManager.fetchObservableWithInfo(combinedOptions, { networkStatus: networkStatus_js_1.NetworkStatus.fetchMore, exposeExtensions: true });
|
|
446
451
|
const subscription = observable
|
|
447
452
|
.pipe(operator, (0, rxjs_1.filter)((notification) => notification.kind === "N" && notification.source === "network"))
|
|
448
453
|
.subscribe({
|
|
449
454
|
next: (notification) => {
|
|
450
455
|
wasUpdated = false;
|
|
451
456
|
const fetchMoreResult = notification.value;
|
|
457
|
+
const extensions = fetchMoreResult[internal_1.extensionsSymbol];
|
|
452
458
|
if ((0, utilities_1.isNetworkRequestSettled)(notification.value.networkStatus)) {
|
|
453
459
|
finalize();
|
|
454
460
|
}
|
|
@@ -469,6 +475,7 @@ class ObservableQuery {
|
|
|
469
475
|
variables: this.variables,
|
|
470
476
|
returnPartialData: true,
|
|
471
477
|
optimistic: false,
|
|
478
|
+
extensions,
|
|
472
479
|
}, (previous) => updateQuery(previous, {
|
|
473
480
|
fetchMoreResult: fetchMoreResult.data,
|
|
474
481
|
variables: combinedOptions.variables,
|
|
@@ -484,6 +491,7 @@ class ObservableQuery {
|
|
|
484
491
|
query: combinedOptions.query,
|
|
485
492
|
variables: combinedOptions.variables,
|
|
486
493
|
data: fetchMoreResult.data,
|
|
494
|
+
extensions,
|
|
487
495
|
});
|
|
488
496
|
}
|
|
489
497
|
},
|
|
@@ -606,7 +614,7 @@ class ObservableQuery {
|
|
|
606
614
|
onError(error);
|
|
607
615
|
}
|
|
608
616
|
else {
|
|
609
|
-
invariant_1.invariant.error(
|
|
617
|
+
invariant_1.invariant.error(84, error);
|
|
610
618
|
}
|
|
611
619
|
return;
|
|
612
620
|
}
|
|
@@ -850,7 +858,7 @@ class ObservableQuery {
|
|
|
850
858
|
if (!this.didWarnCacheOnlyPolling &&
|
|
851
859
|
pollInterval &&
|
|
852
860
|
fetchPolicy === "cache-only") {
|
|
853
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
861
|
+
__DEV__ && invariant_1.invariant.warn(85, (0, internal_1.getOperationName)(this.query, "(anonymous)"));
|
|
854
862
|
this.didWarnCacheOnlyPolling = true;
|
|
855
863
|
}
|
|
856
864
|
}
|
|
@@ -925,6 +933,10 @@ class ObservableQuery {
|
|
|
925
933
|
const oldVariables = this.variables;
|
|
926
934
|
const oldFetchPolicy = this.options.fetchPolicy;
|
|
927
935
|
const mergedOptions = (0, internal_1.compact)(this.options, newOptions || {});
|
|
936
|
+
// This request will hit the network, so even if there are no variables,
|
|
937
|
+
// we now know that's intentional. (see #12996)
|
|
938
|
+
// Even if that happens only once, we want `variablesUnknown` to stay false permanently.
|
|
939
|
+
this.variablesUnknown &&= mergedOptions.fetchPolicy === "standby";
|
|
928
940
|
const options = useDisposableObservable ?
|
|
929
941
|
// Disposable Observable fetches receive a shallow copy of this.options
|
|
930
942
|
// (merged with newOptions), leaving this.options unmodified.
|
|
@@ -1194,7 +1206,9 @@ class ObservableQuery {
|
|
|
1194
1206
|
// "fetchMore" having priority over "polling" or "loading" network statuses
|
|
1195
1207
|
// as for now we just take the "latest" operation that is still active,
|
|
1196
1208
|
// as that lines up best with previous behavior[]
|
|
1197
|
-
const operation = Array.from(this.activeOperations.values())
|
|
1209
|
+
const operation = Array.from(this.activeOperations.values())
|
|
1210
|
+
.reverse()
|
|
1211
|
+
.find((operation) => isEqualQuery(operation, this) && operation.override !== undefined);
|
|
1198
1212
|
return operation?.override ?? baseNetworkStatus;
|
|
1199
1213
|
}
|
|
1200
1214
|
abortActiveOperations() {
|
|
@@ -1339,7 +1353,7 @@ class ObservableQuery {
|
|
|
1339
1353
|
exports.ObservableQuery = ObservableQuery;
|
|
1340
1354
|
function logMissingFieldErrors(missing) {
|
|
1341
1355
|
if (environment_1.__DEV__ && missing) {
|
|
1342
|
-
__DEV__ && invariant_1.invariant.debug(
|
|
1356
|
+
__DEV__ && invariant_1.invariant.debug(86, missing);
|
|
1343
1357
|
}
|
|
1344
1358
|
}
|
|
1345
1359
|
function isEqualQuery(a, b) {
|