@apollo/client 4.2.10 → 4.2.12
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 +14 -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/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/core/QueryInfo.cjs +24 -1
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryManager.cjs +12 -12
- package/__cjs/core/RefetchEventManager.cjs +3 -3
- package/__cjs/invariantErrorCodes.cjs +49 -30
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +10 -2
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +9 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +9 -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/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/QueryInfo.js +19 -0
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +12 -12
- package/core/QueryManager.js.map +1 -1
- package/core/RefetchEventManager.js +3 -3
- package/invariantErrorCodes.js +49 -30
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/package.json +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +10 -2
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts +9 -1
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +9 -1
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +10 -2
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +9 -1
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +9 -1
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/version.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 4.2.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#13400](https://github.com/apollographql/apollo-client/pull/13400) [`56ca81b`](https://github.com/apollographql/apollo-client/commit/56ca81b40962d1aeef3d753e562672dfed042ea2) Thanks [@QiRaining](https://github.com/QiRaining)! - Preserve multi-byte UTF-8 characters split across multipart response chunks.
|
|
8
|
+
|
|
9
|
+
## 4.2.11
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#13398](https://github.com/apollographql/apollo-client/pull/13398) [`3dd3e9a`](https://github.com/apollographql/apollo-client/commit/3dd3e9a6f195ea5dd27a973f153a0538ccdffd20) Thanks [@phryneas](https://github.com/phryneas)! - Fix type signature of some `DocumentationTypes` to fix their display in our documentation.
|
|
14
|
+
|
|
15
|
+
- [#13392](https://github.com/apollographql/apollo-client/pull/13392) [`d4f0771`](https://github.com/apollographql/apollo-client/commit/d4f0771976766b54e0a95a3d51b708b64eb3cfe0) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add a development-only warning when a network result is written to the cache but reading the query back from the cache returns a partial result. This usually points at a `merge` or `read` function that did not repair missing fields in the cache, which prevents Apollo Client from applying the cache result to the data received by the network.
|
|
16
|
+
|
|
3
17
|
## 4.2.10
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -140,7 +140,7 @@ class ApolloCache {
|
|
|
140
140
|
if (environment_1.__DEV__) {
|
|
141
141
|
const actualFragmentName = fragmentName || (0, internal_1.getFragmentDefinition)(fragment).name.value;
|
|
142
142
|
if (id === undefined) {
|
|
143
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
143
|
+
__DEV__ && invariant_1.invariant.warn(119, actualFragmentName);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
return id;
|
|
@@ -82,7 +82,7 @@ class EntityStore {
|
|
|
82
82
|
// then there are no fields to be merged, so we're done.
|
|
83
83
|
if (!incoming)
|
|
84
84
|
return;
|
|
85
|
-
(0, invariant_1.invariant)(typeof dataId === "string",
|
|
85
|
+
(0, invariant_1.invariant)(typeof dataId === "string", 105);
|
|
86
86
|
const merged = new internal_1.DeepMerger({
|
|
87
87
|
reconciler: storeObjectReconciler,
|
|
88
88
|
}).merge(existing, incoming);
|
|
@@ -184,7 +184,7 @@ class EntityStore {
|
|
|
184
184
|
if (environment_1.__DEV__) {
|
|
185
185
|
const checkReference = (ref) => {
|
|
186
186
|
if (this.lookup(ref.__ref) === undefined) {
|
|
187
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
187
|
+
__DEV__ && invariant_1.invariant.warn(106, ref);
|
|
188
188
|
return true;
|
|
189
189
|
}
|
|
190
190
|
};
|
|
@@ -213,7 +213,7 @@ class EntityStore {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
if (seenReference && someNonReference !== undefined) {
|
|
216
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
216
|
+
__DEV__ && invariant_1.invariant.warn(107, someNonReference);
|
|
217
217
|
break;
|
|
218
218
|
}
|
|
219
219
|
}
|
|
@@ -41,7 +41,7 @@ function keyFieldsFnFromSpecifier(specifier) {
|
|
|
41
41
|
// context.readField for this extraction.
|
|
42
42
|
extracted = extractKeyPath(object, schemaKeyPath, extractKey);
|
|
43
43
|
}
|
|
44
|
-
(0, invariant_1.invariant)(extracted !== void 0,
|
|
44
|
+
(0, invariant_1.invariant)(extracted !== void 0, 108, schemaKeyPath.join("."), object);
|
|
45
45
|
return extracted;
|
|
46
46
|
}));
|
|
47
47
|
return `${context.typename}:${JSON.stringify(keyObject)}`;
|
|
@@ -229,7 +229,7 @@ class Policies {
|
|
|
229
229
|
const rootId = "ROOT_" + which.toUpperCase();
|
|
230
230
|
const old = this.rootTypenamesById[rootId];
|
|
231
231
|
if (typename !== old) {
|
|
232
|
-
(0, invariant_1.invariant)(!old || old === which,
|
|
232
|
+
(0, invariant_1.invariant)(!old || old === which, 109, which);
|
|
233
233
|
// First, delete any old __typename associated with this rootId from
|
|
234
234
|
// rootIdsByTypename.
|
|
235
235
|
if (old)
|
|
@@ -372,7 +372,7 @@ class Policies {
|
|
|
372
372
|
if (supertypeSet.has(supertype)) {
|
|
373
373
|
if (!typenameSupertypeSet.has(supertype)) {
|
|
374
374
|
if (checkingFuzzySubtypes) {
|
|
375
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
375
|
+
__DEV__ && invariant_1.invariant.warn(110, typename, supertype);
|
|
376
376
|
}
|
|
377
377
|
// Record positive results for faster future lookup.
|
|
378
378
|
// Unfortunately, we cannot safely cache negative results,
|
|
@@ -625,7 +625,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
627
|
if (environment_1.__DEV__ && options.from === void 0) {
|
|
628
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
628
|
+
__DEV__ && invariant_1.invariant.warn(111, (0, internal_2.stringifyForDisplay)(Array.from(readFieldArgs)));
|
|
629
629
|
}
|
|
630
630
|
if (void 0 === options.variables) {
|
|
631
631
|
options.variables = variables;
|
|
@@ -635,7 +635,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
635
635
|
function makeMergeObjectsFunction(store) {
|
|
636
636
|
return function mergeObjects(existing, incoming) {
|
|
637
637
|
if ((0, internal_2.isArray)(existing) || (0, internal_2.isArray)(incoming)) {
|
|
638
|
-
throw (0, invariant_1.newInvariantError)(
|
|
638
|
+
throw (0, invariant_1.newInvariantError)(112);
|
|
639
639
|
}
|
|
640
640
|
// These dynamic checks are necessary because the parameters of a
|
|
641
641
|
// custom merge function can easily have the any type, so the type
|
|
@@ -194,7 +194,7 @@ class StoreReader {
|
|
|
194
194
|
else {
|
|
195
195
|
const fragment = (0, internal_1.getFragmentFromSelection)(selection, context.lookupFragment);
|
|
196
196
|
if (!fragment && selection.kind === graphql_1.Kind.FRAGMENT_SPREAD) {
|
|
197
|
-
throw (0, invariant_1.newInvariantError)(
|
|
197
|
+
throw (0, invariant_1.newInvariantError)(113, selection.name.value);
|
|
198
198
|
}
|
|
199
199
|
if (fragment && policies.fragmentMatches(fragment, typename)) {
|
|
200
200
|
fragment.selectionSet.selections.forEach(workSet.add, workSet);
|
|
@@ -278,7 +278,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
|
|
|
278
278
|
if ((0, internal_1.isNonNullObject)(value)) {
|
|
279
279
|
(0, invariant_1.invariant)(
|
|
280
280
|
!(0, utilities_1.isReference)(value),
|
|
281
|
-
|
|
281
|
+
114,
|
|
282
282
|
(0, helpers_js_1.getTypenameFromStoreObject)(store, value),
|
|
283
283
|
field.name.value
|
|
284
284
|
);
|
|
@@ -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)(115, 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(116, (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)(117, selection.name.value);
|
|
389
389
|
}
|
|
390
390
|
if (fragment &&
|
|
391
391
|
policies.fragmentMatches(fragment, typename, result, context.variables)) {
|
|
@@ -562,7 +562,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
562
562
|
}
|
|
563
563
|
});
|
|
564
564
|
}
|
|
565
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
565
|
+
__DEV__ && invariant_1.invariant.warn(118, fieldName, parentType, childTypenames.length ?
|
|
566
566
|
"either ensure all objects of type " +
|
|
567
567
|
childTypenames.join(" and ") +
|
|
568
568
|
" have an ID or a custom merge function, or "
|
package/__cjs/core/QueryInfo.cjs
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
"use strict"
|
|
1
|
+
"use strict";;
|
|
2
|
+
const {
|
|
3
|
+
__DEV__
|
|
4
|
+
} = require("@apollo/client/utilities/environment");
|
|
5
|
+
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
7
|
exports.QueryInfo = void 0;
|
|
4
8
|
const equality_1 = require("@wry/equality");
|
|
9
|
+
const environment_1 = require("@apollo/client/utilities/environment");
|
|
5
10
|
const internal_1 = require("@apollo/client/utilities/internal");
|
|
6
11
|
const invariant_1 = require("@apollo/client/utilities/invariant");
|
|
7
12
|
const IGNORE = {};
|
|
@@ -115,6 +120,7 @@ class QueryInfo {
|
|
|
115
120
|
return result;
|
|
116
121
|
}
|
|
117
122
|
if (shouldWriteResult(result, errorPolicy)) {
|
|
123
|
+
let written = false;
|
|
118
124
|
// Using a transaction here so we have a chance to read the result
|
|
119
125
|
// back from the cache before the watch callback fires as a result
|
|
120
126
|
// of writeQuery, so we can store the new diff quietly and ignore
|
|
@@ -138,6 +144,7 @@ class QueryInfo {
|
|
|
138
144
|
overwrite: cacheWriteBehavior === 1 /* CacheWriteBehavior.OVERWRITE */,
|
|
139
145
|
extensions: result.extensions,
|
|
140
146
|
});
|
|
147
|
+
written = true;
|
|
141
148
|
this.lastWrite = {
|
|
142
149
|
result,
|
|
143
150
|
variables,
|
|
@@ -195,6 +202,13 @@ class QueryInfo {
|
|
|
195
202
|
if (diff.complete) {
|
|
196
203
|
result = { ...result, data: diff.result };
|
|
197
204
|
}
|
|
205
|
+
else if (environment_1.__DEV__ &&
|
|
206
|
+
written &&
|
|
207
|
+
// A result that is still streaming is expected to read back
|
|
208
|
+
// incomplete until the remaining chunks arrive.
|
|
209
|
+
!this.hasNext) {
|
|
210
|
+
warnAboutPartialCacheResult(query, result.data, diff);
|
|
211
|
+
}
|
|
198
212
|
},
|
|
199
213
|
});
|
|
200
214
|
}
|
|
@@ -388,6 +402,15 @@ class QueryInfo {
|
|
|
388
402
|
}
|
|
389
403
|
}
|
|
390
404
|
exports.QueryInfo = QueryInfo;
|
|
405
|
+
function warnAboutPartialCacheResult(query, networkResult, diff) {
|
|
406
|
+
__DEV__ && invariant_1.invariant.warn(
|
|
407
|
+
89,
|
|
408
|
+
(0, internal_1.getOperationName)(query, "(anonymous)"),
|
|
409
|
+
diff.missing?.missing,
|
|
410
|
+
networkResult,
|
|
411
|
+
diff.result
|
|
412
|
+
);
|
|
413
|
+
}
|
|
391
414
|
function shouldWriteResult(result, errorPolicy = "none") {
|
|
392
415
|
const ignoreErrors = errorPolicy === "ignore" || errorPolicy === "all";
|
|
393
416
|
let writeWithErrors = !(0, internal_1.graphQLResultHasError)(result);
|