@apollo/client 4.3.3 → 4.3.5
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 +30 -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/helpers.cjs +5 -0
- package/__cjs/cache/inmemory/helpers.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs +17 -6
- 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 +15 -3
- package/__cjs/cache/inmemory/key-extractor.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.cjs +21 -5
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +2 -0
- 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 +32 -16
- 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 +22 -33
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +1 -1
- package/__cjs/core/QueryManager.cjs +22 -15
- package/__cjs/core/QueryManager.cjs.map +1 -1
- 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/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.d.cts +42 -43
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +0 -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/helpers.js +5 -0
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +3 -1
- package/cache/inmemory/inMemoryCache.js +17 -6
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +15 -3
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/policies.d.ts +2 -0
- package/cache/inmemory/policies.js +22 -6
- package/cache/inmemory/policies.js.map +1 -1
- 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 +33 -17
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.js +14 -14
- package/core/ObservableQuery.js +8 -8
- package/core/QueryInfo.d.ts +1 -1
- package/core/QueryInfo.js +23 -34
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +22 -15
- package/core/QueryManager.js.map +1 -1
- 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/react/hooks/useFragment.d.ts +42 -43
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks-compiled/useFragment.d.ts +42 -43
- package/react/hooks-compiled/useFragment.js.map +1 -1
- package/utilities/internal/index.d.ts +0 -1
- package/utilities/internal/index.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
|
@@ -69,7 +69,7 @@ export class StoreReader {
|
|
|
69
69
|
20000 /* defaultCacheSizes["inMemoryCache.prunePartialBoundaries"] */,
|
|
70
70
|
makeCacheKey: ({ boundaries, context, selectionSet }) => {
|
|
71
71
|
if (supportsResultCaching(context.store)) {
|
|
72
|
-
return this.keyMaker.lookup(selectionSet, boundaries, context.streamInfo, context.
|
|
72
|
+
return this.keyMaker.lookup(selectionSet, boundaries, context.streamInfo, context.isDeferPending);
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
75
|
});
|
|
@@ -84,7 +84,7 @@ export class StoreReader {
|
|
|
84
84
|
20000 /* defaultCacheSizes["inMemoryCache.prunePartialStreamArray"] */,
|
|
85
85
|
makeCacheKey: ({ field, context, boundaries }) => {
|
|
86
86
|
if (supportsResultCaching(context.store)) {
|
|
87
|
-
return this.keyMaker.lookup(field, boundaries, context.streamInfo, context.
|
|
87
|
+
return this.keyMaker.lookup(field, boundaries, context.streamInfo, context.isDeferPending);
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
});
|
|
@@ -282,7 +282,7 @@ export class StoreReader {
|
|
|
282
282
|
if (typename) {
|
|
283
283
|
const policy = policies["getFieldPolicy"](typename, fieldName);
|
|
284
284
|
if (policy?.scalar) {
|
|
285
|
-
__DEV__ && invariant.warn(
|
|
285
|
+
__DEV__ && invariant.warn(120, `${typename}.${fieldName}`, policy.scalar);
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
}
|
|
@@ -319,7 +319,7 @@ export class StoreReader {
|
|
|
319
319
|
else {
|
|
320
320
|
const fragment = getFragmentFromSelection(selection, context.lookupFragment);
|
|
321
321
|
if (!fragment && selection.kind === Kind.FRAGMENT_SPREAD) {
|
|
322
|
-
throw newInvariantError(
|
|
322
|
+
throw newInvariantError(121, selection.name.value);
|
|
323
323
|
}
|
|
324
324
|
if (fragment && policies.fragmentMatches(fragment, typename)) {
|
|
325
325
|
const isDeferBoundary = isDeferredFragment(selection, context.variables);
|
|
@@ -450,7 +450,10 @@ export class StoreReader {
|
|
|
450
450
|
if (data == null || !boundaries) {
|
|
451
451
|
return { result: data, dataState: "complete" };
|
|
452
452
|
}
|
|
453
|
-
|
|
453
|
+
// `truncate` is only necessary for the Defer20220824 protocol. the
|
|
454
|
+
// `arrayMerge` option can be removed when we stop supporting the old
|
|
455
|
+
// protocol. See the comment below on array merging for more info.
|
|
456
|
+
const merger = new DeepMerger({ arrayMerge: "truncate" });
|
|
454
457
|
let changed = false;
|
|
455
458
|
let dataState = "complete";
|
|
456
459
|
const result = {};
|
|
@@ -479,7 +482,22 @@ export class StoreReader {
|
|
|
479
482
|
path: path.concat(resultName),
|
|
480
483
|
});
|
|
481
484
|
changed ||= pruned.result !== fieldValue;
|
|
482
|
-
result[resultName]
|
|
485
|
+
const previous = result[resultName];
|
|
486
|
+
let merged = merger.merge(previous, pruned.result);
|
|
487
|
+
// The Defer20220824 protocol allows more than one selection of a
|
|
488
|
+
// list field with `@stream` when the `@stream` arguments are the
|
|
489
|
+
// same. Each selection can prune the list to a different length, so
|
|
490
|
+
// we keep the shortest length. The `truncate` option of the merger
|
|
491
|
+
// handles a shorter later visit, and this check handles a shorter
|
|
492
|
+
// earlier visit. GraphQL 17 rejects any overlapping `@stream` field,
|
|
493
|
+
// so all visits give the same length. When we no longer support the
|
|
494
|
+
// older protocol, we can remove this check and the `truncate` option,
|
|
495
|
+
// and simplify to:
|
|
496
|
+
// result[resultName] = merger.merge(result[resultName], pruned.result);
|
|
497
|
+
if (previous && previous.length < merged.length) {
|
|
498
|
+
merged = merged.slice(0, previous.length);
|
|
499
|
+
}
|
|
500
|
+
result[resultName] = merged;
|
|
483
501
|
dataState = mergeDataState(dataState, pruned.dataState);
|
|
484
502
|
}
|
|
485
503
|
else if (!selection.selectionSet) {
|
|
@@ -513,10 +531,10 @@ export class StoreReader {
|
|
|
513
531
|
// dropped or not.
|
|
514
532
|
const fragment = getFragmentFromSelection(selection, lookupFragment);
|
|
515
533
|
let prune = false;
|
|
516
|
-
if (context.
|
|
534
|
+
if (context.isDeferPending && isDeferredFragment(selection, variables)) {
|
|
517
535
|
const directive = selection.directives?.find((d) => d.name.value === "defer");
|
|
518
536
|
const label = directive && getDirectiveArgValue(directive, "label", Kind.STRING);
|
|
519
|
-
prune =
|
|
537
|
+
prune = context.isDeferPending(path, label);
|
|
520
538
|
}
|
|
521
539
|
if (fragment && policies.fragmentMatches(fragment, data.__typename)) {
|
|
522
540
|
if (boundaries.has(selection) || prune) {
|
|
@@ -616,7 +634,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
|
|
|
616
634
|
if (isNonNullObject(value)) {
|
|
617
635
|
invariant(
|
|
618
636
|
!isReference(value),
|
|
619
|
-
|
|
637
|
+
122,
|
|
620
638
|
getTypenameFromStoreObject(store, value),
|
|
621
639
|
field.name.value
|
|
622
640
|
);
|
|
@@ -680,7 +698,7 @@ function shouldPrune({ dataState }, context) {
|
|
|
680
698
|
(context.streamInfo ||
|
|
681
699
|
// The network hasn't delivered these @defer boundaries yet, so prune
|
|
682
700
|
// the (possibly complete) cached data sitting at them.
|
|
683
|
-
context.
|
|
701
|
+
context.isDeferPending));
|
|
684
702
|
}
|
|
685
703
|
return false;
|
|
686
704
|
}
|