@apollo/client 3.11.7 → 3.12.0-alpha.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/nasty-camels-pay.md +36 -0
- package/.changeset/pre.json +10 -0
- package/CHANGELOG.md +43 -0
- package/apollo-client.cjs +438 -111
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +218 -22
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +218 -22
- package/cache/core/cache.d.ts +13 -10
- package/cache/core/cache.js +32 -14
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +2 -1
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +4 -3
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/inMemoryCache.d.ts +3 -1
- package/cache/inmemory/inMemoryCache.js +7 -0
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- 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/ApolloClient.d.ts +14 -6
- package/core/ApolloClient.js +14 -6
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.js +2 -2
- package/core/ObservableQuery.d.ts +17 -14
- package/core/ObservableQuery.js +29 -16
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +18 -3
- package/core/QueryManager.js +39 -14
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +285 -37
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +285 -37
- package/core/index.d.ts +1 -0
- package/core/index.js.map +1 -1
- package/core/masking.d.ts +4 -0
- package/core/masking.js +212 -0
- package/core/masking.js.map +1 -0
- package/core/types.d.ts +3 -2
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +8 -6
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +131 -87
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +131 -87
- package/invariantErrorCodes.js +140 -86
- 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 +6 -6
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +6 -6
- package/link/http/selectHttpOptionsAndBody.js +3 -3
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- 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/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/masking/index.d.ts +2 -0
- package/masking/index.js +2 -0
- package/masking/index.js.map +1 -0
- package/masking/internal/types.d.ts +15 -0
- package/masking/internal/types.js +2 -0
- package/masking/internal/types.js.map +1 -0
- package/masking/masking.cjs +3 -0
- package/masking/masking.cjs.map +1 -0
- package/masking/masking.cjs.native.js +3 -0
- package/masking/masking.d.cts +1 -0
- package/masking/package.json +8 -0
- package/masking/types.d.ts +44 -0
- package/masking/types.js +2 -0
- package/masking/types.js.map +1 -0
- package/package.json +2 -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 +24 -16
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +24 -16
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useFragment.d.ts +4 -3
- package/react/hooks/useFragment.js +12 -5
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.js +1 -1
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.js +2 -2
- package/react/hooks/useQuery.d.ts +4 -3
- package/react/hooks/useQuery.js +2 -1
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +2 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +2 -1
- package/react/hooks/useSubscription.js +3 -3
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +6 -5
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/internal/cache/QueryReference.d.ts +5 -4
- package/react/internal/cache/QueryReference.js +1 -1
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/internal.cjs +2 -2
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +2 -2
- 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/react/types/types.d.ts +18 -42
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +3 -3
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +3 -3
- package/testing/core/mocking/mockLink.d.ts +3 -2
- package/testing/core/mocking/mockLink.js +3 -3
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts +1 -0
- package/testing/core/mocking/mockQueryManager.js +1 -1
- package/testing/core/mocking/mockQueryManager.js.map +1 -1
- package/testing/internal/disposables/index.d.ts +1 -0
- package/testing/internal/disposables/index.js +1 -0
- package/testing/internal/disposables/index.js.map +1 -1
- package/testing/internal/disposables/withProdMode.d.ts +4 -0
- package/testing/internal/disposables/withProdMode.js +10 -0
- package/testing/internal/disposables/withProdMode.js.map +1 -0
- package/testing/internal/scenarios/index.d.ts +28 -0
- package/testing/internal/scenarios/index.js +18 -2
- package/testing/internal/scenarios/index.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.d.ts +1 -0
- package/utilities/common/maybeDeepFreeze.js +1 -1
- package/utilities/common/maybeDeepFreeze.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.js +1 -1
- package/utilities/graphql/directives.d.ts +3 -1
- package/utilities/graphql/directives.js +39 -5
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.js +3 -3
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/transform.d.ts +1 -0
- package/utilities/graphql/transform.js +15 -2
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +7 -3
- package/utilities/index.js +4 -3
- package/utilities/index.js.map +1 -1
- package/utilities/promises/preventUnhandledRejection.d.ts +2 -0
- package/utilities/promises/preventUnhandledRejection.js +5 -0
- package/utilities/promises/preventUnhandledRejection.js.map +1 -0
- package/utilities/subscriptions/relay/relay.cjs.map +1 -1
- package/utilities/subscriptions/urql/urql.cjs.map +1 -1
- package/utilities/types/NoInfer.d.ts +27 -0
- package/utilities/types/NoInfer.js +2 -0
- package/utilities/types/NoInfer.js.map +1 -0
- package/utilities/types/Prettify.d.ts +4 -0
- package/utilities/types/Prettify.js +2 -0
- package/utilities/types/Prettify.js.map +1 -0
- package/utilities/types/UnionToIntersection.d.ts +2 -0
- package/utilities/types/UnionToIntersection.js +2 -0
- package/utilities/types/UnionToIntersection.js.map +1 -0
- package/utilities/utilities.cjs +73 -19
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +73 -19
- package/version.js +1 -1
package/core/core.cjs.native.js
CHANGED
|
@@ -20,7 +20,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
20
20
|
|
|
21
21
|
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
22
22
|
|
|
23
|
-
var version = "3.
|
|
23
|
+
var version = "3.12.0-alpha.0";
|
|
24
24
|
|
|
25
25
|
function isNonNullObject(obj) {
|
|
26
26
|
return obj !== null && typeof obj === "object";
|
|
@@ -213,7 +213,7 @@ var ObservableQuery = (function (_super) {
|
|
|
213
213
|
observer.error && observer.error(last.error);
|
|
214
214
|
}
|
|
215
215
|
else if (last && last.result) {
|
|
216
|
-
observer.next && observer.next(last.result);
|
|
216
|
+
observer.next && observer.next(_this.maskResult(last.result));
|
|
217
217
|
}
|
|
218
218
|
if (first) {
|
|
219
219
|
_this.reobserve().catch(function () { });
|
|
@@ -231,6 +231,7 @@ var ObservableQuery = (function (_super) {
|
|
|
231
231
|
_this.waitForOwnResult = skipCacheDataFor(options.fetchPolicy);
|
|
232
232
|
_this.isTornDown = false;
|
|
233
233
|
_this.subscribeToMore = _this.subscribeToMore.bind(_this);
|
|
234
|
+
_this.maskResult = _this.maskResult.bind(_this);
|
|
234
235
|
var _b = queryManager.defaultOptions.watchQuery, _c = _b === void 0 ? {} : _b, _d = _c.fetchPolicy, defaultFetchPolicy = _d === void 0 ? "cache-first" : _d;
|
|
235
236
|
var _e = options.fetchPolicy, fetchPolicy = _e === void 0 ? defaultFetchPolicy : _e,
|
|
236
237
|
_f = options.initialFetchPolicy,
|
|
@@ -279,7 +280,7 @@ var ObservableQuery = (function (_super) {
|
|
|
279
280
|
ObservableQuery.prototype.resetDiff = function () {
|
|
280
281
|
this.queryInfo.resetDiff();
|
|
281
282
|
};
|
|
282
|
-
ObservableQuery.prototype.
|
|
283
|
+
ObservableQuery.prototype.getCurrentFullResult = function (saveAsLastResult) {
|
|
283
284
|
if (saveAsLastResult === void 0) { saveAsLastResult = true; }
|
|
284
285
|
var lastResult = this.getLastResult(true);
|
|
285
286
|
var networkStatus = this.queryInfo.networkStatus ||
|
|
@@ -327,12 +328,19 @@ var ObservableQuery = (function (_super) {
|
|
|
327
328
|
}
|
|
328
329
|
return result;
|
|
329
330
|
};
|
|
331
|
+
ObservableQuery.prototype.getCurrentResult = function (saveAsLastResult) {
|
|
332
|
+
if (saveAsLastResult === void 0) { saveAsLastResult = true; }
|
|
333
|
+
return this.maskResult(this.getCurrentFullResult(saveAsLastResult));
|
|
334
|
+
};
|
|
330
335
|
ObservableQuery.prototype.isDifferentFromLastResult = function (newResult, variables) {
|
|
331
336
|
if (!this.last) {
|
|
332
337
|
return true;
|
|
333
338
|
}
|
|
334
|
-
var
|
|
335
|
-
|
|
339
|
+
var documentInfo = this.queryManager.getDocumentInfo(this.query);
|
|
340
|
+
var dataMasking = this.queryManager.dataMasking;
|
|
341
|
+
var query = dataMasking ? documentInfo.nonReactiveQuery : this.query;
|
|
342
|
+
var resultIsDifferent = dataMasking || documentInfo.hasNonreactiveDirective ?
|
|
343
|
+
!equalByQuery(query, this.last.result, newResult, this.variables)
|
|
336
344
|
: !equal.equal(this.last.result, newResult);
|
|
337
345
|
return (resultIsDifferent || (variables && !equal.equal(this.last.variables, variables)));
|
|
338
346
|
};
|
|
@@ -377,7 +385,7 @@ var ObservableQuery = (function (_super) {
|
|
|
377
385
|
var vars = queryDef.variableDefinitions;
|
|
378
386
|
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
379
387
|
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
380
|
-
|
|
388
|
+
21,
|
|
381
389
|
variables,
|
|
382
390
|
((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
|
|
383
391
|
);
|
|
@@ -409,7 +417,7 @@ var ObservableQuery = (function (_super) {
|
|
|
409
417
|
var updateQuery = fetchMoreOptions === null || fetchMoreOptions === void 0 ? void 0 : fetchMoreOptions.updateQuery;
|
|
410
418
|
var isCached = this.options.fetchPolicy !== "no-cache";
|
|
411
419
|
if (!isCached) {
|
|
412
|
-
globals.invariant(updateQuery,
|
|
420
|
+
globals.invariant(updateQuery, 22);
|
|
413
421
|
}
|
|
414
422
|
return this.queryManager
|
|
415
423
|
.fetchQuery(qid, combinedOptions, exports.NetworkStatus.fetchMore)
|
|
@@ -456,7 +464,7 @@ var ObservableQuery = (function (_super) {
|
|
|
456
464
|
});
|
|
457
465
|
_this.reportResult(tslib.__assign(tslib.__assign({}, lastResult), { data: data }), _this.variables);
|
|
458
466
|
}
|
|
459
|
-
return fetchMoreResult;
|
|
467
|
+
return _this.maskResult(fetchMoreResult);
|
|
460
468
|
})
|
|
461
469
|
.finally(function () {
|
|
462
470
|
if (isCached && !updatedQuerySet.has(_this.query)) {
|
|
@@ -490,7 +498,7 @@ var ObservableQuery = (function (_super) {
|
|
|
490
498
|
options.onError(err);
|
|
491
499
|
return;
|
|
492
500
|
}
|
|
493
|
-
globalThis.__DEV__ !== false && globals.invariant.error(
|
|
501
|
+
globalThis.__DEV__ !== false && globals.invariant.error(23, err);
|
|
494
502
|
},
|
|
495
503
|
});
|
|
496
504
|
this.subscriptions.add(subscription);
|
|
@@ -590,7 +598,7 @@ var ObservableQuery = (function (_super) {
|
|
|
590
598
|
if (pollingInfo && pollingInfo.interval === pollInterval) {
|
|
591
599
|
return;
|
|
592
600
|
}
|
|
593
|
-
globals.invariant(pollInterval,
|
|
601
|
+
globals.invariant(pollInterval, 24);
|
|
594
602
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
595
603
|
info.interval = pollInterval;
|
|
596
604
|
var maybeFetch = function () {
|
|
@@ -693,8 +701,7 @@ var ObservableQuery = (function (_super) {
|
|
|
693
701
|
return concast;
|
|
694
702
|
};
|
|
695
703
|
ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
|
|
696
|
-
return this.reobserveAsConcast(newOptions, newNetworkStatus)
|
|
697
|
-
.promise;
|
|
704
|
+
return utilities.preventUnhandledRejection(this.reobserveAsConcast(newOptions, newNetworkStatus).promise.then(this.maskResult));
|
|
698
705
|
};
|
|
699
706
|
ObservableQuery.prototype.resubscribeAfterError = function () {
|
|
700
707
|
var args = [];
|
|
@@ -709,7 +716,7 @@ var ObservableQuery = (function (_super) {
|
|
|
709
716
|
};
|
|
710
717
|
ObservableQuery.prototype.observe = function () {
|
|
711
718
|
this.reportResult(
|
|
712
|
-
this.
|
|
719
|
+
this.getCurrentFullResult(false), this.variables);
|
|
713
720
|
};
|
|
714
721
|
ObservableQuery.prototype.reportResult = function (result, variables) {
|
|
715
722
|
var lastError = this.getLastError();
|
|
@@ -718,7 +725,7 @@ var ObservableQuery = (function (_super) {
|
|
|
718
725
|
this.updateLastResult(result, variables);
|
|
719
726
|
}
|
|
720
727
|
if (lastError || isDifferent) {
|
|
721
|
-
utilities.iterateObserversSafely(this.observers, "next", result);
|
|
728
|
+
utilities.iterateObserversSafely(this.observers, "next", this.maskResult(result));
|
|
722
729
|
}
|
|
723
730
|
};
|
|
724
731
|
ObservableQuery.prototype.reportError = function (error, variables) {
|
|
@@ -747,6 +754,12 @@ var ObservableQuery = (function (_super) {
|
|
|
747
754
|
ObservableQuery.prototype.transformDocument = function (document) {
|
|
748
755
|
return this.queryManager.transform(document);
|
|
749
756
|
};
|
|
757
|
+
ObservableQuery.prototype.maskResult = function (result) {
|
|
758
|
+
return result && "data" in result ? tslib.__assign(tslib.__assign({}, result), { data: this.queryManager.maskOperation({
|
|
759
|
+
document: this.query,
|
|
760
|
+
data: result.data,
|
|
761
|
+
}) }) : result;
|
|
762
|
+
};
|
|
750
763
|
return ObservableQuery;
|
|
751
764
|
}(utilities.Observable));
|
|
752
765
|
utilities.fixObservableSubclass(ObservableQuery);
|
|
@@ -767,11 +780,11 @@ function reobserveCacheFirst(obsQuery) {
|
|
|
767
780
|
return obsQuery.reobserve();
|
|
768
781
|
}
|
|
769
782
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
770
|
-
globalThis.__DEV__ !== false && globals.invariant.error(
|
|
783
|
+
globalThis.__DEV__ !== false && globals.invariant.error(25, error.message, error.stack);
|
|
771
784
|
}
|
|
772
785
|
function logMissingFieldErrors(missing) {
|
|
773
786
|
if (globalThis.__DEV__ !== false && missing) {
|
|
774
|
-
globalThis.__DEV__ !== false && globals.invariant.debug(
|
|
787
|
+
globalThis.__DEV__ !== false && globals.invariant.debug(26, missing);
|
|
775
788
|
}
|
|
776
789
|
}
|
|
777
790
|
function skipCacheDataFor(fetchPolicy ) {
|
|
@@ -1058,6 +1071,209 @@ function shouldWriteResult(result, errorPolicy) {
|
|
|
1058
1071
|
return writeWithErrors;
|
|
1059
1072
|
}
|
|
1060
1073
|
|
|
1074
|
+
function maskOperation(data, document, cache) {
|
|
1075
|
+
var _a;
|
|
1076
|
+
if (!cache.fragmentMatches) {
|
|
1077
|
+
if (globalThis.__DEV__ !== false) {
|
|
1078
|
+
warnOnImproperCacheImplementation();
|
|
1079
|
+
}
|
|
1080
|
+
return data;
|
|
1081
|
+
}
|
|
1082
|
+
var definition = utilities.getOperationDefinition(document);
|
|
1083
|
+
globals.invariant(definition, 37);
|
|
1084
|
+
if (data == null) {
|
|
1085
|
+
return data;
|
|
1086
|
+
}
|
|
1087
|
+
var context = {
|
|
1088
|
+
operationType: definition.operation,
|
|
1089
|
+
operationName: (_a = definition.name) === null || _a === void 0 ? void 0 : _a.value,
|
|
1090
|
+
fragmentMap: utilities.createFragmentMap(utilities.getFragmentDefinitions(document)),
|
|
1091
|
+
cache: cache,
|
|
1092
|
+
};
|
|
1093
|
+
var _b = maskSelectionSet(data, definition.selectionSet, context), masked = _b[0], changed = _b[1];
|
|
1094
|
+
if (Object.isFrozen(data)) {
|
|
1095
|
+
context.disableWarnings = true;
|
|
1096
|
+
utilities.maybeDeepFreeze(masked);
|
|
1097
|
+
context.disableWarnings = false;
|
|
1098
|
+
}
|
|
1099
|
+
return changed ? masked : data;
|
|
1100
|
+
}
|
|
1101
|
+
function maskFragment(data, document, cache, fragmentName) {
|
|
1102
|
+
if (!cache.fragmentMatches) {
|
|
1103
|
+
if (globalThis.__DEV__ !== false) {
|
|
1104
|
+
warnOnImproperCacheImplementation();
|
|
1105
|
+
}
|
|
1106
|
+
return data;
|
|
1107
|
+
}
|
|
1108
|
+
var fragments = document.definitions.filter(function (node) {
|
|
1109
|
+
return node.kind === graphql.Kind.FRAGMENT_DEFINITION;
|
|
1110
|
+
});
|
|
1111
|
+
if (typeof fragmentName === "undefined") {
|
|
1112
|
+
globals.invariant(fragments.length === 1, 38, fragments.length);
|
|
1113
|
+
fragmentName = fragments[0].name.value;
|
|
1114
|
+
}
|
|
1115
|
+
var fragment = fragments.find(function (fragment) { return fragment.name.value === fragmentName; });
|
|
1116
|
+
globals.invariant(!!fragment, 39, fragmentName);
|
|
1117
|
+
if (data == null) {
|
|
1118
|
+
return data;
|
|
1119
|
+
}
|
|
1120
|
+
var context = {
|
|
1121
|
+
operationType: "fragment",
|
|
1122
|
+
operationName: fragment.name.value,
|
|
1123
|
+
fragmentMap: utilities.createFragmentMap(utilities.getFragmentDefinitions(document)),
|
|
1124
|
+
cache: cache,
|
|
1125
|
+
};
|
|
1126
|
+
var _a = maskSelectionSet(data, fragment.selectionSet, context), masked = _a[0], changed = _a[1];
|
|
1127
|
+
if (Object.isFrozen(data)) {
|
|
1128
|
+
context.disableWarnings = true;
|
|
1129
|
+
utilities.maybeDeepFreeze(masked);
|
|
1130
|
+
context.disableWarnings = false;
|
|
1131
|
+
}
|
|
1132
|
+
return changed ? masked : data;
|
|
1133
|
+
}
|
|
1134
|
+
function maskSelectionSet(data, selectionSet, context, path) {
|
|
1135
|
+
if (Array.isArray(data)) {
|
|
1136
|
+
var changed_1 = false;
|
|
1137
|
+
var masked = data.map(function (item, index) {
|
|
1138
|
+
if (item === null) {
|
|
1139
|
+
return null;
|
|
1140
|
+
}
|
|
1141
|
+
var _a = maskSelectionSet(item, selectionSet, context, globalThis.__DEV__ !== false ? "".concat(path || "", "[").concat(index, "]") : void 0), masked = _a[0], itemChanged = _a[1];
|
|
1142
|
+
changed_1 || (changed_1 = itemChanged);
|
|
1143
|
+
return itemChanged ? masked : item;
|
|
1144
|
+
});
|
|
1145
|
+
return [changed_1 ? masked : data, changed_1];
|
|
1146
|
+
}
|
|
1147
|
+
var result = selectionSet.selections.reduce(function (_a, selection) {
|
|
1148
|
+
var memo = _a[0], changed = _a[1];
|
|
1149
|
+
switch (selection.kind) {
|
|
1150
|
+
case graphql.Kind.FIELD: {
|
|
1151
|
+
var keyName = utilities.resultKeyNameFromField(selection);
|
|
1152
|
+
var childSelectionSet = selection.selectionSet;
|
|
1153
|
+
memo[keyName] = data[keyName];
|
|
1154
|
+
if (childSelectionSet && data[keyName] !== null) {
|
|
1155
|
+
var _b = maskSelectionSet(data[keyName], childSelectionSet, context, globalThis.__DEV__ !== false ? "".concat(path || "", ".").concat(keyName) : void 0), masked = _b[0], childChanged = _b[1];
|
|
1156
|
+
if (childChanged ||
|
|
1157
|
+
Object.keys(masked).length !== Object.keys(data[keyName]).length) {
|
|
1158
|
+
memo[keyName] = masked;
|
|
1159
|
+
changed = true;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
return [memo, changed];
|
|
1163
|
+
}
|
|
1164
|
+
case graphql.Kind.INLINE_FRAGMENT: {
|
|
1165
|
+
if (selection.typeCondition &&
|
|
1166
|
+
!context.cache.fragmentMatches(selection, data.__typename)) {
|
|
1167
|
+
return [memo, changed];
|
|
1168
|
+
}
|
|
1169
|
+
var _c = maskSelectionSet(data, selection.selectionSet, context, path), fragmentData = _c[0], childChanged = _c[1];
|
|
1170
|
+
return [
|
|
1171
|
+
tslib.__assign(tslib.__assign({}, memo), fragmentData),
|
|
1172
|
+
changed || childChanged,
|
|
1173
|
+
];
|
|
1174
|
+
}
|
|
1175
|
+
case graphql.Kind.FRAGMENT_SPREAD: {
|
|
1176
|
+
var fragmentName = selection.name.value;
|
|
1177
|
+
var fragment = context.fragmentMap[fragmentName] ||
|
|
1178
|
+
(context.fragmentMap[fragmentName] =
|
|
1179
|
+
context.cache.lookupFragment(fragmentName));
|
|
1180
|
+
globals.invariant(fragment, 40, fragmentName);
|
|
1181
|
+
var mode = utilities.getFragmentMaskMode(selection);
|
|
1182
|
+
if (mode === "mask") {
|
|
1183
|
+
return [memo, true];
|
|
1184
|
+
}
|
|
1185
|
+
if (globalThis.__DEV__ !== false) {
|
|
1186
|
+
if (mode === "migrate") {
|
|
1187
|
+
return [
|
|
1188
|
+
addFieldAccessorWarnings(memo, data, fragment.selectionSet, path || "", context),
|
|
1189
|
+
true,
|
|
1190
|
+
];
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
var _d = maskSelectionSet(data, fragment.selectionSet, context, path), fragmentData = _d[0], changed_2 = _d[1];
|
|
1194
|
+
return [tslib.__assign(tslib.__assign({}, memo), fragmentData), changed_2];
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}, [Object.create(null), false]);
|
|
1198
|
+
if ("__typename" in data && !("__typename" in result[0])) {
|
|
1199
|
+
result[0].__typename = data.__typename;
|
|
1200
|
+
}
|
|
1201
|
+
return result;
|
|
1202
|
+
}
|
|
1203
|
+
function addFieldAccessorWarnings(memo, data, selectionSetNode, path, context) {
|
|
1204
|
+
if (Array.isArray(data)) {
|
|
1205
|
+
return data.map(function (item, index) {
|
|
1206
|
+
return addFieldAccessorWarnings(memo[index] || Object.create(null), item, selectionSetNode, "".concat(path, "[").concat(index, "]"), context);
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
return selectionSetNode.selections.reduce(function (memo, selection) {
|
|
1210
|
+
switch (selection.kind) {
|
|
1211
|
+
case graphql.Kind.FIELD: {
|
|
1212
|
+
var keyName = utilities.resultKeyNameFromField(selection);
|
|
1213
|
+
var childSelectionSet = selection.selectionSet;
|
|
1214
|
+
if (keyName in memo) {
|
|
1215
|
+
return memo;
|
|
1216
|
+
}
|
|
1217
|
+
var value = data[keyName];
|
|
1218
|
+
if (childSelectionSet) {
|
|
1219
|
+
value = addFieldAccessorWarnings(memo[keyName] || Object.create(null), data[keyName], childSelectionSet, "".concat(path, ".").concat(keyName), context);
|
|
1220
|
+
}
|
|
1221
|
+
if (globalThis.__DEV__ !== false) {
|
|
1222
|
+
addAccessorWarning(memo, value, keyName, path, context);
|
|
1223
|
+
}
|
|
1224
|
+
if (!(globalThis.__DEV__ !== false)) {
|
|
1225
|
+
memo[keyName] = data[keyName];
|
|
1226
|
+
}
|
|
1227
|
+
return memo;
|
|
1228
|
+
}
|
|
1229
|
+
case graphql.Kind.INLINE_FRAGMENT: {
|
|
1230
|
+
return addFieldAccessorWarnings(memo, data, selection.selectionSet, path, context);
|
|
1231
|
+
}
|
|
1232
|
+
case graphql.Kind.FRAGMENT_SPREAD: {
|
|
1233
|
+
var fragment = context.fragmentMap[selection.name.value];
|
|
1234
|
+
var mode = utilities.getFragmentMaskMode(selection);
|
|
1235
|
+
if (mode === "mask") {
|
|
1236
|
+
return memo;
|
|
1237
|
+
}
|
|
1238
|
+
if (mode === "unmask") {
|
|
1239
|
+
var fragmentData = maskSelectionSet(data, fragment.selectionSet, context, path)[0];
|
|
1240
|
+
return Object.assign(memo, fragmentData);
|
|
1241
|
+
}
|
|
1242
|
+
return addFieldAccessorWarnings(memo, data, fragment.selectionSet, path, context);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
}, memo);
|
|
1246
|
+
}
|
|
1247
|
+
function addAccessorWarning(data, value, fieldName, path, context) {
|
|
1248
|
+
var getValue = function () {
|
|
1249
|
+
if (context.disableWarnings) {
|
|
1250
|
+
return value;
|
|
1251
|
+
}
|
|
1252
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(41, context.operationName ?
|
|
1253
|
+
"".concat(context.operationType, " '").concat(context.operationName, "'")
|
|
1254
|
+
: "anonymous ".concat(context.operationType), "".concat(path, ".").concat(fieldName).replace(/^\./, ""));
|
|
1255
|
+
getValue = function () { return value; };
|
|
1256
|
+
return value;
|
|
1257
|
+
};
|
|
1258
|
+
Object.defineProperty(data, fieldName, {
|
|
1259
|
+
get: function () {
|
|
1260
|
+
return getValue();
|
|
1261
|
+
},
|
|
1262
|
+
set: function (value) {
|
|
1263
|
+
getValue = function () { return value; };
|
|
1264
|
+
},
|
|
1265
|
+
enumerable: true,
|
|
1266
|
+
configurable: true,
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
var issuedWarning = false;
|
|
1270
|
+
function warnOnImproperCacheImplementation() {
|
|
1271
|
+
if (!issuedWarning) {
|
|
1272
|
+
issuedWarning = true;
|
|
1273
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(42);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1061
1277
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1062
1278
|
var IGNORE = Object.create(null);
|
|
1063
1279
|
var QueryManager = (function () {
|
|
@@ -1082,6 +1298,7 @@ var QueryManager = (function () {
|
|
|
1082
1298
|
this.localState = options.localState;
|
|
1083
1299
|
this.ssrMode = options.ssrMode;
|
|
1084
1300
|
this.assumeImmutableResults = options.assumeImmutableResults;
|
|
1301
|
+
this.dataMasking = options.dataMasking;
|
|
1085
1302
|
var documentTransform = options.documentTransform;
|
|
1086
1303
|
this.documentTransform =
|
|
1087
1304
|
documentTransform ?
|
|
@@ -1099,7 +1316,7 @@ var QueryManager = (function () {
|
|
|
1099
1316
|
this.queries.forEach(function (_info, queryId) {
|
|
1100
1317
|
_this.stopQueryNoBroadcast(queryId);
|
|
1101
1318
|
});
|
|
1102
|
-
this.cancelPendingFetches(globals.newInvariantError(
|
|
1319
|
+
this.cancelPendingFetches(globals.newInvariantError(27));
|
|
1103
1320
|
};
|
|
1104
1321
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
1105
1322
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -1113,8 +1330,8 @@ var QueryManager = (function () {
|
|
|
1113
1330
|
return tslib.__generator(this, function (_j) {
|
|
1114
1331
|
switch (_j.label) {
|
|
1115
1332
|
case 0:
|
|
1116
|
-
globals.invariant(mutation,
|
|
1117
|
-
globals.invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache",
|
|
1333
|
+
globals.invariant(mutation, 28);
|
|
1334
|
+
globals.invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 29);
|
|
1118
1335
|
mutationId = this.generateMutationId();
|
|
1119
1336
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
1120
1337
|
hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
|
|
@@ -1184,7 +1401,10 @@ var QueryManager = (function () {
|
|
|
1184
1401
|
next: function (storeResult) {
|
|
1185
1402
|
self.broadcastQueries();
|
|
1186
1403
|
if (!("hasNext" in storeResult) || storeResult.hasNext === false) {
|
|
1187
|
-
resolve(storeResult)
|
|
1404
|
+
resolve(tslib.__assign(tslib.__assign({}, storeResult), { data: self.maskOperation({
|
|
1405
|
+
document: mutation,
|
|
1406
|
+
data: storeResult.data,
|
|
1407
|
+
}) }));
|
|
1188
1408
|
}
|
|
1189
1409
|
},
|
|
1190
1410
|
error: function (err) {
|
|
@@ -1390,11 +1610,13 @@ var QueryManager = (function () {
|
|
|
1390
1610
|
hasClientExports: utilities.hasClientExports(document),
|
|
1391
1611
|
hasForcedResolvers: this.localState.shouldForceResolvers(document),
|
|
1392
1612
|
hasNonreactiveDirective: utilities.hasDirectives(["nonreactive"], document),
|
|
1613
|
+
nonReactiveQuery: utilities.addNonReactiveToNamedFragments(document),
|
|
1393
1614
|
clientQuery: this.localState.clientQuery(document),
|
|
1394
1615
|
serverQuery: utilities.removeDirectivesFromDocument([
|
|
1395
1616
|
{ name: "client", remove: true },
|
|
1396
1617
|
{ name: "connection" },
|
|
1397
1618
|
{ name: "nonreactive" },
|
|
1619
|
+
{ name: "unmask" },
|
|
1398
1620
|
], document),
|
|
1399
1621
|
defaultVars: utilities.getDefaultValues(utilities.getOperationDefinition(document)),
|
|
1400
1622
|
asQuery: tslib.__assign(tslib.__assign({}, document), { definitions: document.definitions.map(function (def) {
|
|
@@ -1436,11 +1658,16 @@ var QueryManager = (function () {
|
|
|
1436
1658
|
QueryManager.prototype.query = function (options, queryId) {
|
|
1437
1659
|
var _this = this;
|
|
1438
1660
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
1439
|
-
globals.invariant(options.query,
|
|
1440
|
-
globals.invariant(options.query.kind === "Document",
|
|
1441
|
-
globals.invariant(!options.returnPartialData,
|
|
1442
|
-
globals.invariant(!options.pollInterval,
|
|
1443
|
-
|
|
1661
|
+
globals.invariant(options.query, 30);
|
|
1662
|
+
globals.invariant(options.query.kind === "Document", 31);
|
|
1663
|
+
globals.invariant(!options.returnPartialData, 32);
|
|
1664
|
+
globals.invariant(!options.pollInterval, 33);
|
|
1665
|
+
var query = this.transform(options.query);
|
|
1666
|
+
return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: query }))
|
|
1667
|
+
.then(function (result) {
|
|
1668
|
+
return result && tslib.__assign(tslib.__assign({}, result), { data: _this.maskOperation({ document: query, data: result.data }) });
|
|
1669
|
+
})
|
|
1670
|
+
.finally(function () { return _this.stopQuery(queryId); });
|
|
1444
1671
|
};
|
|
1445
1672
|
QueryManager.prototype.generateQueryId = function () {
|
|
1446
1673
|
return String(this.queryIdCounter++);
|
|
@@ -1464,7 +1691,7 @@ var QueryManager = (function () {
|
|
|
1464
1691
|
if (options === void 0) { options = {
|
|
1465
1692
|
discardWatches: true,
|
|
1466
1693
|
}; }
|
|
1467
|
-
this.cancelPendingFetches(globals.newInvariantError(
|
|
1694
|
+
this.cancelPendingFetches(globals.newInvariantError(34));
|
|
1468
1695
|
this.queries.forEach(function (queryInfo) {
|
|
1469
1696
|
if (queryInfo.observableQuery) {
|
|
1470
1697
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -1540,7 +1767,7 @@ var QueryManager = (function () {
|
|
|
1540
1767
|
if (globalThis.__DEV__ !== false && queryNamesAndDocs.size) {
|
|
1541
1768
|
queryNamesAndDocs.forEach(function (included, nameOrDoc) {
|
|
1542
1769
|
if (!included) {
|
|
1543
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(typeof nameOrDoc === "string" ?
|
|
1770
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(typeof nameOrDoc === "string" ? 35 : 36, nameOrDoc);
|
|
1544
1771
|
}
|
|
1545
1772
|
});
|
|
1546
1773
|
}
|
|
@@ -1565,9 +1792,10 @@ var QueryManager = (function () {
|
|
|
1565
1792
|
QueryManager.prototype.setObservableQuery = function (observableQuery) {
|
|
1566
1793
|
this.getQuery(observableQuery.queryId).setObservableQuery(observableQuery);
|
|
1567
1794
|
};
|
|
1568
|
-
QueryManager.prototype.startGraphQLSubscription = function (
|
|
1795
|
+
QueryManager.prototype.startGraphQLSubscription = function (options) {
|
|
1569
1796
|
var _this = this;
|
|
1570
|
-
var query =
|
|
1797
|
+
var query = options.query, variables = options.variables;
|
|
1798
|
+
var fetchPolicy = options.fetchPolicy, _a = options.errorPolicy, errorPolicy = _a === void 0 ? "none" : _a, _b = options.context, context = _b === void 0 ? {} : _b, _c = options.extensions, extensions = _c === void 0 ? {} : _c;
|
|
1571
1799
|
query = this.transform(query);
|
|
1572
1800
|
variables = this.getVariables(query, variables);
|
|
1573
1801
|
var makeObservable = function (variables) {
|
|
@@ -1849,6 +2077,18 @@ var QueryManager = (function () {
|
|
|
1849
2077
|
}
|
|
1850
2078
|
return results;
|
|
1851
2079
|
};
|
|
2080
|
+
QueryManager.prototype.maskOperation = function (options) {
|
|
2081
|
+
var document = options.document, data = options.data;
|
|
2082
|
+
return (this.dataMasking ?
|
|
2083
|
+
maskOperation(data, document, this.cache)
|
|
2084
|
+
: data);
|
|
2085
|
+
};
|
|
2086
|
+
QueryManager.prototype.maskFragment = function (options) {
|
|
2087
|
+
var data = options.data, fragment = options.fragment, fragmentName = options.fragmentName;
|
|
2088
|
+
return this.dataMasking ?
|
|
2089
|
+
maskFragment(data, fragment, this.cache, fragmentName)
|
|
2090
|
+
: data;
|
|
2091
|
+
};
|
|
1852
2092
|
QueryManager.prototype.fetchQueryByPolicy = function (queryInfo, _a,
|
|
1853
2093
|
networkStatus) {
|
|
1854
2094
|
var _this = this;
|
|
@@ -2149,7 +2389,7 @@ var LocalState = (function () {
|
|
|
2149
2389
|
}
|
|
2150
2390
|
else {
|
|
2151
2391
|
fragment = fragmentMap[selection.name.value];
|
|
2152
|
-
globals.invariant(fragment,
|
|
2392
|
+
globals.invariant(fragment, 19, selection.name.value);
|
|
2153
2393
|
}
|
|
2154
2394
|
if (fragment && fragment.typeCondition) {
|
|
2155
2395
|
typeCondition = fragment.typeCondition.name.value;
|
|
@@ -2263,7 +2503,7 @@ var LocalState = (function () {
|
|
|
2263
2503
|
},
|
|
2264
2504
|
FragmentSpread: function (spread, _, __, ___, ancestors) {
|
|
2265
2505
|
var fragment = fragmentMap[spread.name.value];
|
|
2266
|
-
globals.invariant(fragment,
|
|
2506
|
+
globals.invariant(fragment, 20, spread.name.value);
|
|
2267
2507
|
var fragmentSelections = collectByDefinition(fragment);
|
|
2268
2508
|
if (fragmentSelections.size > 0) {
|
|
2269
2509
|
ancestors.forEach(function (node) {
|
|
@@ -2365,10 +2605,10 @@ var ApolloClient = (function () {
|
|
|
2365
2605
|
this.resetStoreCallbacks = [];
|
|
2366
2606
|
this.clearStoreCallbacks = [];
|
|
2367
2607
|
if (!options.cache) {
|
|
2368
|
-
throw globals.newInvariantError(
|
|
2608
|
+
throw globals.newInvariantError(16);
|
|
2369
2609
|
}
|
|
2370
2610
|
var uri = options.uri, credentials = options.credentials, headers = options.headers, cache = options.cache, documentTransform = options.documentTransform, _a = options.ssrMode, ssrMode = _a === void 0 ? false : _a, _b = options.ssrForceFetchDelay, ssrForceFetchDelay = _b === void 0 ? 0 : _b,
|
|
2371
|
-
connectToDevTools = options.connectToDevTools, _c = options.queryDeduplication, queryDeduplication = _c === void 0 ? true : _c, defaultOptions = options.defaultOptions, defaultContext = options.defaultContext, _d = options.assumeImmutableResults, assumeImmutableResults = _d === void 0 ? cache.assumeImmutableResults : _d, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwarenessName = options.name, clientAwarenessVersion = options.version, devtools = options.devtools;
|
|
2611
|
+
connectToDevTools = options.connectToDevTools, _c = options.queryDeduplication, queryDeduplication = _c === void 0 ? true : _c, defaultOptions = options.defaultOptions, defaultContext = options.defaultContext, _d = options.assumeImmutableResults, assumeImmutableResults = _d === void 0 ? cache.assumeImmutableResults : _d, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwarenessName = options.name, clientAwarenessVersion = options.version, devtools = options.devtools, dataMasking = options.dataMasking;
|
|
2372
2612
|
var link = options.link;
|
|
2373
2613
|
if (!link) {
|
|
2374
2614
|
link =
|
|
@@ -2408,6 +2648,7 @@ var ApolloClient = (function () {
|
|
|
2408
2648
|
documentTransform: documentTransform,
|
|
2409
2649
|
queryDeduplication: queryDeduplication,
|
|
2410
2650
|
ssrMode: ssrMode,
|
|
2651
|
+
dataMasking: !!dataMasking,
|
|
2411
2652
|
clientAwareness: {
|
|
2412
2653
|
name: clientAwarenessName,
|
|
2413
2654
|
version: clientAwarenessVersion,
|
|
@@ -2496,7 +2737,7 @@ var ApolloClient = (function () {
|
|
|
2496
2737
|
if (this.defaultOptions.query) {
|
|
2497
2738
|
options = utilities.mergeOptions(this.defaultOptions.query, options);
|
|
2498
2739
|
}
|
|
2499
|
-
globals.invariant(options.fetchPolicy !== "cache-and-network",
|
|
2740
|
+
globals.invariant(options.fetchPolicy !== "cache-and-network", 17);
|
|
2500
2741
|
if (this.disableNetworkFetches && options.fetchPolicy === "network-only") {
|
|
2501
2742
|
options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: "cache-first" });
|
|
2502
2743
|
}
|
|
@@ -2509,14 +2750,21 @@ var ApolloClient = (function () {
|
|
|
2509
2750
|
return this.queryManager.mutate(options);
|
|
2510
2751
|
};
|
|
2511
2752
|
ApolloClient.prototype.subscribe = function (options) {
|
|
2512
|
-
|
|
2753
|
+
var _this = this;
|
|
2754
|
+
return this.queryManager
|
|
2755
|
+
.startGraphQLSubscription(options)
|
|
2756
|
+
.map(function (result) { return (tslib.__assign(tslib.__assign({}, result), { data: _this.queryManager.maskOperation({
|
|
2757
|
+
document: options.query,
|
|
2758
|
+
data: result.data,
|
|
2759
|
+
}) })); });
|
|
2513
2760
|
};
|
|
2514
2761
|
ApolloClient.prototype.readQuery = function (options, optimistic) {
|
|
2515
2762
|
if (optimistic === void 0) { optimistic = false; }
|
|
2516
2763
|
return this.cache.readQuery(options, optimistic);
|
|
2517
2764
|
};
|
|
2518
2765
|
ApolloClient.prototype.watchFragment = function (options) {
|
|
2519
|
-
|
|
2766
|
+
var _a;
|
|
2767
|
+
return this.cache.watchFragment(tslib.__assign(tslib.__assign({}, options), (_a = {}, _a[Symbol.for("apollo.dataMasking")] = this.queryManager.dataMasking, _a)));
|
|
2520
2768
|
};
|
|
2521
2769
|
ApolloClient.prototype.readFragment = function (options, optimistic) {
|
|
2522
2770
|
if (optimistic === void 0) { optimistic = false; }
|
|
@@ -2592,7 +2840,7 @@ var ApolloClient = (function () {
|
|
|
2592
2840
|
result.queries = queries;
|
|
2593
2841
|
result.results = results;
|
|
2594
2842
|
result.catch(function (error) {
|
|
2595
|
-
globalThis.__DEV__ !== false && globals.invariant.debug(
|
|
2843
|
+
globalThis.__DEV__ !== false && globals.invariant.debug(18, error);
|
|
2596
2844
|
});
|
|
2597
2845
|
return result;
|
|
2598
2846
|
};
|
package/core/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from "../link/core/index.js";
|
|
|
14
14
|
export * from "../link/http/index.js";
|
|
15
15
|
export type { ServerError } from "../link/utils/index.js";
|
|
16
16
|
export { fromError, toPromise, fromPromise, throwServerError, } from "../link/utils/index.js";
|
|
17
|
+
export type { DataMasking, FragmentType, Masked, MaskedDocumentNode, MaybeMasked, Unmasked, } from "../masking/index.js";
|
|
17
18
|
export type { DocumentTransformCacheKey, Observer, ObservableSubscription, Reference, StoreObject, } from "../utilities/index.js";
|
|
18
19
|
export { DocumentTransform, Observable, isReference, makeReference, } from "../utilities/index.js";
|
|
19
20
|
import { setVerbosity } from "ts-invariant";
|
package/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,UAAU;AAGV,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAK/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAcvD,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAoBhE,OAAO,EACL,KAAK,EACL,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,uBAAuB,EACvB,OAAO,GACR,MAAM,mBAAmB,CAAC;AAE3B,cAAc,4BAA4B,CAAC;AAE3C,UAAU;AAEV,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AAEtC,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,UAAU;AAGV,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAK/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAcvD,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAoBhE,OAAO,EACL,KAAK,EACL,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,uBAAuB,EACvB,OAAO,GACR,MAAM,mBAAmB,CAAC;AAE3B,cAAc,4BAA4B,CAAC;AAE3C,UAAU;AAEV,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AAEtC,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAqBhC,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,aAAa,GACd,MAAM,uBAAuB,CAAC;AAE/B,gBAAgB;AAEhB,yEAAyE;AACzE,qEAAqE;AACrE,uEAAuE;AACvE,6DAA6D;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,CAAC;AAC3C,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAEzC,0DAA0D;AAC1D,qEAAqE;AACrE,sEAAsE;AACtE,yEAAyE;AACzE,yCAAyC;AACzC,wEAAwE;AACxE,6EAA6E;AAC7E,8EAA8E;AAC9E,sEAAsE;AACtE,qEAAqE;AACrE,4EAA4E;AAC5E,6BAA6B;AAC7B,OAAO,EACL,GAAG,EACH,WAAW,EACX,uBAAuB,EACvB,mCAAmC,EACnC,oCAAoC,GACrC,MAAM,aAAa,CAAC","sourcesContent":["/* Core */\n\nexport type { ApolloClientOptions, DefaultOptions } from \"./ApolloClient.js\";\nexport { ApolloClient, mergeOptions } from \"./ApolloClient.js\";\nexport type {\n FetchMoreOptions,\n UpdateQueryOptions,\n} from \"./ObservableQuery.js\";\nexport { ObservableQuery } from \"./ObservableQuery.js\";\nexport type {\n QueryOptions,\n WatchQueryOptions,\n MutationOptions,\n SubscriptionOptions,\n FetchPolicy,\n WatchQueryFetchPolicy,\n MutationFetchPolicy,\n RefetchWritePolicy,\n ErrorPolicy,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n} from \"./watchQueryOptions.js\";\nexport { NetworkStatus, isNetworkRequestSettled } from \"./networkStatus.js\";\nexport * from \"./types.js\";\nexport type { Resolver, FragmentMatcher } from \"./LocalState.js\";\nexport { isApolloError, ApolloError } from \"../errors/index.js\";\n/* Cache */\n\nexport type {\n // All the exports (types) from ../cache, minus cacheSlot,\n // which we want to keep semi-private.\n Transaction,\n DataProxy,\n InMemoryCacheConfig,\n ReactiveVar,\n TypePolicies,\n TypePolicy,\n FieldPolicy,\n FieldReadFunction,\n FieldMergeFunction,\n FieldFunctionOptions,\n PossibleTypesMap,\n WatchFragmentOptions,\n WatchFragmentResult,\n} from \"../cache/index.js\";\nexport {\n Cache,\n ApolloCache,\n InMemoryCache,\n MissingFieldError,\n defaultDataIdFromObject,\n makeVar,\n} from \"../cache/index.js\";\n\nexport * from \"../cache/inmemory/types.js\";\n\n/* Link */\n\nexport * from \"../link/core/index.js\";\nexport * from \"../link/http/index.js\";\nexport type { ServerError } from \"../link/utils/index.js\";\nexport {\n fromError,\n toPromise,\n fromPromise,\n throwServerError,\n} from \"../link/utils/index.js\";\n\n/* Masking */\nexport type {\n DataMasking,\n FragmentType,\n Masked,\n MaskedDocumentNode,\n MaybeMasked,\n Unmasked,\n} from \"../masking/index.js\";\n\n/* Utilities */\n\nexport type {\n DocumentTransformCacheKey,\n Observer,\n ObservableSubscription,\n Reference,\n StoreObject,\n} from \"../utilities/index.js\";\nexport {\n DocumentTransform,\n Observable,\n isReference,\n makeReference,\n} from \"../utilities/index.js\";\n\n/* Supporting */\n\n// The verbosity of invariant.{log,warn,error} can be controlled globally\n// (for anyone using the same ts-invariant package) by passing \"log\",\n// \"warn\", \"error\", or \"silent\" to setVerbosity (\"log\" is the default).\n// Note that all invariant.* logging is hidden in production.\nimport { setVerbosity } from \"ts-invariant\";\nexport { setVerbosity as setLogVerbosity };\nsetVerbosity(__DEV__ ? \"log\" : \"silent\");\n\n// Note that importing `gql` by itself, then destructuring\n// additional properties separately before exporting, is intentional.\n// Due to the way the `graphql-tag` library is setup, certain bundlers\n// can't find the properties added to the exported `gql` function without\n// additional guidance (e.g. Rollup - see\n// https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module).\n// Instead of having people that are using bundlers with `@apollo/client` add\n// extra bundler config to help `graphql-tag` exports be found (which would be\n// awkward since they aren't importing `graphql-tag` themselves), this\n// workaround of pulling the extra properties off the `gql` function,\n// then re-exporting them separately, helps keeps bundlers happy without any\n// additional config changes.\nexport {\n gql,\n resetCaches,\n disableFragmentWarnings,\n enableExperimentalFragmentVariables,\n disableExperimentalFragmentVariables,\n} from \"graphql-tag\";\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ApolloCache, DocumentNode, TypedDocumentNode } from "./index.js";
|
|
2
|
+
export declare function maskOperation<TData = unknown>(data: TData, document: DocumentNode | TypedDocumentNode<TData>, cache: ApolloCache<unknown>): TData;
|
|
3
|
+
export declare function maskFragment<TData = unknown>(data: TData, document: TypedDocumentNode<TData> | DocumentNode, cache: ApolloCache<unknown>, fragmentName?: string): TData;
|
|
4
|
+
//# sourceMappingURL=masking.d.ts.map
|