@apollo/client 4.0.0-alpha.20 → 4.0.0-alpha.22
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 +113 -0
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/core/ApolloClient.cjs +22 -19
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +7 -8
- package/__cjs/core/ObservableQuery.cjs +15 -11
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +1 -2
- package/__cjs/core/QueryInfo.cjs +223 -34
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +34 -24
- package/__cjs/core/QueryManager.cjs +89 -265
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +13 -38
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +1 -1
- package/__cjs/core/networkStatus.cjs +7 -1
- package/__cjs/core/networkStatus.cjs.map +1 -1
- package/__cjs/core/networkStatus.d.cts +7 -1
- package/__cjs/core/types.d.cts +5 -4
- package/__cjs/invariantErrorCodes.cjs +99 -104
- package/__cjs/link/batch-http/batchHttpLink.cjs +14 -14
- package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
- package/__cjs/link/batch-http/batchHttpLink.d.cts +4 -0
- package/__cjs/link/batch-http/index.cjs +2 -1
- package/__cjs/link/batch-http/index.cjs.map +1 -1
- package/__cjs/link/batch-http/index.d.cts +1 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +45 -0
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -0
- package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +62 -0
- package/__cjs/link/client-awareness/index.cjs +6 -0
- package/__cjs/link/client-awareness/index.cjs.map +1 -0
- package/__cjs/link/client-awareness/index.d.cts +2 -0
- package/__cjs/link/core/ApolloLink.cjs +2 -2
- package/__cjs/link/core/types.d.cts +1 -6
- package/__cjs/link/http/BaseHttpLink.cjs +117 -0
- package/__cjs/link/http/BaseHttpLink.cjs.map +1 -0
- package/__cjs/link/http/BaseHttpLink.d.cts +6 -0
- package/__cjs/link/http/HttpLink.cjs +8 -5
- package/__cjs/link/http/HttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.d.cts +16 -4
- package/__cjs/link/http/index.cjs +4 -3
- package/__cjs/link/http/index.cjs.map +1 -1
- package/__cjs/link/http/index.d.cts +2 -2
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/http/selectHttpOptionsAndBody.cjs +6 -5
- package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
- package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
- package/__cjs/link/persisted-queries/index.cjs +7 -5
- package/__cjs/link/persisted-queries/index.cjs.map +1 -1
- package/__cjs/local-state/LocalState.cjs +0 -8
- package/__cjs/local-state/LocalState.cjs.map +1 -1
- package/__cjs/masking/maskDefinition.cjs +2 -2
- package/__cjs/masking/maskDefinition.cjs.map +1 -1
- package/__cjs/masking/maskFragment.cjs +2 -10
- package/__cjs/masking/maskFragment.cjs.map +1 -1
- package/__cjs/masking/maskOperation.cjs +1 -9
- package/__cjs/masking/maskOperation.cjs.map +1 -1
- package/__cjs/masking/utils.cjs +0 -8
- package/__cjs/masking/utils.cjs.map +1 -1
- package/__cjs/masking/utils.d.cts +0 -1
- package/__cjs/react/context/ApolloConsumer.cjs +1 -1
- package/__cjs/react/context/ApolloContext.cjs +1 -1
- package/__cjs/react/context/ApolloProvider.cjs +1 -1
- package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs +2 -2
- package/__cjs/react/hooks/useApolloClient.cjs +1 -1
- package/__cjs/react/hooks/useLazyQuery.cjs +3 -4
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +0 -8
- package/__cjs/react/hooks/useLoadableQuery.cjs +2 -2
- package/__cjs/react/hooks/useSubscription.cjs +1 -1
- package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
- package/__cjs/react/internal/cache/QueryReference.cjs +1 -1
- package/__cjs/react/ssr/prerenderStatic.cjs +2 -2
- package/__cjs/testing/core/mocking/mockLink.cjs +4 -4
- package/__cjs/utilities/caching/sizes.cjs.map +1 -1
- package/__cjs/utilities/caching/sizes.d.cts +6 -0
- package/__cjs/utilities/graphql/DocumentTransform.cjs +1 -1
- package/__cjs/utilities/index.cjs +1 -16
- package/__cjs/utilities/index.cjs.map +1 -1
- package/__cjs/utilities/index.d.cts +0 -13
- package/__cjs/utilities/internal/checkDocument.cjs +47 -13
- package/__cjs/utilities/internal/checkDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/checkDocument.d.cts +1 -1
- package/__cjs/utilities/internal/getFragmentDefinition.cjs +3 -3
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs +1 -1
- package/__cjs/utilities/internal/getFragmentQueryDocument.cjs +2 -2
- package/__cjs/utilities/internal/getMainDefinition.cjs +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.cjs +1 -0
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.d.cts +0 -1
- package/__cjs/utilities/internal/getQueryDefinition.cjs +1 -1
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +1 -1
- package/__cjs/utilities/internal/shouldInclude.cjs +4 -4
- package/__cjs/utilities/internal/valueToObjectRepresentation.cjs +1 -1
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.js +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/ApolloClient.d.ts +7 -8
- package/core/ApolloClient.js +23 -20
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +1 -2
- package/core/ObservableQuery.js +15 -11
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +34 -24
- package/core/QueryInfo.js +221 -34
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +13 -38
- package/core/QueryManager.js +91 -267
- package/core/QueryManager.js.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js.map +1 -1
- package/core/networkStatus.d.ts +7 -1
- package/core/networkStatus.js +7 -1
- package/core/networkStatus.js.map +1 -1
- package/core/types.d.ts +5 -4
- package/invariantErrorCodes.js +99 -104
- package/legacyEntryPoints/link/client-awareness/client-awareness.cjs +1 -0
- package/legacyEntryPoints/link/client-awareness/client-awareness.d.cts +1 -0
- package/legacyEntryPoints/link/client-awareness/index.d.ts +1 -0
- package/legacyEntryPoints/link/client-awareness/index.js +1 -0
- package/link/batch-http/batchHttpLink.d.ts +4 -0
- package/link/batch-http/batchHttpLink.js +11 -12
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/batch-http/index.d.ts +1 -1
- package/link/batch-http/index.js +1 -1
- package/link/batch-http/index.js.map +1 -1
- package/link/client-awareness/ClientAwarenessLink.d.ts +62 -0
- package/link/client-awareness/ClientAwarenessLink.js +41 -0
- package/link/client-awareness/ClientAwarenessLink.js.map +1 -0
- package/link/client-awareness/index.d.ts +2 -0
- package/link/client-awareness/index.js +2 -0
- package/link/client-awareness/index.js.map +1 -0
- package/link/core/ApolloLink.js +2 -2
- package/link/core/types.d.ts +1 -6
- package/link/http/BaseHttpLink.d.ts +6 -0
- package/link/http/BaseHttpLink.js +113 -0
- package/link/http/BaseHttpLink.js.map +1 -0
- package/link/http/HttpLink.d.ts +16 -4
- package/link/http/HttpLink.js +6 -4
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/index.d.ts +2 -2
- package/link/http/index.js +2 -2
- package/link/http/index.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/http/selectHttpOptionsAndBody.js +6 -5
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.js +7 -5
- package/link/persisted-queries/index.js.map +1 -1
- package/local-state/LocalState.js +0 -8
- package/local-state/LocalState.js.map +1 -1
- package/masking/maskDefinition.js +2 -2
- package/masking/maskDefinition.js.map +1 -1
- package/masking/maskFragment.js +2 -10
- package/masking/maskFragment.js.map +1 -1
- package/masking/maskOperation.js +1 -9
- package/masking/maskOperation.js.map +1 -1
- package/masking/utils.d.ts +0 -1
- package/masking/utils.js +0 -7
- package/masking/utils.js.map +1 -1
- package/package.json +7 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/hooks/internal/validateSuspenseHookOptions.js +2 -2
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useLazyQuery.d.ts +0 -8
- package/react/hooks/useLazyQuery.js +3 -4
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.js +2 -2
- package/react/hooks/useSubscription.js +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/internal/cache/QueryReference.js +1 -1
- package/react/ssr/prerenderStatic.js +2 -2
- package/testing/core/mocking/mockLink.js +4 -4
- package/utilities/caching/sizes.d.ts +6 -0
- package/utilities/caching/sizes.js.map +1 -1
- package/utilities/graphql/DocumentTransform.js +1 -1
- package/utilities/index.d.ts +0 -13
- package/utilities/index.js +0 -12
- package/utilities/index.js.map +1 -1
- package/utilities/internal/checkDocument.d.ts +1 -1
- package/utilities/internal/checkDocument.js +46 -12
- package/utilities/internal/checkDocument.js.map +1 -1
- package/utilities/internal/getFragmentDefinition.js +3 -3
- package/utilities/internal/getFragmentFromSelection.js +1 -1
- package/utilities/internal/getFragmentQueryDocument.js +2 -2
- package/utilities/internal/getMainDefinition.js +1 -1
- package/utilities/internal/getMemoryInternals.d.ts +0 -1
- package/utilities/internal/getMemoryInternals.js +1 -0
- package/utilities/internal/getMemoryInternals.js.map +1 -1
- package/utilities/internal/getQueryDefinition.js +1 -1
- package/utilities/internal/removeDirectivesFromDocument.js +1 -1
- package/utilities/internal/shouldInclude.js +4 -4
- package/utilities/internal/valueToObjectRepresentation.js +1 -1
- package/version.js +1 -1
- package/__cjs/link/http/createHttpLink.cjs +0 -151
- package/__cjs/link/http/createHttpLink.cjs.map +0 -1
- package/__cjs/link/http/createHttpLink.d.cts +0 -4
- package/link/http/createHttpLink.d.ts +0 -4
- package/link/http/createHttpLink.js +0 -143
- package/link/http/createHttpLink.js.map +0 -1
package/core/ObservableQuery.js
CHANGED
|
@@ -5,7 +5,6 @@ import { compact, filterMap, getOperationDefinition, getQueryDefinition, prevent
|
|
|
5
5
|
import { invariant } from "@apollo/client/utilities/invariant";
|
|
6
6
|
import { equalByQuery } from "./equalByQuery.js";
|
|
7
7
|
import { isNetworkRequestInFlight, NetworkStatus } from "./networkStatus.js";
|
|
8
|
-
import { QueryInfo } from "./QueryInfo.js";
|
|
9
8
|
const { assign, hasOwnProperty } = Object;
|
|
10
9
|
const uninitialized = {
|
|
11
10
|
loading: true,
|
|
@@ -346,7 +345,7 @@ export class ObservableQuery {
|
|
|
346
345
|
const queryDef = getQueryDefinition(this.query);
|
|
347
346
|
const vars = queryDef.variableDefinitions;
|
|
348
347
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
349
|
-
__DEV__ && invariant.warn(
|
|
348
|
+
__DEV__ && invariant.warn(78, variables, queryDef.name?.value || queryDef);
|
|
350
349
|
}
|
|
351
350
|
}
|
|
352
351
|
if (variables && !equal(this.variables, variables)) {
|
|
@@ -395,7 +394,7 @@ export class ObservableQuery {
|
|
|
395
394
|
const updateQuery = fetchMoreOptions?.updateQuery;
|
|
396
395
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
397
396
|
if (!isCached) {
|
|
398
|
-
invariant(updateQuery,
|
|
397
|
+
invariant(updateQuery, 79);
|
|
399
398
|
}
|
|
400
399
|
const { finalize, pushNotification } = this.pushOperation(NetworkStatus.fetchMore);
|
|
401
400
|
pushNotification({
|
|
@@ -528,7 +527,7 @@ export class ObservableQuery {
|
|
|
528
527
|
onError(error);
|
|
529
528
|
}
|
|
530
529
|
else {
|
|
531
|
-
__DEV__ && invariant.error(
|
|
530
|
+
__DEV__ && invariant.error(80, error);
|
|
532
531
|
}
|
|
533
532
|
return;
|
|
534
533
|
}
|
|
@@ -667,10 +666,6 @@ export class ObservableQuery {
|
|
|
667
666
|
// TODO Make sure we update the networkStatus (and infer fetchVariables)
|
|
668
667
|
// before actually committing to the fetch.
|
|
669
668
|
const initialFetchPolicy = this.options.fetchPolicy;
|
|
670
|
-
const queryInfo = new QueryInfo({
|
|
671
|
-
queryManager: this.queryManager,
|
|
672
|
-
observableQuery: this,
|
|
673
|
-
});
|
|
674
669
|
options.context ??= {};
|
|
675
670
|
let synchronouslyEmitted = false;
|
|
676
671
|
const onCacheHit = () => {
|
|
@@ -716,7 +711,13 @@ export class ObservableQuery {
|
|
|
716
711
|
}
|
|
717
712
|
}
|
|
718
713
|
});
|
|
719
|
-
let { observable, fromLink } = this.queryManager.fetchObservableWithInfo(
|
|
714
|
+
let { observable, fromLink } = this.queryManager.fetchObservableWithInfo(options, {
|
|
715
|
+
networkStatus,
|
|
716
|
+
query: fetchQuery,
|
|
717
|
+
onCacheHit,
|
|
718
|
+
fetchQueryOperator,
|
|
719
|
+
observableQuery: this,
|
|
720
|
+
});
|
|
720
721
|
// track query and variables from the start of the operation
|
|
721
722
|
const { query, variables } = this;
|
|
722
723
|
const operation = {
|
|
@@ -772,7 +773,7 @@ export class ObservableQuery {
|
|
|
772
773
|
if (pollingInfo && pollingInfo.interval === pollInterval) {
|
|
773
774
|
return;
|
|
774
775
|
}
|
|
775
|
-
invariant(pollInterval,
|
|
776
|
+
invariant(pollInterval, 81);
|
|
776
777
|
const info = pollingInfo || (this.pollingInfo = {});
|
|
777
778
|
info.interval = pollInterval;
|
|
778
779
|
const maybeFetch = () => {
|
|
@@ -1108,6 +1109,9 @@ export class ObservableQuery {
|
|
|
1108
1109
|
};
|
|
1109
1110
|
}
|
|
1110
1111
|
calculateNetworkStatus(baseNetworkStatus) {
|
|
1112
|
+
if (baseNetworkStatus === NetworkStatus.streaming) {
|
|
1113
|
+
return baseNetworkStatus;
|
|
1114
|
+
}
|
|
1111
1115
|
// in the future, this could be more complex logic, e.g. "refetch" and
|
|
1112
1116
|
// "fetchMore" having priority over "polling" or "loading" network statuses
|
|
1113
1117
|
// as for now we just take the "latest" operation that is still active,
|
|
@@ -1255,7 +1259,7 @@ export class ObservableQuery {
|
|
|
1255
1259
|
}
|
|
1256
1260
|
export function logMissingFieldErrors(missing) {
|
|
1257
1261
|
if (__DEV__ && missing) {
|
|
1258
|
-
__DEV__ && invariant.debug(
|
|
1262
|
+
__DEV__ && invariant.debug(82, missing);
|
|
1259
1263
|
}
|
|
1260
1264
|
}
|
|
1261
1265
|
function isEqualQuery(a, b) {
|