@apollo/client 3.9.0-alpha.5 → 3.9.0-beta.0
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/.changeset/dirty-tigers-matter.md +13 -0
- package/.changeset/mighty-coats-check.md +47 -0
- package/.changeset/pre.json +9 -1
- package/.changeset/rare-snakes-melt.md +24 -0
- package/.changeset/swift-zoos-collect.md +19 -0
- package/.changeset/thick-tips-cry.md +9 -0
- package/.changeset/tough-timers-begin.md +8 -0
- package/.changeset/unlucky-rats-decide.md +5 -0
- package/.changeset/wet-forks-rhyme.md +5 -0
- package/CHANGELOG.md +118 -4
- package/apollo-client.cjs +329 -82
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +78 -6
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +78 -6
- package/cache/core/cache.d.ts +9 -0
- package/cache/core/cache.js +11 -2
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +7 -0
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +12 -0
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/core/types/common.d.ts +4 -0
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.js +19 -3
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +9 -0
- package/cache/inmemory/inMemoryCache.js +8 -2
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/readFromStore.js +7 -3
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +18 -0
- package/cache/inmemory/types.js.map +1 -1
- package/core/ApolloClient.d.ts +9 -0
- package/core/ApolloClient.js +4 -0
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +2 -0
- package/core/ObservableQuery.js +7 -1
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +1 -0
- package/core/QueryInfo.js +4 -0
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +1 -1
- package/core/QueryManager.js +15 -10
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +99 -12
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +99 -12
- package/core/watchQueryOptions.d.ts +20 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +1 -1
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +1 -1
- package/link/core/ApolloLink.d.ts +15 -0
- package/link/core/ApolloLink.js +8 -4
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/core.cjs +8 -4
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +8 -4
- package/link/persisted-queries/index.d.ts +11 -1
- package/link/persisted-queries/index.js +28 -3
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs +26 -3
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +26 -3
- package/link/remove-typename/remove-typename.cjs +18 -2
- package/link/remove-typename/remove-typename.cjs.map +1 -1
- package/link/remove-typename/remove-typename.cjs.native.js +18 -2
- package/link/remove-typename/removeTypenameFromVariables.d.ts +9 -1
- package/link/remove-typename/removeTypenameFromVariables.js +19 -3
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/package.json +21 -21
- package/react/cache/QueryReference.d.ts +11 -5
- package/react/cache/QueryReference.js +91 -55
- package/react/cache/QueryReference.js.map +1 -1
- package/react/hooks/hooks.cjs +112 -52
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +112 -52
- package/react/hooks/index.d.ts +2 -0
- package/react/hooks/index.js +1 -0
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +12 -9
- package/react/hooks/useBackgroundQuery.js +1 -1
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +1 -1
- package/react/hooks/useLoadableQuery.js +1 -1
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +35 -0
- package/react/hooks/useQueryRefHandlers.js +48 -0
- package/react/hooks/useQueryRefHandlers.js.map +1 -0
- package/react/hooks/useReadQuery.js +8 -2
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/index.d.ts +2 -0
- package/react/index.js +1 -0
- package/react/index.js.map +1 -1
- package/react/parser/index.js +6 -3
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +11 -3
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +11 -3
- package/react/query-preloader/createQueryPreloader.d.ts +253 -0
- package/react/query-preloader/createQueryPreloader.js +29 -0
- package/react/query-preloader/createQueryPreloader.js.map +1 -0
- package/react/react.cjs +248 -1
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +248 -1
- package/react/types/types.d.ts +6 -0
- package/react/types/types.js.map +1 -1
- package/testing/internal/index.d.ts +4 -0
- package/testing/internal/index.js +2 -0
- package/testing/internal/index.js.map +1 -1
- package/testing/internal/renderHelpers.d.ts +12 -0
- package/testing/internal/renderHelpers.js +22 -0
- package/testing/internal/renderHelpers.js.map +1 -0
- package/testing/internal/scenarios/index.d.ts +41 -0
- package/testing/internal/scenarios/index.js +46 -0
- package/testing/internal/scenarios/index.js.map +1 -0
- package/testing/matchers/index.js +2 -0
- package/testing/matchers/index.js.map +1 -1
- package/testing/matchers/toBeDisposed.d.ts +3 -0
- package/testing/matchers/toBeDisposed.js +26 -0
- package/testing/matchers/toBeDisposed.js.map +1 -0
- package/utilities/caching/caches.d.ts +34 -0
- package/utilities/caching/caches.js +64 -0
- package/utilities/caching/caches.js.map +1 -0
- package/utilities/caching/getMemoryInternals.d.ts +76 -0
- package/utilities/caching/getMemoryInternals.js +112 -0
- package/utilities/caching/getMemoryInternals.js.map +1 -0
- package/utilities/caching/index.d.ts +4 -0
- package/utilities/caching/index.js +3 -0
- package/utilities/caching/index.js.map +1 -0
- package/utilities/caching/sizes.d.ts +261 -0
- package/utilities/caching/sizes.js +27 -0
- package/utilities/caching/sizes.js.map +1 -0
- package/utilities/common/canUse.js +1 -1
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/canonicalStringify.js +8 -2
- package/utilities/common/canonicalStringify.js.map +1 -1
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/utilities/graphql/DocumentTransform.d.ts +14 -1
- package/utilities/graphql/DocumentTransform.js +9 -5
- package/utilities/graphql/DocumentTransform.js.map +1 -1
- package/utilities/graphql/print.js +6 -2
- package/utilities/graphql/print.js.map +1 -1
- package/utilities/index.d.ts +2 -0
- package/utilities/index.js +1 -0
- package/utilities/index.js.map +1 -1
- package/utilities/utilities.cjs +57 -9
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +57 -9
- package/version.js +1 -1
package/cache/cache.cjs
CHANGED
|
@@ -6,14 +6,64 @@ var globals = require('../utilities/globals');
|
|
|
6
6
|
var tslib = require('tslib');
|
|
7
7
|
var optimism = require('optimism');
|
|
8
8
|
var utilities = require('../utilities');
|
|
9
|
+
var caches = require('@wry/caches');
|
|
9
10
|
var equality = require('@wry/equality');
|
|
10
11
|
var trie = require('@wry/trie');
|
|
11
12
|
var graphql = require('graphql');
|
|
12
13
|
|
|
14
|
+
var getInMemoryCacheMemoryInternals = globalThis.__DEV__ !== false ?
|
|
15
|
+
_getInMemoryCacheMemoryInternals
|
|
16
|
+
: undefined;
|
|
17
|
+
var getApolloCacheMemoryInternals = globalThis.__DEV__ !== false ?
|
|
18
|
+
_getApolloCacheMemoryInternals
|
|
19
|
+
: undefined;
|
|
20
|
+
function _getApolloCacheMemoryInternals() {
|
|
21
|
+
return {
|
|
22
|
+
cache: {
|
|
23
|
+
fragmentQueryDocuments: getWrapperInformation(this["getFragmentDoc"]),
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function _getInMemoryCacheMemoryInternals() {
|
|
28
|
+
var fragments = this.config.fragments;
|
|
29
|
+
return tslib.__assign(tslib.__assign({}, _getApolloCacheMemoryInternals.apply(this)), { addTypenameDocumentTransform: transformInfo(this["addTypenameTransform"]), inMemoryCache: {
|
|
30
|
+
executeSelectionSet: getWrapperInformation(this["storeReader"]["executeSelectionSet"]),
|
|
31
|
+
executeSubSelectedArray: getWrapperInformation(this["storeReader"]["executeSubSelectedArray"]),
|
|
32
|
+
maybeBroadcastWatch: getWrapperInformation(this["maybeBroadcastWatch"]),
|
|
33
|
+
}, fragmentRegistry: {
|
|
34
|
+
findFragmentSpreads: getWrapperInformation(fragments === null || fragments === void 0 ? void 0 : fragments.findFragmentSpreads),
|
|
35
|
+
lookup: getWrapperInformation(fragments === null || fragments === void 0 ? void 0 : fragments.lookup),
|
|
36
|
+
transform: getWrapperInformation(fragments === null || fragments === void 0 ? void 0 : fragments.transform),
|
|
37
|
+
} });
|
|
38
|
+
}
|
|
39
|
+
function isWrapper(f) {
|
|
40
|
+
return !!f && "dirtyKey" in f;
|
|
41
|
+
}
|
|
42
|
+
function getWrapperInformation(f) {
|
|
43
|
+
return isWrapper(f) ? f.size : undefined;
|
|
44
|
+
}
|
|
45
|
+
function isDefined(value) {
|
|
46
|
+
return value != null;
|
|
47
|
+
}
|
|
48
|
+
function transformInfo(transform) {
|
|
49
|
+
return recurseTransformInfo(transform).map(function (cache) { return ({ cache: cache }); });
|
|
50
|
+
}
|
|
51
|
+
function recurseTransformInfo(transform) {
|
|
52
|
+
return transform ?
|
|
53
|
+
tslib.__spreadArray(tslib.__spreadArray([
|
|
54
|
+
getWrapperInformation(transform === null || transform === void 0 ? void 0 : transform["performWork"])
|
|
55
|
+
], recurseTransformInfo(transform === null || transform === void 0 ? void 0 : transform["left"]), true), recurseTransformInfo(transform === null || transform === void 0 ? void 0 : transform["right"]), true).filter(isDefined)
|
|
56
|
+
: [];
|
|
57
|
+
}
|
|
58
|
+
|
|
13
59
|
var ApolloCache = (function () {
|
|
14
60
|
function ApolloCache() {
|
|
15
61
|
this.assumeImmutableResults = false;
|
|
16
|
-
this.getFragmentDoc = optimism.wrap(utilities.getFragmentQueryDocument
|
|
62
|
+
this.getFragmentDoc = optimism.wrap(utilities.getFragmentQueryDocument, {
|
|
63
|
+
max: utilities.cacheSizes["cache.fragmentQueryDocuments"] ||
|
|
64
|
+
1000 ,
|
|
65
|
+
cache: caches.WeakCache,
|
|
66
|
+
});
|
|
17
67
|
}
|
|
18
68
|
ApolloCache.prototype.batch = function (options) {
|
|
19
69
|
var _this = this;
|
|
@@ -91,6 +141,9 @@ var ApolloCache = (function () {
|
|
|
91
141
|
};
|
|
92
142
|
return ApolloCache;
|
|
93
143
|
}());
|
|
144
|
+
if (globalThis.__DEV__ !== false) {
|
|
145
|
+
ApolloCache.prototype.getMemoryInternals = getApolloCacheMemoryInternals;
|
|
146
|
+
}
|
|
94
147
|
|
|
95
148
|
exports.Cache = void 0;
|
|
96
149
|
(function (Cache) {
|
|
@@ -827,7 +880,9 @@ var StoreReader = (function () {
|
|
|
827
880
|
maybeDependOnExistenceOfEntity(options.context.store, options.enclosingRef.__ref);
|
|
828
881
|
return _this.execSelectionSetImpl(options);
|
|
829
882
|
}, {
|
|
830
|
-
max: this.config.resultCacheMaxSize
|
|
883
|
+
max: this.config.resultCacheMaxSize ||
|
|
884
|
+
utilities.cacheSizes["inMemoryCache.executeSelectionSet"] ||
|
|
885
|
+
10000 ,
|
|
831
886
|
keyArgs: execSelectionSetKeyArgs,
|
|
832
887
|
makeCacheKey: function (selectionSet, parent, context, canonizeResults) {
|
|
833
888
|
if (supportsResultCaching(context.store)) {
|
|
@@ -839,7 +894,9 @@ var StoreReader = (function () {
|
|
|
839
894
|
maybeDependOnExistenceOfEntity(options.context.store, options.enclosingRef.__ref);
|
|
840
895
|
return _this.execSubSelectedArrayImpl(options);
|
|
841
896
|
}, {
|
|
842
|
-
max: this.config.resultCacheMaxSize
|
|
897
|
+
max: this.config.resultCacheMaxSize ||
|
|
898
|
+
utilities.cacheSizes["inMemoryCache.executeSubSelectedArray"] ||
|
|
899
|
+
5000 ,
|
|
843
900
|
makeCacheKey: function (_a) {
|
|
844
901
|
var field = _a.field, array = _a.array, context = _a.context;
|
|
845
902
|
if (supportsResultCaching(context.store)) {
|
|
@@ -2116,7 +2173,9 @@ var InMemoryCache = (function (_super) {
|
|
|
2116
2173
|
this.maybeBroadcastWatch = optimism.wrap(function (c, options) {
|
|
2117
2174
|
return _this.broadcastWatch(c, options);
|
|
2118
2175
|
}, {
|
|
2119
|
-
max: this.config.resultCacheMaxSize
|
|
2176
|
+
max: this.config.resultCacheMaxSize ||
|
|
2177
|
+
utilities.cacheSizes["inMemoryCache.maybeBroadcastWatch"] ||
|
|
2178
|
+
5000 ,
|
|
2120
2179
|
makeCacheKey: function (c) {
|
|
2121
2180
|
var store = c.optimistic ? _this.optimisticData : _this.data;
|
|
2122
2181
|
if (supportsResultCaching(store)) {
|
|
@@ -2371,6 +2430,9 @@ var InMemoryCache = (function (_super) {
|
|
|
2371
2430
|
};
|
|
2372
2431
|
return InMemoryCache;
|
|
2373
2432
|
}(ApolloCache));
|
|
2433
|
+
if (globalThis.__DEV__ !== false) {
|
|
2434
|
+
InMemoryCache.prototype.getMemoryInternals = getInMemoryCacheMemoryInternals;
|
|
2435
|
+
}
|
|
2374
2436
|
|
|
2375
2437
|
function createFragmentRegistry() {
|
|
2376
2438
|
var fragments = [];
|
|
@@ -2416,9 +2478,19 @@ var FragmentRegistry = (function () {
|
|
|
2416
2478
|
var proto = FragmentRegistry.prototype;
|
|
2417
2479
|
this.invalidate = (this.lookup = optimism.wrap(proto.lookup.bind(this), {
|
|
2418
2480
|
makeCacheKey: function (arg) { return arg; },
|
|
2481
|
+
max: utilities.cacheSizes["fragmentRegistry.lookup"] ||
|
|
2482
|
+
1000 ,
|
|
2419
2483
|
})).dirty;
|
|
2420
|
-
this.transform = optimism.wrap(proto.transform.bind(this)
|
|
2421
|
-
|
|
2484
|
+
this.transform = optimism.wrap(proto.transform.bind(this), {
|
|
2485
|
+
cache: caches.WeakCache,
|
|
2486
|
+
max: utilities.cacheSizes["fragmentRegistry.transform"] ||
|
|
2487
|
+
2000 ,
|
|
2488
|
+
});
|
|
2489
|
+
this.findFragmentSpreads = optimism.wrap(proto.findFragmentSpreads.bind(this), {
|
|
2490
|
+
cache: caches.WeakCache,
|
|
2491
|
+
max: utilities.cacheSizes["fragmentRegistry.findFragmentSpreads"] ||
|
|
2492
|
+
4000 ,
|
|
2493
|
+
});
|
|
2422
2494
|
};
|
|
2423
2495
|
FragmentRegistry.prototype.lookup = function (fragmentName) {
|
|
2424
2496
|
return this.registry[fragmentName] || null;
|