@apollo/client 3.8.0-beta.0 → 3.8.0-beta.1
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/apollo-client.cjs +120 -120
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +1 -2
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +1 -2
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +1 -2
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/core/ApolloClient.d.ts +1 -2
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.js +2 -2
- package/core/ObservableQuery.js +5 -5
- package/core/QueryManager.d.ts +1 -2
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +10 -11
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +19 -84
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +19 -84
- package/core/index.d.ts +1 -2
- package/core/index.d.ts.map +1 -1
- package/core/index.js +1 -2
- package/core/index.js.map +1 -1
- package/dev/dev.cjs +54 -54
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +54 -54
- package/invariantErrorCodes.js +53 -53
- package/link/core/ApolloLink.js +2 -2
- package/link/core/core.cjs +2 -2
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +2 -2
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +1 -1
- package/link/http/http.cjs +3 -3
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +3 -3
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/persisted-queries/persisted-queries.cjs +2 -2
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
- package/link/remove-typename/remove-typename.cjs +5 -6
- package/link/remove-typename/remove-typename.cjs.map +1 -1
- package/link/remove-typename/remove-typename.cjs.native.js +5 -6
- package/link/remove-typename/removeTypenameFromVariables.d.ts.map +1 -1
- package/link/remove-typename/removeTypenameFromVariables.js +5 -6
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/utils/toPromise.js +1 -1
- package/link/utils/utils.cjs +2 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +2 -2
- package/link/utils/validateOperation.js +1 -1
- package/package.json +1 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs +3 -3
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +3 -3
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc.cjs +2 -2
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +2 -2
- package/react/hoc/withApollo.js +1 -1
- package/react/hooks/hooks.cjs +9 -9
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +9 -9
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useBackgroundQuery.js +1 -1
- package/react/hooks/useQuery.js +1 -1
- package/react/hooks/useSubscription.js +2 -2
- package/react/hooks/useSuspenseCache.js +1 -1
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/parser/index.js +5 -5
- package/react/parser/parser.cjs +5 -5
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +5 -5
- package/testing/core/core.cjs +1 -1
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +1 -1
- package/testing/core/mocking/mockLink.js +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.map +1 -0
- package/{core → utilities/graphql}/DocumentTransform.js +4 -3
- package/utilities/graphql/DocumentTransform.js.map +1 -0
- package/utilities/index.d.ts +1 -0
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +1 -0
- package/utilities/index.js.map +1 -1
- package/utilities/utilities.cjs +86 -20
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +86 -20
- package/version.js +1 -1
- package/core/DocumentTransform.d.ts.map +0 -1
- package/core/DocumentTransform.js.map +0 -1
- /package/{core → utilities/graphql}/DocumentTransform.d.ts +0 -0
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var globals = require('./globals');
|
|
6
6
|
var graphql = require('graphql');
|
|
7
|
+
var trie = require('@wry/trie');
|
|
7
8
|
var tslib = require('tslib');
|
|
8
9
|
var zenObservableTs = require('zen-observable-ts');
|
|
9
10
|
require('symbol-observable');
|
|
@@ -77,6 +78,26 @@ function getInclusionDirectives(directives) {
|
|
|
77
78
|
return result;
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
var canUseWeakMap = typeof WeakMap === 'function' &&
|
|
82
|
+
globals.maybe(function () { return navigator.product; }) !== 'ReactNative';
|
|
83
|
+
var canUseWeakSet = typeof WeakSet === 'function';
|
|
84
|
+
var canUseSymbol = typeof Symbol === 'function' &&
|
|
85
|
+
typeof Symbol.for === 'function';
|
|
86
|
+
var canUseAsyncIteratorSymbol = canUseSymbol && Symbol.asyncIterator;
|
|
87
|
+
var canUseDOM = typeof globals.maybe(function () { return window.document.createElement; }) === "function";
|
|
88
|
+
var usingJSDOM = globals.maybe(function () { return navigator.userAgent.indexOf("jsdom") >= 0; }) || false;
|
|
89
|
+
var canUseLayoutEffect = canUseDOM && !usingJSDOM;
|
|
90
|
+
|
|
91
|
+
function isNonNullObject(obj) {
|
|
92
|
+
return obj !== null && typeof obj === 'object';
|
|
93
|
+
}
|
|
94
|
+
function isPlainObject(obj) {
|
|
95
|
+
return (obj !== null &&
|
|
96
|
+
typeof obj === 'object' &&
|
|
97
|
+
(Object.getPrototypeOf(obj) === Object.prototype ||
|
|
98
|
+
Object.getPrototypeOf(obj) === null));
|
|
99
|
+
}
|
|
100
|
+
|
|
80
101
|
function getFragmentQueryDocument(document, fragmentName) {
|
|
81
102
|
var actualFragmentName = fragmentName;
|
|
82
103
|
var fragments = [];
|
|
@@ -142,16 +163,6 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
142
163
|
}
|
|
143
164
|
}
|
|
144
165
|
|
|
145
|
-
function isNonNullObject(obj) {
|
|
146
|
-
return obj !== null && typeof obj === 'object';
|
|
147
|
-
}
|
|
148
|
-
function isPlainObject(obj) {
|
|
149
|
-
return (obj !== null &&
|
|
150
|
-
typeof obj === 'object' &&
|
|
151
|
-
(Object.getPrototypeOf(obj) === Object.prototype ||
|
|
152
|
-
Object.getPrototypeOf(obj) === null));
|
|
153
|
-
}
|
|
154
|
-
|
|
155
166
|
function makeReference(id) {
|
|
156
167
|
return { __ref: String(id) };
|
|
157
168
|
}
|
|
@@ -444,6 +455,70 @@ function getDefaultValues(definition) {
|
|
|
444
455
|
return defaultValues;
|
|
445
456
|
}
|
|
446
457
|
|
|
458
|
+
function identity(document) {
|
|
459
|
+
return document;
|
|
460
|
+
}
|
|
461
|
+
var DocumentTransform = (function () {
|
|
462
|
+
function DocumentTransform(transform, options) {
|
|
463
|
+
if (options === void 0) { options = Object.create(null); }
|
|
464
|
+
this.resultCache = canUseWeakSet
|
|
465
|
+
? new WeakSet()
|
|
466
|
+
: new Set();
|
|
467
|
+
this.transform = transform;
|
|
468
|
+
if (options.getCacheKey) {
|
|
469
|
+
this.getCacheKey = options.getCacheKey;
|
|
470
|
+
}
|
|
471
|
+
if (options.cache !== false) {
|
|
472
|
+
this.stableCacheKeys = new trie.Trie(canUseWeakMap, function (key) { return ({ key: key }); });
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
DocumentTransform.prototype.getCacheKey = function (document) {
|
|
476
|
+
return [document];
|
|
477
|
+
};
|
|
478
|
+
DocumentTransform.identity = function () {
|
|
479
|
+
return new DocumentTransform(identity, { cache: false });
|
|
480
|
+
};
|
|
481
|
+
DocumentTransform.split = function (predicate, left, right) {
|
|
482
|
+
if (right === void 0) { right = DocumentTransform.identity(); }
|
|
483
|
+
return new DocumentTransform(function (document) {
|
|
484
|
+
var documentTransform = predicate(document) ? left : right;
|
|
485
|
+
return documentTransform.transformDocument(document);
|
|
486
|
+
}, { cache: false });
|
|
487
|
+
};
|
|
488
|
+
DocumentTransform.prototype.transformDocument = function (document) {
|
|
489
|
+
if (this.resultCache.has(document)) {
|
|
490
|
+
return document;
|
|
491
|
+
}
|
|
492
|
+
var cacheEntry = this.getStableCacheEntry(document);
|
|
493
|
+
if (cacheEntry && cacheEntry.value) {
|
|
494
|
+
return cacheEntry.value;
|
|
495
|
+
}
|
|
496
|
+
checkDocument(document);
|
|
497
|
+
var transformedDocument = this.transform(document);
|
|
498
|
+
this.resultCache.add(transformedDocument);
|
|
499
|
+
if (cacheEntry) {
|
|
500
|
+
cacheEntry.value = transformedDocument;
|
|
501
|
+
}
|
|
502
|
+
return transformedDocument;
|
|
503
|
+
};
|
|
504
|
+
DocumentTransform.prototype.concat = function (otherTransform) {
|
|
505
|
+
var _this = this;
|
|
506
|
+
return new DocumentTransform(function (document) {
|
|
507
|
+
return otherTransform.transformDocument(_this.transformDocument(document));
|
|
508
|
+
}, { cache: false });
|
|
509
|
+
};
|
|
510
|
+
DocumentTransform.prototype.getStableCacheEntry = function (document) {
|
|
511
|
+
if (!this.stableCacheKeys)
|
|
512
|
+
return;
|
|
513
|
+
var cacheKeys = this.getCacheKey(document);
|
|
514
|
+
if (cacheKeys) {
|
|
515
|
+
globals.invariant(Array.isArray(cacheKeys), 65);
|
|
516
|
+
return this.stableCacheKeys.lookupArray(cacheKeys);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
return DocumentTransform;
|
|
520
|
+
}());
|
|
521
|
+
|
|
447
522
|
var isArray = Array.isArray;
|
|
448
523
|
function isNonEmptyArray(value) {
|
|
449
524
|
return Array.isArray(value) && value.length > 0;
|
|
@@ -1180,16 +1255,6 @@ function asyncMap(observable, mapFn, catchFn) {
|
|
|
1180
1255
|
});
|
|
1181
1256
|
}
|
|
1182
1257
|
|
|
1183
|
-
var canUseWeakMap = typeof WeakMap === 'function' &&
|
|
1184
|
-
globals.maybe(function () { return navigator.product; }) !== 'ReactNative';
|
|
1185
|
-
var canUseWeakSet = typeof WeakSet === 'function';
|
|
1186
|
-
var canUseSymbol = typeof Symbol === 'function' &&
|
|
1187
|
-
typeof Symbol.for === 'function';
|
|
1188
|
-
var canUseAsyncIteratorSymbol = canUseSymbol && Symbol.asyncIterator;
|
|
1189
|
-
var canUseDOM = typeof globals.maybe(function () { return window.document.createElement; }) === "function";
|
|
1190
|
-
var usingJSDOM = globals.maybe(function () { return navigator.userAgent.indexOf("jsdom") >= 0; }) || false;
|
|
1191
|
-
var canUseLayoutEffect = canUseDOM && !usingJSDOM;
|
|
1192
|
-
|
|
1193
1258
|
function fixObservableSubclass(subclass) {
|
|
1194
1259
|
function set(key) {
|
|
1195
1260
|
Object.defineProperty(subclass, key, { value: zenObservableTs.Observable });
|
|
@@ -1494,6 +1559,7 @@ exports.maybe = globals.maybe;
|
|
|
1494
1559
|
exports.Observable = zenObservableTs.Observable;
|
|
1495
1560
|
exports.Concast = Concast;
|
|
1496
1561
|
exports.DeepMerger = DeepMerger;
|
|
1562
|
+
exports.DocumentTransform = DocumentTransform;
|
|
1497
1563
|
exports.addTypenameToDocument = addTypenameToDocument;
|
|
1498
1564
|
exports.argumentsObjectFromField = argumentsObjectFromField;
|
|
1499
1565
|
exports.asyncMap = asyncMap;
|
package/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export var version = '3.8.0-beta.
|
|
1
|
+
export var version = '3.8.0-beta.1';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentTransform.d.ts","sourceRoot":"","sources":["../../src/core/DocumentTransform.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,yBAAyB,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;AAE/D,KAAK,WAAW,GAAG,CAAC,QAAQ,EAAE,YAAY,KAAK,YAAY,CAAC;AAE5D,UAAU,wBAAwB;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,CACZ,QAAQ,EAAE,YAAY,KACnB,yBAAyB,GAAG,SAAS,CAAC;CAC5C;AAMD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;IAExC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAEA;IAE5B,OAAO,CAAC,eAAe,CAET;IAOd,OAAO,CAAC,WAAW;IAMnB,MAAM,CAAC,QAAQ;IAOf,MAAM,CAAC,KAAK,CACV,SAAS,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,OAAO,EAC9C,IAAI,EAAE,iBAAiB,EACvB,KAAK,GAAE,iBAAgD;gBAcvD,SAAS,EAAE,WAAW,EACtB,OAAO,GAAE,wBAA8C;IAczD,iBAAiB,CAAC,QAAQ,EAAE,YAAY;IA0BxC,MAAM,CAAC,cAAc,EAAE,iBAAiB;IAYxC,mBAAmB,CAAC,QAAQ,EAAE,YAAY;;;;CAW3C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentTransform.js","sourceRoot":"","sources":["../../src/core/DocumentTransform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE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8GC","sourcesContent":["import { Trie } from '@wry/trie';\nimport { canUseWeakMap, canUseWeakSet, checkDocument } from '../utilities';\nimport { invariant } from '../utilities/globals';\nimport type { DocumentNode } from 'graphql';\n\nexport type DocumentTransformCacheKey = ReadonlyArray<unknown>;\n\ntype TransformFn = (document: DocumentNode) => DocumentNode;\n\ninterface DocumentTransformOptions {\n cache?: boolean;\n getCacheKey?: (\n document: DocumentNode\n ) => DocumentTransformCacheKey | undefined;\n}\n\nfunction identity(document: DocumentNode) {\n return document;\n}\n\nexport class DocumentTransform {\n private readonly transform: TransformFn;\n\n private readonly resultCache = canUseWeakSet\n ? new WeakSet<DocumentNode>()\n : new Set<DocumentNode>();\n\n private stableCacheKeys:\n | Trie<{ key: DocumentTransformCacheKey; value?: DocumentNode }>\n | undefined;\n\n // This default implementation of getCacheKey can be overridden by providing\n // options.getCacheKey to the DocumentTransform constructor. In general, a\n // getCacheKey function may either return an array of keys (often including\n // the document) to be used as a cache key, or undefined to indicate the\n // transform for this document should not be cached.\n private getCacheKey(\n document: DocumentNode\n ): DocumentTransformCacheKey | undefined {\n return [document];\n }\n\n static identity() {\n // No need to cache this transform since it just returns the document\n // unchanged. This should save a bit of memory that would otherwise be\n // needed to populate the `documentCache` of this transform.\n return new DocumentTransform(identity, { cache: false });\n }\n\n static split(\n predicate: (document: DocumentNode) => boolean,\n left: DocumentTransform,\n right: DocumentTransform = DocumentTransform.identity()\n ) {\n return new DocumentTransform(\n (document) => {\n const documentTransform = predicate(document) ? left : right;\n\n return documentTransform.transformDocument(document);\n },\n // Reasonably assume both `left` and `right` transforms handle their own caching\n { cache: false }\n );\n }\n\n constructor(\n transform: TransformFn,\n options: DocumentTransformOptions = Object.create(null)\n ) {\n this.transform = transform;\n\n if (options.getCacheKey) {\n // Override default `getCacheKey` function, which returns [document].\n this.getCacheKey = options.getCacheKey;\n }\n\n if (options.cache !== false) {\n this.stableCacheKeys = new Trie(canUseWeakMap, (key) => ({ key }));\n }\n }\n\n transformDocument(document: DocumentNode) {\n // If a user passes an already transformed result back to this function,\n // immediately return it.\n if (this.resultCache.has(document)) {\n return document;\n }\n\n const cacheEntry = this.getStableCacheEntry(document);\n\n if (cacheEntry && cacheEntry.value) {\n return cacheEntry.value;\n }\n\n checkDocument(document);\n\n const transformedDocument = this.transform(document);\n\n this.resultCache.add(transformedDocument);\n\n if (cacheEntry) {\n cacheEntry.value = transformedDocument;\n }\n\n return transformedDocument;\n }\n\n concat(otherTransform: DocumentTransform) {\n return new DocumentTransform(\n (document) => {\n return otherTransform.transformDocument(\n this.transformDocument(document)\n );\n },\n // Reasonably assume both transforms handle their own caching\n { cache: false }\n );\n }\n\n getStableCacheEntry(document: DocumentNode) {\n if (!this.stableCacheKeys) return;\n const cacheKeys = this.getCacheKey(document);\n if (cacheKeys) {\n invariant(\n Array.isArray(cacheKeys),\n '`getCacheKey` must return an array or undefined'\n );\n return this.stableCacheKeys.lookupArray(cacheKeys);\n }\n }\n}\n"]}
|
|
File without changes
|