@apollo/client 4.3.0-alpha.5 → 4.3.0-alpha.6
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 +10 -0
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +24 -2
- 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 +10 -9
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +1 -1
- package/__cjs/core/QueryInfo.cjs +2 -11
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +2 -2
- package/__cjs/core/QueryManager.cjs +14 -11
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/invariantErrorCodes.cjs +13 -8
- 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/policies.js +24 -2
- 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 +1 -1
- package/core/ObservableQuery.js +11 -10
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +2 -2
- package/core/QueryInfo.js +3 -12
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +14 -11
- package/core/QueryManager.js.map +1 -1
- package/invariantErrorCodes.js +13 -8
- 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
|
@@ -75,7 +75,7 @@ class StoreWriter {
|
|
|
75
75
|
path: [],
|
|
76
76
|
});
|
|
77
77
|
if (!(0, utilities_1.isReference)(ref)) {
|
|
78
|
-
throw (0, invariant_1.newInvariantError)(
|
|
78
|
+
throw (0, invariant_1.newInvariantError)(117, result);
|
|
79
79
|
}
|
|
80
80
|
// So far, the store has not been modified, so now it's time to process
|
|
81
81
|
// context.incomingById and merge those incoming fields into context.store.
|
|
@@ -237,7 +237,7 @@ class StoreWriter {
|
|
|
237
237
|
// provide a default value, so its absence from the written data should
|
|
238
238
|
// not be cause for alarm.
|
|
239
239
|
!policies.getReadFunction(typename, field.name.value)) {
|
|
240
|
-
invariant_1.invariant.error(
|
|
240
|
+
invariant_1.invariant.error(118, (0, internal_1.resultKeyNameFromField)(field), result);
|
|
241
241
|
}
|
|
242
242
|
});
|
|
243
243
|
// Identify the result object, even if dataId was already provided,
|
|
@@ -385,7 +385,7 @@ class StoreWriter {
|
|
|
385
385
|
else {
|
|
386
386
|
const fragment = (0, internal_1.getFragmentFromSelection)(selection, context.lookupFragment);
|
|
387
387
|
if (!fragment && selection.kind === graphql_1.Kind.FRAGMENT_SPREAD) {
|
|
388
|
-
throw (0, invariant_1.newInvariantError)(
|
|
388
|
+
throw (0, invariant_1.newInvariantError)(119, selection.name.value);
|
|
389
389
|
}
|
|
390
390
|
if (fragment &&
|
|
391
391
|
policies.fragmentMatches(fragment, typename, result, context.variables)) {
|
|
@@ -558,7 +558,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
558
558
|
}
|
|
559
559
|
});
|
|
560
560
|
}
|
|
561
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
561
|
+
__DEV__ && invariant_1.invariant.warn(120, fieldName, parentType, childTypenames.length ?
|
|
562
562
|
"either ensure all objects of type " +
|
|
563
563
|
childTypenames.join(" and ") +
|
|
564
564
|
" have an ID or a custom merge function, or "
|
|
@@ -214,12 +214,13 @@ class ObservableQuery {
|
|
|
214
214
|
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
215
215
|
*/
|
|
216
216
|
getCacheDiff({ optimistic = true } = {}) {
|
|
217
|
-
return this.cache.diff({
|
|
217
|
+
return (0, internal_1.toDiffWithDataState)(this.cache.diff({
|
|
218
218
|
query: this.query,
|
|
219
219
|
variables: this.variables,
|
|
220
220
|
returnPartialData: true,
|
|
221
221
|
optimistic,
|
|
222
|
-
|
|
222
|
+
[internal_1.handleIncrementalSymbol]: undefined,
|
|
223
|
+
}));
|
|
223
224
|
}
|
|
224
225
|
getInitialResult(initialFetchPolicy) {
|
|
225
226
|
let fetchPolicy = initialFetchPolicy || this.options.fetchPolicy;
|
|
@@ -229,16 +230,18 @@ class ObservableQuery {
|
|
|
229
230
|
}
|
|
230
231
|
const cacheResult = () => {
|
|
231
232
|
const diff = this.getCacheDiff();
|
|
233
|
+
let { dataState } = diff;
|
|
232
234
|
// TODO: queryInfo.getDiff should handle this since cache.diff returns a
|
|
233
235
|
// null when returnPartialData is false
|
|
234
236
|
const data = this.options.returnPartialData || diff.complete ?
|
|
235
237
|
diff.result ?? undefined
|
|
236
238
|
: undefined;
|
|
239
|
+
if (data === undefined) {
|
|
240
|
+
dataState = "empty";
|
|
241
|
+
}
|
|
237
242
|
return this.maskResult({
|
|
238
243
|
data,
|
|
239
|
-
dataState
|
|
240
|
-
: data === undefined ? "empty"
|
|
241
|
-
: "partial",
|
|
244
|
+
dataState,
|
|
242
245
|
loading: !diff.complete,
|
|
243
246
|
networkStatus: diff.complete ? networkStatus_js_1.NetworkStatus.ready : networkStatus_js_1.NetworkStatus.loading,
|
|
244
247
|
partial: !diff.complete,
|
|
@@ -1164,9 +1167,7 @@ class ObservableQuery {
|
|
|
1164
1167
|
kind: "N",
|
|
1165
1168
|
value: {
|
|
1166
1169
|
data: diff.result,
|
|
1167
|
-
dataState: diff.
|
|
1168
|
-
: diff.result ? "partial"
|
|
1169
|
-
: "empty",
|
|
1170
|
+
dataState: diff.dataState,
|
|
1170
1171
|
networkStatus: networkStatus_js_1.NetworkStatus.ready,
|
|
1171
1172
|
loading: false,
|
|
1172
1173
|
error: undefined,
|
|
@@ -1310,7 +1311,7 @@ class ObservableQuery {
|
|
|
1310
1311
|
if (notification.source === "cache") {
|
|
1311
1312
|
result = notification.value;
|
|
1312
1313
|
if (result.networkStatus === networkStatus_js_1.NetworkStatus.ready &&
|
|
1313
|
-
result.partial &&
|
|
1314
|
+
result.dataState === "partial" &&
|
|
1314
1315
|
(!this.options.returnPartialData ||
|
|
1315
1316
|
previous.result.networkStatus === networkStatus_js_1.NetworkStatus.error) &&
|
|
1316
1317
|
this.options.fetchPolicy !== "cache-only") {
|