@apollo/client 4.3.2 → 4.3.4
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 +26 -0
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +4 -1
- package/__cjs/cache/core/types/Cache.d.cts +5 -0
- package/__cjs/cache/inmemory/entityStore.cjs +4 -4
- package/__cjs/cache/inmemory/inMemoryCache.cjs +15 -5
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +3 -1
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +5 -5
- package/__cjs/cache/inmemory/readFromStore.cjs +28 -10
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/types.d.cts +7 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +29 -14
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +5 -2
- package/__cjs/core/ApolloClient.cjs +14 -14
- package/__cjs/core/ObservableQuery.cjs +8 -8
- package/__cjs/core/QueryInfo.cjs +13 -32
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryManager.cjs +12 -12
- package/__cjs/core/RefetchEventManager.cjs +3 -3
- package/__cjs/incremental/handlers/defer20220824.cjs +15 -2
- package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
- package/__cjs/incremental/handlers/defer20220824.d.cts +5 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs +58 -14
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +23 -12
- package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
- package/__cjs/incremental/types.d.cts +19 -1
- package/__cjs/invariantErrorCodes.cjs +64 -58
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +0 -1
- package/__cjs/utilities/internal/isDeferredFragment.cjs +24 -26
- package/__cjs/utilities/internal/isDeferredFragment.cjs.map +1 -1
- package/__cjs/utilities/internal/isDeferredFragment.d.cts +1 -1
- package/__cjs/utilities/internal/isStreamField.cjs +24 -20
- package/__cjs/utilities/internal/isStreamField.cjs.map +1 -1
- package/__cjs/utilities/internal/isStreamField.d.cts +1 -1
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.d.ts +4 -1
- package/cache/core/cache.js +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +5 -0
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/inmemory/entityStore.js +4 -4
- package/cache/inmemory/inMemoryCache.d.ts +3 -1
- package/cache/inmemory/inMemoryCache.js +15 -5
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +5 -5
- package/cache/inmemory/readFromStore.js +28 -10
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +7 -2
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +5 -2
- package/cache/inmemory/writeToStore.js +30 -15
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.js +14 -14
- package/core/ObservableQuery.js +8 -8
- package/core/QueryInfo.js +14 -33
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +12 -12
- package/core/RefetchEventManager.js +3 -3
- package/incremental/handlers/defer20220824.d.ts +5 -1
- package/incremental/handlers/defer20220824.js +15 -2
- package/incremental/handlers/defer20220824.js.map +1 -1
- package/incremental/handlers/graphql17Alpha9.d.ts +23 -12
- package/incremental/handlers/graphql17Alpha9.js +58 -14
- package/incremental/handlers/graphql17Alpha9.js.map +1 -1
- package/incremental/handlers/notImplemented.js +1 -1
- package/incremental/types.d.ts +19 -1
- package/incremental/types.js.map +1 -1
- package/invariantErrorCodes.js +64 -58
- package/package.json +1 -1
- package/utilities/internal/index.d.ts +0 -1
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/isDeferredFragment.d.ts +1 -1
- package/utilities/internal/isDeferredFragment.js +23 -25
- package/utilities/internal/isDeferredFragment.js.map +1 -1
- package/utilities/internal/isStreamField.d.ts +1 -1
- package/utilities/internal/isStreamField.js +23 -19
- package/utilities/internal/isStreamField.js.map +1 -1
- package/version.js +1 -1
- package/__cjs/utilities/internal/types/DeferInfo.cjs +0 -3
- package/__cjs/utilities/internal/types/DeferInfo.cjs.map +0 -1
- package/__cjs/utilities/internal/types/DeferInfo.d.cts +0 -10
- package/utilities/internal/types/DeferInfo.d.ts +0 -10
- package/utilities/internal/types/DeferInfo.js +0 -2
- package/utilities/internal/types/DeferInfo.js.map +0 -1
|
@@ -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, 114, schemaKeyPath.join("."), object);
|
|
45
45
|
return extracted;
|
|
46
46
|
}));
|
|
47
47
|
return `${context.typename}:${JSON.stringify(keyObject)}`;
|
|
@@ -251,7 +251,7 @@ class Policies {
|
|
|
251
251
|
const rootId = "ROOT_" + which.toUpperCase();
|
|
252
252
|
const old = this.rootTypenamesById[rootId];
|
|
253
253
|
if (typename !== old) {
|
|
254
|
-
(0, invariant_1.invariant)(!old || old === which,
|
|
254
|
+
(0, invariant_1.invariant)(!old || old === which, 115, which);
|
|
255
255
|
// First, delete any old __typename associated with this rootId from
|
|
256
256
|
// rootIdsByTypename.
|
|
257
257
|
if (old)
|
|
@@ -394,7 +394,7 @@ class Policies {
|
|
|
394
394
|
if (supertypeSet.has(supertype)) {
|
|
395
395
|
if (!typenameSupertypeSet.has(supertype)) {
|
|
396
396
|
if (checkingFuzzySubtypes) {
|
|
397
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
397
|
+
__DEV__ && invariant_1.invariant.warn(116, typename, supertype);
|
|
398
398
|
}
|
|
399
399
|
// Record positive results for faster future lookup.
|
|
400
400
|
// Unfortunately, we cannot safely cache negative results,
|
|
@@ -650,7 +650,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
650
650
|
}
|
|
651
651
|
}
|
|
652
652
|
if (environment_1.__DEV__ && options.from === void 0) {
|
|
653
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
653
|
+
__DEV__ && invariant_1.invariant.warn(117, (0, internal_2.stringifyForDisplay)(Array.from(readFieldArgs)));
|
|
654
654
|
}
|
|
655
655
|
if (void 0 === options.variables) {
|
|
656
656
|
options.variables = variables;
|
|
@@ -660,7 +660,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
660
660
|
function makeMergeObjectsFunction(store) {
|
|
661
661
|
return function mergeObjects(existing, incoming) {
|
|
662
662
|
if ((0, internal_2.isArray)(existing) || (0, internal_2.isArray)(incoming)) {
|
|
663
|
-
throw (0, invariant_1.newInvariantError)(
|
|
663
|
+
throw (0, invariant_1.newInvariantError)(118);
|
|
664
664
|
}
|
|
665
665
|
// These dynamic checks are necessary because the parameters of a
|
|
666
666
|
// custom merge function can easily have the any type, so the type
|
|
@@ -697,6 +697,6 @@ function makeMergeObjectsFunction(store) {
|
|
|
697
697
|
};
|
|
698
698
|
}
|
|
699
699
|
function warnAboutScalarConfig(typename, fieldName, scalar, kind) {
|
|
700
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
700
|
+
__DEV__ && invariant_1.invariant.warn(119, `${typename}.${fieldName}`, scalar, kind);
|
|
701
701
|
}
|
|
702
702
|
//# sourceMappingURL=policies.cjs.map
|
|
@@ -76,7 +76,7 @@ class StoreReader {
|
|
|
76
76
|
20000 /* defaultCacheSizes["inMemoryCache.prunePartialBoundaries"] */,
|
|
77
77
|
makeCacheKey: ({ boundaries, context, selectionSet }) => {
|
|
78
78
|
if ((0, entityStore_js_1.supportsResultCaching)(context.store)) {
|
|
79
|
-
return this.keyMaker.lookup(selectionSet, boundaries, context.streamInfo, context.
|
|
79
|
+
return this.keyMaker.lookup(selectionSet, boundaries, context.streamInfo, context.isDeferPending);
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
});
|
|
@@ -91,7 +91,7 @@ class StoreReader {
|
|
|
91
91
|
20000 /* defaultCacheSizes["inMemoryCache.prunePartialStreamArray"] */,
|
|
92
92
|
makeCacheKey: ({ field, context, boundaries }) => {
|
|
93
93
|
if ((0, entityStore_js_1.supportsResultCaching)(context.store)) {
|
|
94
|
-
return this.keyMaker.lookup(field, boundaries, context.streamInfo, context.
|
|
94
|
+
return this.keyMaker.lookup(field, boundaries, context.streamInfo, context.isDeferPending);
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
97
|
});
|
|
@@ -289,7 +289,7 @@ class StoreReader {
|
|
|
289
289
|
if (typename) {
|
|
290
290
|
const policy = policies["getFieldPolicy"](typename, fieldName);
|
|
291
291
|
if (policy?.scalar) {
|
|
292
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
292
|
+
__DEV__ && invariant_1.invariant.warn(120, `${typename}.${fieldName}`, policy.scalar);
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
295
|
}
|
|
@@ -326,7 +326,7 @@ class StoreReader {
|
|
|
326
326
|
else {
|
|
327
327
|
const fragment = (0, internal_1.getFragmentFromSelection)(selection, context.lookupFragment);
|
|
328
328
|
if (!fragment && selection.kind === graphql_1.Kind.FRAGMENT_SPREAD) {
|
|
329
|
-
throw (0, invariant_1.newInvariantError)(
|
|
329
|
+
throw (0, invariant_1.newInvariantError)(121, selection.name.value);
|
|
330
330
|
}
|
|
331
331
|
if (fragment && policies.fragmentMatches(fragment, typename)) {
|
|
332
332
|
const isDeferBoundary = (0, internal_1.isDeferredFragment)(selection, context.variables);
|
|
@@ -457,7 +457,10 @@ class StoreReader {
|
|
|
457
457
|
if (data == null || !boundaries) {
|
|
458
458
|
return { result: data, dataState: "complete" };
|
|
459
459
|
}
|
|
460
|
-
|
|
460
|
+
// `truncate` is only necessary for the Defer20220824 protocol. the
|
|
461
|
+
// `arrayMerge` option can be removed when we stop supporting the old
|
|
462
|
+
// protocol. See the comment below on array merging for more info.
|
|
463
|
+
const merger = new internal_1.DeepMerger({ arrayMerge: "truncate" });
|
|
461
464
|
let changed = false;
|
|
462
465
|
let dataState = "complete";
|
|
463
466
|
const result = {};
|
|
@@ -486,7 +489,22 @@ class StoreReader {
|
|
|
486
489
|
path: path.concat(resultName),
|
|
487
490
|
});
|
|
488
491
|
changed ||= pruned.result !== fieldValue;
|
|
489
|
-
result[resultName]
|
|
492
|
+
const previous = result[resultName];
|
|
493
|
+
let merged = merger.merge(previous, pruned.result);
|
|
494
|
+
// The Defer20220824 protocol allows more than one selection of a
|
|
495
|
+
// list field with `@stream` when the `@stream` arguments are the
|
|
496
|
+
// same. Each selection can prune the list to a different length, so
|
|
497
|
+
// we keep the shortest length. The `truncate` option of the merger
|
|
498
|
+
// handles a shorter later visit, and this check handles a shorter
|
|
499
|
+
// earlier visit. GraphQL 17 rejects any overlapping `@stream` field,
|
|
500
|
+
// so all visits give the same length. When we no longer support the
|
|
501
|
+
// older protocol, we can remove this check and the `truncate` option,
|
|
502
|
+
// and simplify to:
|
|
503
|
+
// result[resultName] = merger.merge(result[resultName], pruned.result);
|
|
504
|
+
if (previous && previous.length < merged.length) {
|
|
505
|
+
merged = merged.slice(0, previous.length);
|
|
506
|
+
}
|
|
507
|
+
result[resultName] = merged;
|
|
490
508
|
dataState = mergeDataState(dataState, pruned.dataState);
|
|
491
509
|
}
|
|
492
510
|
else if (!selection.selectionSet) {
|
|
@@ -520,10 +538,10 @@ class StoreReader {
|
|
|
520
538
|
// dropped or not.
|
|
521
539
|
const fragment = (0, internal_1.getFragmentFromSelection)(selection, lookupFragment);
|
|
522
540
|
let prune = false;
|
|
523
|
-
if (context.
|
|
541
|
+
if (context.isDeferPending && (0, internal_1.isDeferredFragment)(selection, variables)) {
|
|
524
542
|
const directive = selection.directives?.find((d) => d.name.value === "defer");
|
|
525
543
|
const label = directive && (0, internal_1.getDirectiveArgValue)(directive, "label", graphql_1.Kind.STRING);
|
|
526
|
-
prune =
|
|
544
|
+
prune = context.isDeferPending(path, label);
|
|
527
545
|
}
|
|
528
546
|
if (fragment && policies.fragmentMatches(fragment, data.__typename)) {
|
|
529
547
|
if (boundaries.has(selection) || prune) {
|
|
@@ -624,7 +642,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
|
|
|
624
642
|
if ((0, internal_1.isNonNullObject)(value)) {
|
|
625
643
|
(0, invariant_1.invariant)(
|
|
626
644
|
!(0, utilities_1.isReference)(value),
|
|
627
|
-
|
|
645
|
+
122,
|
|
628
646
|
(0, helpers_js_1.getTypenameFromStoreObject)(store, value),
|
|
629
647
|
field.name.value
|
|
630
648
|
);
|
|
@@ -688,7 +706,7 @@ function shouldPrune({ dataState }, context) {
|
|
|
688
706
|
(context.streamInfo ||
|
|
689
707
|
// The network hasn't delivered these @defer boundaries yet, so prune
|
|
690
708
|
// the (possibly complete) cached data sitting at them.
|
|
691
|
-
context.
|
|
709
|
+
context.isDeferPending));
|
|
692
710
|
}
|
|
693
711
|
return false;
|
|
694
712
|
}
|