@apollo/client 4.3.0-alpha.5 → 4.3.0-alpha.7
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 +22 -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 +28 -6
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +3 -3
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/core/ObservableQuery.cjs +175 -62
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +4 -7
- package/__cjs/core/QueryInfo.cjs +13 -136
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +2 -26
- package/__cjs/core/QueryManager.cjs +26 -25
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/RefetchEventManager.cjs +3 -3
- package/__cjs/invariantErrorCodes.cjs +57 -32
- package/__cjs/utilities/internal/index.cjs +3 -1
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +1 -0
- package/__cjs/utilities/internal/toDiffWithDataState.cjs +20 -0
- package/__cjs/utilities/internal/toDiffWithDataState.cjs.map +1 -0
- package/__cjs/utilities/internal/toDiffWithDataState.d.cts +8 -0
- 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 +28 -6
- 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/writeToStore.js +4 -4
- package/core/ObservableQuery.d.ts +4 -7
- package/core/ObservableQuery.js +172 -63
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +3 -27
- package/core/QueryInfo.js +14 -137
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +26 -25
- package/core/QueryManager.js.map +1 -1
- package/core/RefetchEventManager.js +3 -3
- package/invariantErrorCodes.js +57 -32
- package/package.json +1 -1
- package/utilities/internal/index.d.ts +1 -0
- package/utilities/internal/index.js +1 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/toDiffWithDataState.d.ts +8 -0
- package/utilities/internal/toDiffWithDataState.js +17 -0
- package/utilities/internal/toDiffWithDataState.js.map +1 -0
- package/version.js +1 -1
|
@@ -106,7 +106,7 @@ class QueryManager {
|
|
|
106
106
|
*/
|
|
107
107
|
stop() {
|
|
108
108
|
this.obsQueries.forEach((oq) => oq.stop());
|
|
109
|
-
this.cancelPendingFetches((0, invariant_1.newInvariantError)(
|
|
109
|
+
this.cancelPendingFetches((0, invariant_1.newInvariantError)(91));
|
|
110
110
|
}
|
|
111
111
|
cancelPendingFetches(error) {
|
|
112
112
|
this.fetchCancelFns.forEach((cancel) => cancel(error));
|
|
@@ -121,7 +121,7 @@ class QueryManager {
|
|
|
121
121
|
if (environment_1.__DEV__) {
|
|
122
122
|
(0, invariant_1.invariant)(
|
|
123
123
|
this.localState,
|
|
124
|
-
|
|
124
|
+
92,
|
|
125
125
|
(0, internal_1.getOperationName)(mutation, "(anonymous)")
|
|
126
126
|
);
|
|
127
127
|
}
|
|
@@ -356,7 +356,7 @@ class QueryManager {
|
|
|
356
356
|
// depend on values that previously existed in the data portion of the
|
|
357
357
|
// store. So, we cancel the promises and observers that we have issued
|
|
358
358
|
// so far and not yet resolved (in the case of queries).
|
|
359
|
-
this.cancelPendingFetches((0, invariant_1.newInvariantError)(
|
|
359
|
+
this.cancelPendingFetches((0, invariant_1.newInvariantError)(93));
|
|
360
360
|
this.obsQueries.forEach((observableQuery) => {
|
|
361
361
|
// Set loading to true so listeners don't trigger unless they want
|
|
362
362
|
// results with partial data.
|
|
@@ -426,10 +426,10 @@ class QueryManager {
|
|
|
426
426
|
if (!included) {
|
|
427
427
|
const queryName = queryNames.get(nameOrQueryString);
|
|
428
428
|
if (queryName) {
|
|
429
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
429
|
+
__DEV__ && invariant_1.invariant.warn(94, queryName);
|
|
430
430
|
}
|
|
431
431
|
else {
|
|
432
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
432
|
+
__DEV__ && invariant_1.invariant.warn(95);
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
435
|
});
|
|
@@ -458,7 +458,7 @@ class QueryManager {
|
|
|
458
458
|
if (environment_1.__DEV__) {
|
|
459
459
|
(0, invariant_1.invariant)(
|
|
460
460
|
!this.getDocumentInfo(query).hasClientExports || this.localState,
|
|
461
|
-
|
|
461
|
+
96,
|
|
462
462
|
(0, internal_1.getOperationName)(query, "(anonymous)")
|
|
463
463
|
);
|
|
464
464
|
}
|
|
@@ -603,14 +603,14 @@ class QueryManager {
|
|
|
603
603
|
if (environment_1.__DEV__) {
|
|
604
604
|
(0, invariant_1.invariant)(
|
|
605
605
|
this.localState,
|
|
606
|
-
|
|
606
|
+
97,
|
|
607
607
|
operation[0].toUpperCase() + operation.slice(1),
|
|
608
608
|
operationName ?? "(anonymous)"
|
|
609
609
|
);
|
|
610
610
|
}
|
|
611
611
|
(0, invariant_1.invariant)(
|
|
612
612
|
!hasIncrementalDirective,
|
|
613
|
-
|
|
613
|
+
98,
|
|
614
614
|
operation[0].toUpperCase() + operation.slice(1),
|
|
615
615
|
operationName ?? "(anonymous)"
|
|
616
616
|
);
|
|
@@ -653,7 +653,6 @@ class QueryManager {
|
|
|
653
653
|
});
|
|
654
654
|
const hasErrors = (0, internal_1.graphQLResultHasError)(result);
|
|
655
655
|
if (hasErrors && errorPolicy === "none") {
|
|
656
|
-
queryInfo.resetLastWrite();
|
|
657
656
|
observableQuery?.["resetNotifications"]();
|
|
658
657
|
const error = new errors_1.CombinedGraphQLErrors(removeStreamDetailsFromExtensions(result));
|
|
659
658
|
dataStateErrorCache_js_1.dataStateErrorCache.set(error, dataState);
|
|
@@ -688,7 +687,6 @@ class QueryManager {
|
|
|
688
687
|
return aqr;
|
|
689
688
|
}), (0, rxjs_2.catchError)((error) => {
|
|
690
689
|
if (errorPolicy === "none") {
|
|
691
|
-
queryInfo.resetLastWrite();
|
|
692
690
|
observableQuery?.["resetNotifications"]();
|
|
693
691
|
throw error;
|
|
694
692
|
}
|
|
@@ -782,7 +780,7 @@ class QueryManager {
|
|
|
782
780
|
if (environment_1.__DEV__) {
|
|
783
781
|
(0, invariant_1.invariant)(
|
|
784
782
|
this.localState,
|
|
785
|
-
|
|
783
|
+
99,
|
|
786
784
|
(0, internal_1.getOperationName)(normalized.query, "(anonymous)")
|
|
787
785
|
);
|
|
788
786
|
}
|
|
@@ -958,7 +956,7 @@ class QueryManager {
|
|
|
958
956
|
!this.noCacheWarningsByCause.has(cause)) {
|
|
959
957
|
this.noCacheWarningsByCause.add(cause);
|
|
960
958
|
__DEV__ && invariant_1.invariant.warn(
|
|
961
|
-
|
|
959
|
+
100,
|
|
962
960
|
(0, internal_1.getOperationName)(document, `Unnamed ${operationType ?? "operation"}`)
|
|
963
961
|
);
|
|
964
962
|
}
|
|
@@ -974,31 +972,32 @@ class QueryManager {
|
|
|
974
972
|
: data;
|
|
975
973
|
}
|
|
976
974
|
fetchQueryByPolicy({ query, variables, fetchPolicy, errorPolicy, returnPartialData, context, networkStatus, }, { cacheWriteBehavior, onCacheHit, queryInfo, observableQuery, exposeExtensions, }) {
|
|
977
|
-
const readCache = () =>
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
975
|
+
const readCache = () => {
|
|
976
|
+
return queryInfo.getDiff({
|
|
977
|
+
query,
|
|
978
|
+
variables,
|
|
979
|
+
returnPartialData: true,
|
|
980
|
+
optimistic: true,
|
|
981
|
+
});
|
|
982
|
+
};
|
|
983
983
|
const resultsFromCache = (diff, networkStatus) => {
|
|
984
984
|
const data = diff.result;
|
|
985
985
|
if (environment_1.__DEV__ && !returnPartialData && data !== null) {
|
|
986
986
|
(0, ObservableQuery_js_1.logMissingFieldErrors)(diff.missing);
|
|
987
987
|
}
|
|
988
|
-
const toResult = (data) => {
|
|
988
|
+
const toResult = (data, dataState = diff.dataState) => {
|
|
989
989
|
// TODO: Eventually we should move this handling into
|
|
990
990
|
// queryInfo.getDiff() directly. Since getDiff is updated to return null
|
|
991
991
|
// on returnPartialData: false, we should take advantage of that instead
|
|
992
992
|
// of having to patch it elsewhere.
|
|
993
993
|
if (!diff.complete && !returnPartialData) {
|
|
994
994
|
data = undefined;
|
|
995
|
+
dataState = "empty";
|
|
995
996
|
}
|
|
996
997
|
return {
|
|
997
998
|
// TODO: Handle partial data
|
|
998
999
|
data: data,
|
|
999
|
-
dataState
|
|
1000
|
-
: data ? "partial"
|
|
1001
|
-
: "empty",
|
|
1000
|
+
dataState,
|
|
1002
1001
|
loading: (0, utilities_1.isNetworkRequestInFlight)(networkStatus),
|
|
1003
1002
|
networkStatus,
|
|
1004
1003
|
partial: !diff.complete,
|
|
@@ -1024,7 +1023,7 @@ class QueryManager {
|
|
|
1024
1023
|
if (environment_1.__DEV__) {
|
|
1025
1024
|
(0, invariant_1.invariant)(
|
|
1026
1025
|
this.localState,
|
|
1027
|
-
|
|
1026
|
+
101,
|
|
1028
1027
|
(0, internal_1.getOperationName)(query, "(anonymous)")
|
|
1029
1028
|
);
|
|
1030
1029
|
}
|
|
@@ -1040,7 +1039,9 @@ class QueryManager {
|
|
|
1040
1039
|
fetchPolicy,
|
|
1041
1040
|
}).then((resolved) => ({
|
|
1042
1041
|
kind: "N",
|
|
1043
|
-
value: toResult(resolved.data || void 0
|
|
1042
|
+
value: toResult(resolved.data || void 0, diff.complete ? "complete"
|
|
1043
|
+
: resolved.data ? "partial"
|
|
1044
|
+
: "empty"),
|
|
1044
1045
|
// Always attach the variables used for this fetch so @export
|
|
1045
1046
|
// resolution can update ObservableQuery.options.variables and
|
|
1046
1047
|
// resubscribe the cache watch under the correct variable set.
|
|
@@ -1136,7 +1137,7 @@ function validateDidEmitValue() {
|
|
|
1136
1137
|
didEmitValue = true;
|
|
1137
1138
|
},
|
|
1138
1139
|
complete() {
|
|
1139
|
-
(0, invariant_1.invariant)(didEmitValue,
|
|
1140
|
+
(0, invariant_1.invariant)(didEmitValue, 102);
|
|
1140
1141
|
},
|
|
1141
1142
|
});
|
|
1142
1143
|
}
|