@apollo/client 3.13.8 → 3.14.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/chilled-cameras-scream.md +5 -0
- package/.changeset/great-suns-cover.md +5 -0
- package/.changeset/perfect-donuts-roll.md +5 -0
- package/.changeset/popular-waves-drop.md +5 -0
- package/.changeset/pre.json +16 -0
- package/.changeset/shy-dragons-tease.md +5 -0
- package/.changeset/smooth-countries-cough.md +5 -0
- package/.changeset/spotty-walls-repair.md +5 -0
- package/CHANGELOG.md +20 -0
- package/README.md +80 -31
- package/apollo-client.cjs +354 -132
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +78 -21
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +78 -21
- package/cache/core/cache.js +27 -4
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +4 -4
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +2 -2
- package/cache/inmemory/inMemoryCache.js +15 -4
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/policies.js +18 -13
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +7 -0
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +14 -3
- package/cache/inmemory/types.js.map +1 -1
- package/core/ApolloClient.d.ts +191 -2
- package/core/ApolloClient.js +93 -7
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.js +2 -2
- package/core/ObservableQuery.js +10 -6
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.js +8 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +15 -12
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +93 -30
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +93 -30
- package/core/watchQueryOptions.d.ts +2 -2
- package/dev/dev.cjs +144 -84
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +144 -84
- package/invariantErrorCodes.js +158 -83
- 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/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/maskDefinition.js +2 -2
- package/masking/maskFragment.js +2 -2
- package/masking/maskOperation.js +1 -1
- package/masking/masking.cjs +6 -6
- package/masking/masking.cjs.map +1 -1
- package/masking/masking.cjs.native.js +6 -6
- package/masking/utils.js +1 -1
- package/package.json +1 -1
- package/react/components/Mutation.js +5 -0
- package/react/components/Mutation.js.map +1 -1
- package/react/components/Query.js +5 -0
- package/react/components/Query.js.map +1 -1
- package/react/components/Subscription.js +5 -0
- package/react/components/Subscription.js.map +1 -1
- package/react/components/components.cjs +34 -0
- package/react/components/components.cjs.map +1 -1
- package/react/components/components.cjs.native.js +34 -0
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.js +7 -2
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs +9 -4
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +9 -4
- package/react/hoc/graphql.js +17 -4
- package/react/hoc/graphql.js.map +1 -1
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc.cjs +55 -9
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +55 -9
- package/react/hoc/mutation-hoc.js +8 -1
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.js +8 -1
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.js +8 -1
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/withApollo.js +1 -1
- package/react/hooks/hooks.cjs +264 -31
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +264 -31
- package/react/hooks/internal/index.d.ts +2 -0
- package/react/hooks/internal/index.js +2 -0
- package/react/hooks/internal/index.js.map +1 -1
- package/react/hooks/internal/useWarnRemoved.d.ts +2 -0
- package/react/hooks/internal/useWarnRemoved.js +14 -0
- package/react/hooks/internal/useWarnRemoved.js.map +1 -0
- package/react/hooks/internal/useWarnRemovedOption.d.ts +2 -0
- package/react/hooks/internal/useWarnRemovedOption.js +14 -0
- package/react/hooks/internal/useWarnRemovedOption.js.map +1 -0
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useBackgroundQuery.js +11 -3
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.js +30 -21
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.js +65 -0
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.js +12 -5
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.js +5 -1
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +2 -2
- package/react/hooks/useQuery.js +25 -7
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.js +3 -3
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +12 -6
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/internal/cache/QueryReference.d.ts +16 -0
- 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.d.ts +7 -0
- package/react/parser/index.js +17 -7
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +28 -7
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +28 -7
- package/react/query-preloader/createQueryPreloader.d.ts +2 -1
- package/react/query-preloader/createQueryPreloader.js +14 -5
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/react.cjs +40 -6
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +40 -6
- package/react/types/types.d.ts +303 -9
- package/react/types/types.documentation.d.ts +2 -3
- package/react/types/types.documentation.js.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +2 -2
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +2 -2
- package/testing/core/mocking/mockLink.js +2 -2
- package/testing/react/MockedProvider.d.ts +27 -1
- package/testing/react/MockedProvider.js +16 -10
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +42 -11
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +42 -11
- package/utilities/deprecation/index.d.ts +11 -0
- package/utilities/deprecation/index.js +28 -0
- package/utilities/deprecation/index.js.map +1 -0
- 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.js +7 -7
- 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.js +2 -2
- package/utilities/utilities.cjs +22 -22
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +22 -22
- package/version.js +1 -1
package/apollo-client.cjs
CHANGED
|
@@ -31,7 +31,7 @@ function _interopNamespace(e) {
|
|
|
31
31
|
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
32
32
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
33
33
|
|
|
34
|
-
var version = "3.
|
|
34
|
+
var version = "3.14.0-alpha.0";
|
|
35
35
|
|
|
36
36
|
function maybe(thunk) {
|
|
37
37
|
try {
|
|
@@ -145,7 +145,7 @@ function shouldInclude(_a, variables) {
|
|
|
145
145
|
if (ifArgument.value.kind === "Variable") {
|
|
146
146
|
evaledValue =
|
|
147
147
|
variables && variables[ifArgument.value.name.value];
|
|
148
|
-
invariant(evaledValue !== void 0,
|
|
148
|
+
invariant(evaledValue !== void 0, 93, directive.name.value);
|
|
149
149
|
}
|
|
150
150
|
else {
|
|
151
151
|
evaledValue = ifArgument.value.value;
|
|
@@ -180,12 +180,12 @@ function getInclusionDirectives(directives) {
|
|
|
180
180
|
return;
|
|
181
181
|
var directiveArguments = directive.arguments;
|
|
182
182
|
var directiveName = directive.name.value;
|
|
183
|
-
invariant(directiveArguments && directiveArguments.length === 1,
|
|
183
|
+
invariant(directiveArguments && directiveArguments.length === 1, 94, directiveName);
|
|
184
184
|
var ifArgument = directiveArguments[0];
|
|
185
|
-
invariant(ifArgument.name && ifArgument.name.value === "if",
|
|
185
|
+
invariant(ifArgument.name && ifArgument.name.value === "if", 95, directiveName);
|
|
186
186
|
var ifValue = ifArgument.value;
|
|
187
187
|
invariant(ifValue &&
|
|
188
|
-
(ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"),
|
|
188
|
+
(ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), 96, directiveName);
|
|
189
189
|
result.push({ directive: directive, ifArgument: ifArgument });
|
|
190
190
|
});
|
|
191
191
|
}
|
|
@@ -207,13 +207,13 @@ function getFragmentMaskMode(fragment) {
|
|
|
207
207
|
if (globalThis.__DEV__ !== false) {
|
|
208
208
|
if (modeArg) {
|
|
209
209
|
if (modeArg.value.kind === graphql.Kind.VARIABLE) {
|
|
210
|
-
globalThis.__DEV__ !== false && invariant.warn(
|
|
210
|
+
globalThis.__DEV__ !== false && invariant.warn(97);
|
|
211
211
|
}
|
|
212
212
|
else if (modeArg.value.kind !== graphql.Kind.STRING) {
|
|
213
|
-
globalThis.__DEV__ !== false && invariant.warn(
|
|
213
|
+
globalThis.__DEV__ !== false && invariant.warn(98);
|
|
214
214
|
}
|
|
215
215
|
else if (modeArg.value.value !== "migrate") {
|
|
216
|
-
globalThis.__DEV__ !== false && invariant.warn(
|
|
216
|
+
globalThis.__DEV__ !== false && invariant.warn(99, modeArg.value.value);
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
}
|
|
@@ -246,7 +246,7 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
246
246
|
document.definitions.forEach(function (definition) {
|
|
247
247
|
if (definition.kind === "OperationDefinition") {
|
|
248
248
|
throw newInvariantError(
|
|
249
|
-
|
|
249
|
+
100,
|
|
250
250
|
definition.operation,
|
|
251
251
|
definition.name ? " named '".concat(definition.name.value, "'") : ""
|
|
252
252
|
);
|
|
@@ -256,7 +256,7 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
256
256
|
}
|
|
257
257
|
});
|
|
258
258
|
if (typeof actualFragmentName === "undefined") {
|
|
259
|
-
invariant(fragments.length === 1,
|
|
259
|
+
invariant(fragments.length === 1, 101, fragments.length);
|
|
260
260
|
actualFragmentName = fragments[0].name.value;
|
|
261
261
|
}
|
|
262
262
|
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
|
|
@@ -297,7 +297,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
297
297
|
return fragmentMap(fragmentName);
|
|
298
298
|
}
|
|
299
299
|
var fragment = fragmentMap && fragmentMap[fragmentName];
|
|
300
|
-
invariant(fragment,
|
|
300
|
+
invariant(fragment, 102, fragmentName);
|
|
301
301
|
return fragment || null;
|
|
302
302
|
}
|
|
303
303
|
default:
|
|
@@ -562,7 +562,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
562
562
|
argObj[name.value] = null;
|
|
563
563
|
}
|
|
564
564
|
else {
|
|
565
|
-
throw newInvariantError(
|
|
565
|
+
throw newInvariantError(111, name.value, value.kind);
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
568
|
function storeKeyNameFromField(field, variables) {
|
|
@@ -696,16 +696,16 @@ function isInlineFragment(selection) {
|
|
|
696
696
|
}
|
|
697
697
|
|
|
698
698
|
function checkDocument(doc) {
|
|
699
|
-
invariant(doc && doc.kind === "Document",
|
|
699
|
+
invariant(doc && doc.kind === "Document", 103);
|
|
700
700
|
var operations = doc.definitions
|
|
701
701
|
.filter(function (d) { return d.kind !== "FragmentDefinition"; })
|
|
702
702
|
.map(function (definition) {
|
|
703
703
|
if (definition.kind !== "OperationDefinition") {
|
|
704
|
-
throw newInvariantError(
|
|
704
|
+
throw newInvariantError(104, definition.kind);
|
|
705
705
|
}
|
|
706
706
|
return definition;
|
|
707
707
|
});
|
|
708
|
-
invariant(operations.length <= 1,
|
|
708
|
+
invariant(operations.length <= 1, 105, operations.length);
|
|
709
709
|
return doc;
|
|
710
710
|
}
|
|
711
711
|
function getOperationDefinition(doc) {
|
|
@@ -728,14 +728,14 @@ function getFragmentDefinitions(doc) {
|
|
|
728
728
|
}
|
|
729
729
|
function getQueryDefinition(doc) {
|
|
730
730
|
var queryDef = getOperationDefinition(doc);
|
|
731
|
-
invariant(queryDef && queryDef.operation === "query",
|
|
731
|
+
invariant(queryDef && queryDef.operation === "query", 106);
|
|
732
732
|
return queryDef;
|
|
733
733
|
}
|
|
734
734
|
function getFragmentDefinition(doc) {
|
|
735
|
-
invariant(doc.kind === "Document",
|
|
736
|
-
invariant(doc.definitions.length <= 1,
|
|
735
|
+
invariant(doc.kind === "Document", 107);
|
|
736
|
+
invariant(doc.definitions.length <= 1, 108);
|
|
737
737
|
var fragmentDef = doc.definitions[0];
|
|
738
|
-
invariant(fragmentDef.kind === "FragmentDefinition",
|
|
738
|
+
invariant(fragmentDef.kind === "FragmentDefinition", 109);
|
|
739
739
|
return fragmentDef;
|
|
740
740
|
}
|
|
741
741
|
function getMainDefinition(queryDoc) {
|
|
@@ -758,7 +758,7 @@ function getMainDefinition(queryDoc) {
|
|
|
758
758
|
if (fragmentDefinition) {
|
|
759
759
|
return fragmentDefinition;
|
|
760
760
|
}
|
|
761
|
-
throw newInvariantError(
|
|
761
|
+
throw newInvariantError(110);
|
|
762
762
|
}
|
|
763
763
|
function getDefaultValues(definition) {
|
|
764
764
|
var defaultValues = Object.create(null);
|
|
@@ -809,7 +809,7 @@ var DocumentTransform = (function () {
|
|
|
809
809
|
makeCacheKey: function (document) {
|
|
810
810
|
var cacheKeys = _this.getCacheKey(document);
|
|
811
811
|
if (cacheKeys) {
|
|
812
|
-
invariant(Array.isArray(cacheKeys),
|
|
812
|
+
invariant(Array.isArray(cacheKeys), 92);
|
|
813
813
|
return stableCacheKeys_1.lookupArray(cacheKeys);
|
|
814
814
|
}
|
|
815
815
|
},
|
|
@@ -939,7 +939,7 @@ function removeDirectivesFromDocument(directives, doc) {
|
|
|
939
939
|
return getInUseByFragmentName(ancestor.name.value);
|
|
940
940
|
}
|
|
941
941
|
}
|
|
942
|
-
globalThis.__DEV__ !== false && invariant.error(
|
|
942
|
+
globalThis.__DEV__ !== false && invariant.error(112);
|
|
943
943
|
return null;
|
|
944
944
|
};
|
|
945
945
|
var operationCount = 0;
|
|
@@ -1615,7 +1615,7 @@ function toPromise(observable) {
|
|
|
1615
1615
|
observable.subscribe({
|
|
1616
1616
|
next: function (data) {
|
|
1617
1617
|
if (completed) {
|
|
1618
|
-
globalThis.__DEV__ !== false && invariant.warn(
|
|
1618
|
+
globalThis.__DEV__ !== false && invariant.warn(46);
|
|
1619
1619
|
}
|
|
1620
1620
|
else {
|
|
1621
1621
|
completed = true;
|
|
@@ -1658,7 +1658,7 @@ function validateOperation(operation) {
|
|
|
1658
1658
|
for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
|
|
1659
1659
|
var key = _a[_i];
|
|
1660
1660
|
if (OPERATION_FIELDS.indexOf(key) < 0) {
|
|
1661
|
-
throw newInvariantError(
|
|
1661
|
+
throw newInvariantError(47, key);
|
|
1662
1662
|
}
|
|
1663
1663
|
}
|
|
1664
1664
|
return operation;
|
|
@@ -1767,7 +1767,7 @@ var ApolloLink = (function () {
|
|
|
1767
1767
|
ApolloLink.concat = function (first, second) {
|
|
1768
1768
|
var firstLink = toLink(first);
|
|
1769
1769
|
if (isTerminating(firstLink)) {
|
|
1770
|
-
globalThis.__DEV__ !== false && invariant.warn(
|
|
1770
|
+
globalThis.__DEV__ !== false && invariant.warn(39, firstLink);
|
|
1771
1771
|
return firstLink;
|
|
1772
1772
|
}
|
|
1773
1773
|
var nextLink = toLink(second);
|
|
@@ -1793,7 +1793,7 @@ var ApolloLink = (function () {
|
|
|
1793
1793
|
return ApolloLink.concat(this, next);
|
|
1794
1794
|
};
|
|
1795
1795
|
ApolloLink.prototype.request = function (operation, forward) {
|
|
1796
|
-
throw newInvariantError(
|
|
1796
|
+
throw newInvariantError(40);
|
|
1797
1797
|
};
|
|
1798
1798
|
ApolloLink.prototype.onError = function (error, observer) {
|
|
1799
1799
|
if (observer && observer.error) {
|
|
@@ -2175,7 +2175,7 @@ var serializeFetchParameter = function (p, label) {
|
|
|
2175
2175
|
serialized = JSON.stringify(p);
|
|
2176
2176
|
}
|
|
2177
2177
|
catch (e) {
|
|
2178
|
-
var parseError = newInvariantError(
|
|
2178
|
+
var parseError = newInvariantError(43, label, e.message);
|
|
2179
2179
|
parseError.parseError = e;
|
|
2180
2180
|
throw parseError;
|
|
2181
2181
|
}
|
|
@@ -2261,7 +2261,7 @@ function removeDuplicateHeaders(headers, preserveHeaderCase) {
|
|
|
2261
2261
|
|
|
2262
2262
|
var checkFetcher = function (fetcher) {
|
|
2263
2263
|
if (!fetcher && typeof fetch === "undefined") {
|
|
2264
|
-
throw newInvariantError(
|
|
2264
|
+
throw newInvariantError(41);
|
|
2265
2265
|
}
|
|
2266
2266
|
};
|
|
2267
2267
|
|
|
@@ -2395,7 +2395,7 @@ var createHttpLink = function (linkOptions) {
|
|
|
2395
2395
|
options.headers = options.headers || {};
|
|
2396
2396
|
var acceptHeader = "multipart/mixed;";
|
|
2397
2397
|
if (isSubscription && hasDefer) {
|
|
2398
|
-
globalThis.__DEV__ !== false && invariant.warn(
|
|
2398
|
+
globalThis.__DEV__ !== false && invariant.warn(42);
|
|
2399
2399
|
}
|
|
2400
2400
|
if (isSubscription) {
|
|
2401
2401
|
acceptHeader +=
|
|
@@ -2536,7 +2536,7 @@ var issuedWarning = false;
|
|
|
2536
2536
|
function warnOnImproperCacheImplementation() {
|
|
2537
2537
|
if (!issuedWarning) {
|
|
2538
2538
|
issuedWarning = true;
|
|
2539
|
-
globalThis.__DEV__ !== false && invariant.warn(
|
|
2539
|
+
globalThis.__DEV__ !== false && invariant.warn(53);
|
|
2540
2540
|
}
|
|
2541
2541
|
}
|
|
2542
2542
|
|
|
@@ -2620,7 +2620,7 @@ function maskSelectionSet(data, selectionSet, context, migration, path) {
|
|
|
2620
2620
|
var fragment = context.fragmentMap[fragmentName] ||
|
|
2621
2621
|
(context.fragmentMap[fragmentName] =
|
|
2622
2622
|
context.cache.lookupFragment(fragmentName));
|
|
2623
|
-
invariant(fragment,
|
|
2623
|
+
invariant(fragment, 48, fragmentName);
|
|
2624
2624
|
var mode = getFragmentMaskMode(selection);
|
|
2625
2625
|
if (mode !== "mask") {
|
|
2626
2626
|
value = maskSelectionSet(data, fragment.selectionSet, context, mode === "migrate", path);
|
|
@@ -2643,7 +2643,7 @@ function getAccessorWarningDescriptor(fieldName, value, path, operationName, ope
|
|
|
2643
2643
|
if (disableWarningsSlot.getValue()) {
|
|
2644
2644
|
return value;
|
|
2645
2645
|
}
|
|
2646
|
-
globalThis.__DEV__ !== false && invariant.warn(
|
|
2646
|
+
globalThis.__DEV__ !== false && invariant.warn(49, operationName ?
|
|
2647
2647
|
"".concat(operationType, " '").concat(operationName, "'")
|
|
2648
2648
|
: "anonymous ".concat(operationType), "".concat(path, ".").concat(fieldName).replace(/^\./, ""));
|
|
2649
2649
|
getValue = function () { return value; };
|
|
@@ -2672,11 +2672,11 @@ function maskFragment(data, document, cache, fragmentName) {
|
|
|
2672
2672
|
return node.kind === graphql.Kind.FRAGMENT_DEFINITION;
|
|
2673
2673
|
});
|
|
2674
2674
|
if (typeof fragmentName === "undefined") {
|
|
2675
|
-
invariant(fragments.length === 1,
|
|
2675
|
+
invariant(fragments.length === 1, 50, fragments.length);
|
|
2676
2676
|
fragmentName = fragments[0].name.value;
|
|
2677
2677
|
}
|
|
2678
2678
|
var fragment = fragments.find(function (fragment) { return fragment.name.value === fragmentName; });
|
|
2679
|
-
invariant(!!fragment,
|
|
2679
|
+
invariant(!!fragment, 51, fragmentName);
|
|
2680
2680
|
if (data == null) {
|
|
2681
2681
|
return data;
|
|
2682
2682
|
}
|
|
@@ -2702,7 +2702,7 @@ function maskOperation(data, document, cache) {
|
|
|
2702
2702
|
return data;
|
|
2703
2703
|
}
|
|
2704
2704
|
var definition = getOperationDefinition(document);
|
|
2705
|
-
invariant(definition,
|
|
2705
|
+
invariant(definition, 52);
|
|
2706
2706
|
if (data == null) {
|
|
2707
2707
|
return data;
|
|
2708
2708
|
}
|
|
@@ -2716,6 +2716,31 @@ function maskOperation(data, document, cache) {
|
|
|
2716
2716
|
});
|
|
2717
2717
|
}
|
|
2718
2718
|
|
|
2719
|
+
var slot = new optimism.Slot();
|
|
2720
|
+
function isMuted(name) {
|
|
2721
|
+
return (slot.getValue() || []).includes(name);
|
|
2722
|
+
}
|
|
2723
|
+
function muteDeprecations(name) {
|
|
2724
|
+
var args = [];
|
|
2725
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2726
|
+
args[_i - 1] = arguments[_i];
|
|
2727
|
+
}
|
|
2728
|
+
return slot.withValue.apply(slot, tslib.__spreadArray([Array.isArray(name) ? name : [name]], args, false));
|
|
2729
|
+
}
|
|
2730
|
+
function warnRemovedOption(options, name, callSite, recommendation) {
|
|
2731
|
+
if (recommendation === void 0) { recommendation = "Please remove this option."; }
|
|
2732
|
+
warnDeprecated(name, function () {
|
|
2733
|
+
if (name in options) {
|
|
2734
|
+
globalThis.__DEV__ !== false && invariant.warn(91, callSite, name, recommendation);
|
|
2735
|
+
}
|
|
2736
|
+
});
|
|
2737
|
+
}
|
|
2738
|
+
function warnDeprecated(name, cb) {
|
|
2739
|
+
if (!isMuted(name)) {
|
|
2740
|
+
cb();
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2719
2744
|
var ApolloCache = (function () {
|
|
2720
2745
|
function ApolloCache() {
|
|
2721
2746
|
this.assumeImmutableResults = false;
|
|
@@ -2756,8 +2781,14 @@ var ApolloCache = (function () {
|
|
|
2756
2781
|
return false;
|
|
2757
2782
|
};
|
|
2758
2783
|
ApolloCache.prototype.readQuery = function (options, optimistic) {
|
|
2784
|
+
var _this = this;
|
|
2759
2785
|
if (optimistic === void 0) { optimistic = !!options.optimistic; }
|
|
2760
|
-
|
|
2786
|
+
if (globalThis.__DEV__ !== false) {
|
|
2787
|
+
warnRemovedOption(options, "canonizeResults", "cache.readQuery");
|
|
2788
|
+
}
|
|
2789
|
+
return muteDeprecations("canonizeResults", function () {
|
|
2790
|
+
return _this.read(tslib.__assign(tslib.__assign({}, options), { rootId: options.id || "ROOT_QUERY", optimistic: optimistic }));
|
|
2791
|
+
});
|
|
2761
2792
|
};
|
|
2762
2793
|
ApolloCache.prototype.watchFragment = function (options) {
|
|
2763
2794
|
var _this = this;
|
|
@@ -2799,8 +2830,14 @@ var ApolloCache = (function () {
|
|
|
2799
2830
|
});
|
|
2800
2831
|
};
|
|
2801
2832
|
ApolloCache.prototype.readFragment = function (options, optimistic) {
|
|
2833
|
+
var _this = this;
|
|
2802
2834
|
if (optimistic === void 0) { optimistic = !!options.optimistic; }
|
|
2803
|
-
|
|
2835
|
+
if (globalThis.__DEV__ !== false) {
|
|
2836
|
+
warnRemovedOption(options, "canonizeResults", "cache.readFragment");
|
|
2837
|
+
}
|
|
2838
|
+
return muteDeprecations("canonizeResults", function () {
|
|
2839
|
+
return _this.read(tslib.__assign(tslib.__assign({}, options), { query: _this.getFragmentDoc(options.fragment, options.fragmentName), rootId: options.id, optimistic: optimistic }));
|
|
2840
|
+
});
|
|
2804
2841
|
};
|
|
2805
2842
|
ApolloCache.prototype.writeQuery = function (_a) {
|
|
2806
2843
|
var id = _a.id, data = _a.data, options = tslib.__rest(_a, ["id", "data"]);
|
|
@@ -2818,9 +2855,14 @@ var ApolloCache = (function () {
|
|
|
2818
2855
|
}));
|
|
2819
2856
|
};
|
|
2820
2857
|
ApolloCache.prototype.updateQuery = function (options, update) {
|
|
2858
|
+
if (globalThis.__DEV__ !== false) {
|
|
2859
|
+
warnRemovedOption(options, "canonizeResults", "cache.updateQuery");
|
|
2860
|
+
}
|
|
2821
2861
|
return this.batch({
|
|
2822
2862
|
update: function (cache) {
|
|
2823
|
-
var value =
|
|
2863
|
+
var value = muteDeprecations("canonizeResults", function () {
|
|
2864
|
+
return cache.readQuery(options);
|
|
2865
|
+
});
|
|
2824
2866
|
var data = update(value);
|
|
2825
2867
|
if (data === void 0 || data === null)
|
|
2826
2868
|
return value;
|
|
@@ -2830,9 +2872,14 @@ var ApolloCache = (function () {
|
|
|
2830
2872
|
});
|
|
2831
2873
|
};
|
|
2832
2874
|
ApolloCache.prototype.updateFragment = function (options, update) {
|
|
2875
|
+
if (globalThis.__DEV__ !== false) {
|
|
2876
|
+
warnRemovedOption(options, "canonizeResults", "cache.updateFragment");
|
|
2877
|
+
}
|
|
2833
2878
|
return this.batch({
|
|
2834
2879
|
update: function (cache) {
|
|
2835
|
-
var value =
|
|
2880
|
+
var value = muteDeprecations("canonizeResults", function () {
|
|
2881
|
+
return cache.readFragment(options);
|
|
2882
|
+
});
|
|
2836
2883
|
var data = update(value);
|
|
2837
2884
|
if (data === void 0 || data === null)
|
|
2838
2885
|
return value;
|
|
@@ -4096,8 +4143,7 @@ var Policies = (function () {
|
|
|
4096
4143
|
}
|
|
4097
4144
|
});
|
|
4098
4145
|
};
|
|
4099
|
-
Policies.prototype.updateTypePolicy = function (typename, incoming) {
|
|
4100
|
-
var _this = this;
|
|
4146
|
+
Policies.prototype.updateTypePolicy = function (typename, incoming, existingFieldPolicies) {
|
|
4101
4147
|
var existing = this.getTypePolicy(typename);
|
|
4102
4148
|
var keyFields = incoming.keyFields, fields = incoming.fields;
|
|
4103
4149
|
function setMerge(existing, merge) {
|
|
@@ -4115,7 +4161,10 @@ var Policies = (function () {
|
|
|
4115
4161
|
: existing.keyFn;
|
|
4116
4162
|
if (fields) {
|
|
4117
4163
|
Object.keys(fields).forEach(function (fieldName) {
|
|
4118
|
-
var existing =
|
|
4164
|
+
var existing = existingFieldPolicies[fieldName];
|
|
4165
|
+
if (!existing || (existing === null || existing === void 0 ? void 0 : existing.typename) !== typename) {
|
|
4166
|
+
existing = existingFieldPolicies[fieldName] = { typename: typename };
|
|
4167
|
+
}
|
|
4119
4168
|
var incoming = fields[fieldName];
|
|
4120
4169
|
if (typeof incoming === "function") {
|
|
4121
4170
|
existing.read = incoming;
|
|
@@ -4194,16 +4243,14 @@ var Policies = (function () {
|
|
|
4194
4243
|
var inbox = this.toBeAdded[typename];
|
|
4195
4244
|
if (inbox && inbox.length) {
|
|
4196
4245
|
inbox.splice(0).forEach(function (policy) {
|
|
4197
|
-
_this.updateTypePolicy(typename, policy);
|
|
4246
|
+
_this.updateTypePolicy(typename, policy, _this.typePolicies[typename].fields);
|
|
4198
4247
|
});
|
|
4199
4248
|
}
|
|
4200
4249
|
return this.typePolicies[typename];
|
|
4201
4250
|
};
|
|
4202
|
-
Policies.prototype.getFieldPolicy = function (typename, fieldName
|
|
4251
|
+
Policies.prototype.getFieldPolicy = function (typename, fieldName) {
|
|
4203
4252
|
if (typename) {
|
|
4204
|
-
|
|
4205
|
-
return (fieldPolicies[fieldName] ||
|
|
4206
|
-
(createIfMissing && (fieldPolicies[fieldName] = Object.create(null))));
|
|
4253
|
+
return this.getTypePolicy(typename).fields[fieldName];
|
|
4207
4254
|
}
|
|
4208
4255
|
};
|
|
4209
4256
|
Policies.prototype.getSupertypeSet = function (subtype, createIfMissing) {
|
|
@@ -4264,12 +4311,12 @@ var Policies = (function () {
|
|
|
4264
4311
|
return false;
|
|
4265
4312
|
};
|
|
4266
4313
|
Policies.prototype.hasKeyArgs = function (typename, fieldName) {
|
|
4267
|
-
var policy = this.getFieldPolicy(typename, fieldName
|
|
4314
|
+
var policy = this.getFieldPolicy(typename, fieldName);
|
|
4268
4315
|
return !!(policy && policy.keyFn);
|
|
4269
4316
|
};
|
|
4270
4317
|
Policies.prototype.getStoreFieldName = function (fieldSpec) {
|
|
4271
4318
|
var typename = fieldSpec.typename, fieldName = fieldSpec.fieldName;
|
|
4272
|
-
var policy = this.getFieldPolicy(typename, fieldName
|
|
4319
|
+
var policy = this.getFieldPolicy(typename, fieldName);
|
|
4273
4320
|
var storeFieldName;
|
|
4274
4321
|
var keyFn = policy && policy.keyFn;
|
|
4275
4322
|
if (keyFn && typename) {
|
|
@@ -4318,7 +4365,7 @@ var Policies = (function () {
|
|
|
4318
4365
|
var storeFieldName = this.getStoreFieldName(options);
|
|
4319
4366
|
var fieldName = fieldNameFromStoreName(storeFieldName);
|
|
4320
4367
|
var existing = context.store.getFieldValue(objectOrReference, storeFieldName);
|
|
4321
|
-
var policy = this.getFieldPolicy(options.typename, fieldName
|
|
4368
|
+
var policy = this.getFieldPolicy(options.typename, fieldName);
|
|
4322
4369
|
var read = policy && policy.read;
|
|
4323
4370
|
if (read) {
|
|
4324
4371
|
var readOptions = makeFieldFunctionOptions(this, objectOrReference, options, context, context.store.getStorage(isReference(objectOrReference) ?
|
|
@@ -4332,11 +4379,11 @@ var Policies = (function () {
|
|
|
4332
4379
|
return existing;
|
|
4333
4380
|
};
|
|
4334
4381
|
Policies.prototype.getReadFunction = function (typename, fieldName) {
|
|
4335
|
-
var policy = this.getFieldPolicy(typename, fieldName
|
|
4382
|
+
var policy = this.getFieldPolicy(typename, fieldName);
|
|
4336
4383
|
return policy && policy.read;
|
|
4337
4384
|
};
|
|
4338
4385
|
Policies.prototype.getMergeFunction = function (parentTypename, fieldName, childTypename) {
|
|
4339
|
-
var policy = this.getFieldPolicy(parentTypename, fieldName
|
|
4386
|
+
var policy = this.getFieldPolicy(parentTypename, fieldName);
|
|
4340
4387
|
var merge = policy && policy.merge;
|
|
4341
4388
|
if (!merge && childTypename) {
|
|
4342
4389
|
policy = this.getTypePolicy(childTypename);
|
|
@@ -4845,6 +4892,10 @@ var InMemoryCache = (function (_super) {
|
|
|
4845
4892
|
_this.assumeImmutableResults = true;
|
|
4846
4893
|
_this.makeVar = makeVar;
|
|
4847
4894
|
_this.txCount = 0;
|
|
4895
|
+
if (globalThis.__DEV__ !== false) {
|
|
4896
|
+
warnRemovedOption(config, "addTypename", "InMemoryCache", "Please remove the `addTypename` option when initializing `InMemoryCache`.");
|
|
4897
|
+
warnRemovedOption(config, "canonizeResults", "InMemoryCache", "Please remove the `canonizeResults` option when initializing `InMemoryCache`.");
|
|
4898
|
+
}
|
|
4848
4899
|
_this.config = normalizeConfig(config);
|
|
4849
4900
|
_this.addTypename = !!_this.config.addTypename;
|
|
4850
4901
|
_this.policies = new Policies({
|
|
@@ -4868,6 +4919,8 @@ var InMemoryCache = (function (_super) {
|
|
|
4868
4919
|
var _this = this;
|
|
4869
4920
|
var previousReader = this.storeReader;
|
|
4870
4921
|
var fragments = this.config.fragments;
|
|
4922
|
+
this.addTypenameTransform.resetCache();
|
|
4923
|
+
fragments === null || fragments === void 0 ? void 0 : fragments.resetCaches();
|
|
4871
4924
|
this.storeWriter = new StoreWriter(this, (this.storeReader = new StoreReader({
|
|
4872
4925
|
cache: this,
|
|
4873
4926
|
addTypename: this.addTypename,
|
|
@@ -4906,6 +4959,9 @@ var InMemoryCache = (function (_super) {
|
|
|
4906
4959
|
return (optimistic ? this.optimisticData : this.data).extract();
|
|
4907
4960
|
};
|
|
4908
4961
|
InMemoryCache.prototype.read = function (options) {
|
|
4962
|
+
if (globalThis.__DEV__ !== false) {
|
|
4963
|
+
warnRemovedOption(options, "canonizeResults", "cache.read");
|
|
4964
|
+
}
|
|
4909
4965
|
var
|
|
4910
4966
|
_a = options.returnPartialData,
|
|
4911
4967
|
returnPartialData = _a === void 0 ? false : _a;
|
|
@@ -4949,6 +5005,9 @@ var InMemoryCache = (function (_super) {
|
|
|
4949
5005
|
}
|
|
4950
5006
|
};
|
|
4951
5007
|
InMemoryCache.prototype.diff = function (options) {
|
|
5008
|
+
if (globalThis.__DEV__ !== false) {
|
|
5009
|
+
warnRemovedOption(options, "canonizeResults", "cache.diff");
|
|
5010
|
+
}
|
|
4952
5011
|
return this.storeReader.diffQueryAgainstStore(tslib.__assign(tslib.__assign({}, options), { store: options.optimistic ? this.optimisticData : this.data, rootId: options.id || "ROOT_QUERY", config: this.config }));
|
|
4953
5012
|
};
|
|
4954
5013
|
InMemoryCache.prototype.watch = function (watch) {
|
|
@@ -4968,11 +5027,8 @@ var InMemoryCache = (function (_super) {
|
|
|
4968
5027
|
};
|
|
4969
5028
|
};
|
|
4970
5029
|
InMemoryCache.prototype.gc = function (options) {
|
|
4971
|
-
var _a;
|
|
4972
5030
|
canonicalStringify.reset();
|
|
4973
5031
|
print.reset();
|
|
4974
|
-
this.addTypenameTransform.resetCache();
|
|
4975
|
-
(_a = this.config.fragments) === null || _a === void 0 ? void 0 : _a.resetCaches();
|
|
4976
5032
|
var ids = this.optimisticData.gc();
|
|
4977
5033
|
if (options && !this.txCount) {
|
|
4978
5034
|
if (options.resetResultCache) {
|
|
@@ -5126,8 +5182,9 @@ var InMemoryCache = (function (_super) {
|
|
|
5126
5182
|
return document;
|
|
5127
5183
|
};
|
|
5128
5184
|
InMemoryCache.prototype.broadcastWatch = function (c, options) {
|
|
5185
|
+
var _this = this;
|
|
5129
5186
|
var lastDiff = c.lastDiff;
|
|
5130
|
-
var diff =
|
|
5187
|
+
var diff = muteDeprecations("canonizeResults", function () { return _this.diff(c); });
|
|
5131
5188
|
if (options) {
|
|
5132
5189
|
if (c.optimistic && typeof options.optimistic === "string") {
|
|
5133
5190
|
diff.fromOptimisticTransaction = true;
|
|
@@ -5364,7 +5421,7 @@ var ObservableQuery = (function (_super) {
|
|
|
5364
5421
|
var vars = queryDef.variableDefinitions;
|
|
5365
5422
|
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
5366
5423
|
globalThis.__DEV__ !== false && invariant.warn(
|
|
5367
|
-
|
|
5424
|
+
22,
|
|
5368
5425
|
variables,
|
|
5369
5426
|
((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
|
|
5370
5427
|
);
|
|
@@ -5396,7 +5453,7 @@ var ObservableQuery = (function (_super) {
|
|
|
5396
5453
|
var updateQuery = fetchMoreOptions === null || fetchMoreOptions === void 0 ? void 0 : fetchMoreOptions.updateQuery;
|
|
5397
5454
|
var isCached = this.options.fetchPolicy !== "no-cache";
|
|
5398
5455
|
if (!isCached) {
|
|
5399
|
-
invariant(updateQuery,
|
|
5456
|
+
invariant(updateQuery, 23);
|
|
5400
5457
|
}
|
|
5401
5458
|
return this.queryManager
|
|
5402
5459
|
.fetchQuery(qid, combinedOptions, exports.NetworkStatus.fetchMore)
|
|
@@ -5473,7 +5530,7 @@ var ObservableQuery = (function (_super) {
|
|
|
5473
5530
|
options.onError(err);
|
|
5474
5531
|
return;
|
|
5475
5532
|
}
|
|
5476
|
-
globalThis.__DEV__ !== false && invariant.error(
|
|
5533
|
+
globalThis.__DEV__ !== false && invariant.error(24, err);
|
|
5477
5534
|
},
|
|
5478
5535
|
});
|
|
5479
5536
|
this.subscriptions.add(subscription);
|
|
@@ -5484,6 +5541,9 @@ var ObservableQuery = (function (_super) {
|
|
|
5484
5541
|
};
|
|
5485
5542
|
};
|
|
5486
5543
|
ObservableQuery.prototype.setOptions = function (newOptions) {
|
|
5544
|
+
if (globalThis.__DEV__ !== false) {
|
|
5545
|
+
warnRemovedOption(newOptions, "canonizeResults", "setOptions");
|
|
5546
|
+
}
|
|
5487
5547
|
return this.reobserve(newOptions);
|
|
5488
5548
|
};
|
|
5489
5549
|
ObservableQuery.prototype.silentSetOptions = function (newOptions) {
|
|
@@ -5576,7 +5636,7 @@ var ObservableQuery = (function (_super) {
|
|
|
5576
5636
|
if (pollingInfo && pollingInfo.interval === pollInterval) {
|
|
5577
5637
|
return;
|
|
5578
5638
|
}
|
|
5579
|
-
invariant(pollInterval,
|
|
5639
|
+
invariant(pollInterval, 25);
|
|
5580
5640
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
5581
5641
|
info.interval = pollInterval;
|
|
5582
5642
|
var maybeFetch = function () {
|
|
@@ -5797,11 +5857,11 @@ var ObservableQuery = (function (_super) {
|
|
|
5797
5857
|
}(zenObservableTs.Observable));
|
|
5798
5858
|
fixObservableSubclass(ObservableQuery);
|
|
5799
5859
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
5800
|
-
globalThis.__DEV__ !== false && invariant.error(
|
|
5860
|
+
globalThis.__DEV__ !== false && invariant.error(26, error.message, error.stack);
|
|
5801
5861
|
}
|
|
5802
5862
|
function logMissingFieldErrors(missing) {
|
|
5803
5863
|
if (globalThis.__DEV__ !== false && missing) {
|
|
5804
|
-
globalThis.__DEV__ !== false && invariant.debug(
|
|
5864
|
+
globalThis.__DEV__ !== false && invariant.debug(27, missing);
|
|
5805
5865
|
}
|
|
5806
5866
|
}
|
|
5807
5867
|
function skipCacheDataFor(fetchPolicy ) {
|
|
@@ -5867,6 +5927,7 @@ var QueryInfo = (function () {
|
|
|
5867
5927
|
this.lastDiff = void 0;
|
|
5868
5928
|
};
|
|
5869
5929
|
QueryInfo.prototype.getDiff = function () {
|
|
5930
|
+
var _this = this;
|
|
5870
5931
|
var options = this.getDiffOptions();
|
|
5871
5932
|
if (this.lastDiff && equal.equal(options, this.lastDiff.options)) {
|
|
5872
5933
|
return this.lastDiff.diff;
|
|
@@ -5876,7 +5937,9 @@ var QueryInfo = (function () {
|
|
|
5876
5937
|
if (oq && oq.options.fetchPolicy === "no-cache") {
|
|
5877
5938
|
return { complete: false };
|
|
5878
5939
|
}
|
|
5879
|
-
var diff =
|
|
5940
|
+
var diff = muteDeprecations("canonizeResults", function () {
|
|
5941
|
+
return _this.cache.diff(options);
|
|
5942
|
+
});
|
|
5880
5943
|
this.updateLastDiff(diff, options);
|
|
5881
5944
|
return diff;
|
|
5882
5945
|
};
|
|
@@ -5999,7 +6062,9 @@ var QueryInfo = (function () {
|
|
|
5999
6062
|
}
|
|
6000
6063
|
}
|
|
6001
6064
|
var diffOptions = _this.getDiffOptions(options.variables);
|
|
6002
|
-
var diff =
|
|
6065
|
+
var diff = muteDeprecations("canonizeResults", function () {
|
|
6066
|
+
return cache.diff(diffOptions);
|
|
6067
|
+
});
|
|
6003
6068
|
if (!_this.stopped && equal.equal(_this.variables, options.variables)) {
|
|
6004
6069
|
_this.updateWatch(options.variables);
|
|
6005
6070
|
}
|
|
@@ -6086,7 +6151,7 @@ var QueryManager = (function () {
|
|
|
6086
6151
|
this.queries.forEach(function (_info, queryId) {
|
|
6087
6152
|
_this.stopQueryNoBroadcast(queryId);
|
|
6088
6153
|
});
|
|
6089
|
-
this.cancelPendingFetches(newInvariantError(
|
|
6154
|
+
this.cancelPendingFetches(newInvariantError(28));
|
|
6090
6155
|
};
|
|
6091
6156
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
6092
6157
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -6100,8 +6165,8 @@ var QueryManager = (function () {
|
|
|
6100
6165
|
return tslib.__generator(this, function (_j) {
|
|
6101
6166
|
switch (_j.label) {
|
|
6102
6167
|
case 0:
|
|
6103
|
-
invariant(mutation,
|
|
6104
|
-
invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache",
|
|
6168
|
+
invariant(mutation, 29);
|
|
6169
|
+
invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 30);
|
|
6105
6170
|
mutationId = this.generateMutationId();
|
|
6106
6171
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
6107
6172
|
hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
|
|
@@ -6431,10 +6496,10 @@ var QueryManager = (function () {
|
|
|
6431
6496
|
QueryManager.prototype.query = function (options, queryId) {
|
|
6432
6497
|
var _this = this;
|
|
6433
6498
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
6434
|
-
invariant(options.query,
|
|
6435
|
-
invariant(options.query.kind === "Document",
|
|
6436
|
-
invariant(!options.returnPartialData,
|
|
6437
|
-
invariant(!options.pollInterval,
|
|
6499
|
+
invariant(options.query, 31);
|
|
6500
|
+
invariant(options.query.kind === "Document", 32);
|
|
6501
|
+
invariant(!options.returnPartialData, 33);
|
|
6502
|
+
invariant(!options.pollInterval, 34);
|
|
6438
6503
|
var query = this.transform(options.query);
|
|
6439
6504
|
return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: query }))
|
|
6440
6505
|
.then(function (result) {
|
|
@@ -6469,7 +6534,7 @@ var QueryManager = (function () {
|
|
|
6469
6534
|
if (options === void 0) { options = {
|
|
6470
6535
|
discardWatches: true,
|
|
6471
6536
|
}; }
|
|
6472
|
-
this.cancelPendingFetches(newInvariantError(
|
|
6537
|
+
this.cancelPendingFetches(newInvariantError(35));
|
|
6473
6538
|
this.queries.forEach(function (queryInfo) {
|
|
6474
6539
|
if (queryInfo.observableQuery) {
|
|
6475
6540
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -6551,10 +6616,10 @@ var QueryManager = (function () {
|
|
|
6551
6616
|
if (!included) {
|
|
6552
6617
|
var queryName = queryNames.get(nameOrQueryString);
|
|
6553
6618
|
if (queryName) {
|
|
6554
|
-
globalThis.__DEV__ !== false && invariant.warn(
|
|
6619
|
+
globalThis.__DEV__ !== false && invariant.warn(36, queryName);
|
|
6555
6620
|
}
|
|
6556
6621
|
else {
|
|
6557
|
-
globalThis.__DEV__ !== false && invariant.warn(
|
|
6622
|
+
globalThis.__DEV__ !== false && invariant.warn(37);
|
|
6558
6623
|
}
|
|
6559
6624
|
}
|
|
6560
6625
|
});
|
|
@@ -6845,7 +6910,9 @@ var QueryManager = (function () {
|
|
|
6845
6910
|
var result;
|
|
6846
6911
|
if (onQueryUpdated) {
|
|
6847
6912
|
if (!diff) {
|
|
6848
|
-
diff =
|
|
6913
|
+
diff = muteDeprecations("canonizeResults", function () {
|
|
6914
|
+
return _this.cache.diff(oq["queryInfo"]["getDiffOptions"]());
|
|
6915
|
+
});
|
|
6849
6916
|
}
|
|
6850
6917
|
result = onQueryUpdated(oq, diff, lastDiff);
|
|
6851
6918
|
}
|
|
@@ -6878,7 +6945,7 @@ var QueryManager = (function () {
|
|
|
6878
6945
|
!this.noCacheWarningsByQueryId.has(operationId)) {
|
|
6879
6946
|
this.noCacheWarningsByQueryId.add(operationId);
|
|
6880
6947
|
globalThis.__DEV__ !== false && invariant.warn(
|
|
6881
|
-
|
|
6948
|
+
38,
|
|
6882
6949
|
(_c = getOperationName(document)) !== null && _c !== void 0 ? _c : "Unnamed ".concat(operationType !== null && operationType !== void 0 ? operationType : "operation")
|
|
6883
6950
|
);
|
|
6884
6951
|
}
|
|
@@ -7193,7 +7260,7 @@ var LocalState = (function () {
|
|
|
7193
7260
|
}
|
|
7194
7261
|
else {
|
|
7195
7262
|
fragment = fragmentMap[selection.name.value];
|
|
7196
|
-
invariant(fragment,
|
|
7263
|
+
invariant(fragment, 20, selection.name.value);
|
|
7197
7264
|
}
|
|
7198
7265
|
if (fragment && fragment.typeCondition) {
|
|
7199
7266
|
typeCondition = fragment.typeCondition.name.value;
|
|
@@ -7307,7 +7374,7 @@ var LocalState = (function () {
|
|
|
7307
7374
|
},
|
|
7308
7375
|
FragmentSpread: function (spread, _, __, ___, ancestors) {
|
|
7309
7376
|
var fragment = fragmentMap[spread.name.value];
|
|
7310
|
-
invariant(fragment,
|
|
7377
|
+
invariant(fragment, 21, spread.name.value);
|
|
7311
7378
|
var fragmentSelections = collectByDefinition(fragment);
|
|
7312
7379
|
if (fragmentSelections.size > 0) {
|
|
7313
7380
|
ancestors.forEach(function (node) {
|
|
@@ -7334,14 +7401,26 @@ var hasSuggestedDevtools = false;
|
|
|
7334
7401
|
var ApolloClient = (function () {
|
|
7335
7402
|
function ApolloClient(options) {
|
|
7336
7403
|
var _this = this;
|
|
7337
|
-
var _a;
|
|
7404
|
+
var _a, _b, _c;
|
|
7338
7405
|
this.resetStoreCallbacks = [];
|
|
7339
7406
|
this.clearStoreCallbacks = [];
|
|
7340
7407
|
if (!options.cache) {
|
|
7341
7408
|
throw newInvariantError(16);
|
|
7342
7409
|
}
|
|
7343
|
-
var uri = options.uri, credentials = options.credentials, headers = options.headers, cache = options.cache, documentTransform = options.documentTransform,
|
|
7344
|
-
connectToDevTools = options.connectToDevTools,
|
|
7410
|
+
var uri = options.uri, credentials = options.credentials, headers = options.headers, cache = options.cache, documentTransform = options.documentTransform, _d = options.ssrMode, ssrMode = _d === void 0 ? false : _d, _e = options.ssrForceFetchDelay, ssrForceFetchDelay = _e === void 0 ? 0 : _e,
|
|
7411
|
+
connectToDevTools = options.connectToDevTools, _f = options.queryDeduplication, queryDeduplication = _f === void 0 ? true : _f, defaultOptions = options.defaultOptions, defaultContext = options.defaultContext, _g = options.assumeImmutableResults, assumeImmutableResults = _g === void 0 ? cache.assumeImmutableResults : _g, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwareness = options.clientAwareness, clientAwarenessName = options.name, clientAwarenessVersion = options.version, devtools = options.devtools, dataMasking = options.dataMasking;
|
|
7412
|
+
if (globalThis.__DEV__ !== false) {
|
|
7413
|
+
warnRemovedOption(options, "connectToDevTools", "ApolloClient", "Please use `devtools.enabled` instead.");
|
|
7414
|
+
warnRemovedOption(options, "uri", "ApolloClient", "Please initialize an instance of `HttpLink` with `uri` instead.");
|
|
7415
|
+
warnRemovedOption(options, "credentials", "ApolloClient", "Please initialize an instance of `HttpLink` with `credentials` instead.");
|
|
7416
|
+
warnRemovedOption(options, "headers", "ApolloClient", "Please initialize an instance of `HttpLink` with `headers` instead.");
|
|
7417
|
+
warnRemovedOption(options, "name", "ApolloClient", "Please use the `clientAwareness.name` option instead.");
|
|
7418
|
+
warnRemovedOption(options, "version", "ApolloClient", "Please use the `clientAwareness.version` option instead.");
|
|
7419
|
+
warnRemovedOption(options, "typeDefs", "ApolloClient");
|
|
7420
|
+
if (!options.link) {
|
|
7421
|
+
globalThis.__DEV__ !== false && invariant.warn(17);
|
|
7422
|
+
}
|
|
7423
|
+
}
|
|
7345
7424
|
var link = options.link;
|
|
7346
7425
|
if (!link) {
|
|
7347
7426
|
link =
|
|
@@ -7383,8 +7462,8 @@ var ApolloClient = (function () {
|
|
|
7383
7462
|
ssrMode: ssrMode,
|
|
7384
7463
|
dataMasking: !!dataMasking,
|
|
7385
7464
|
clientAwareness: {
|
|
7386
|
-
name: clientAwarenessName,
|
|
7387
|
-
version: clientAwarenessVersion,
|
|
7465
|
+
name: (_b = clientAwareness === null || clientAwareness === void 0 ? void 0 : clientAwareness.name) !== null && _b !== void 0 ? _b : clientAwarenessName,
|
|
7466
|
+
version: (_c = clientAwareness === null || clientAwareness === void 0 ? void 0 : clientAwareness.version) !== null && _c !== void 0 ? _c : clientAwarenessVersion,
|
|
7388
7467
|
},
|
|
7389
7468
|
localState: this.localState,
|
|
7390
7469
|
assumeImmutableResults: assumeImmutableResults,
|
|
@@ -7406,6 +7485,16 @@ var ApolloClient = (function () {
|
|
|
7406
7485
|
if (this.devtoolsConfig.enabled)
|
|
7407
7486
|
this.connectToDevTools();
|
|
7408
7487
|
}
|
|
7488
|
+
Object.defineProperty(ApolloClient.prototype, "prioritizeCacheValues", {
|
|
7489
|
+
get: function () {
|
|
7490
|
+
return this.disableNetworkFetches;
|
|
7491
|
+
},
|
|
7492
|
+
set: function (value) {
|
|
7493
|
+
this.disableNetworkFetches = value;
|
|
7494
|
+
},
|
|
7495
|
+
enumerable: false,
|
|
7496
|
+
configurable: true
|
|
7497
|
+
});
|
|
7409
7498
|
ApolloClient.prototype.connectToDevTools = function () {
|
|
7410
7499
|
if (typeof window === "undefined") {
|
|
7411
7500
|
return;
|
|
@@ -7464,16 +7553,22 @@ var ApolloClient = (function () {
|
|
|
7464
7553
|
options.fetchPolicy === "cache-and-network")) {
|
|
7465
7554
|
options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: "cache-first" });
|
|
7466
7555
|
}
|
|
7556
|
+
if (globalThis.__DEV__ !== false) {
|
|
7557
|
+
warnRemovedOption(options, "canonizeResults", "client.watchQuery");
|
|
7558
|
+
}
|
|
7467
7559
|
return this.queryManager.watchQuery(options);
|
|
7468
7560
|
};
|
|
7469
7561
|
ApolloClient.prototype.query = function (options) {
|
|
7470
7562
|
if (this.defaultOptions.query) {
|
|
7471
7563
|
options = mergeOptions(this.defaultOptions.query, options);
|
|
7472
7564
|
}
|
|
7473
|
-
invariant(options.fetchPolicy !== "cache-and-network",
|
|
7565
|
+
invariant(options.fetchPolicy !== "cache-and-network", 18);
|
|
7474
7566
|
if (this.disableNetworkFetches && options.fetchPolicy === "network-only") {
|
|
7475
7567
|
options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: "cache-first" });
|
|
7476
7568
|
}
|
|
7569
|
+
if (globalThis.__DEV__ !== false) {
|
|
7570
|
+
warnRemovedOption(options, "canonizeResults", "client.query");
|
|
7571
|
+
}
|
|
7477
7572
|
return this.queryManager.query(options);
|
|
7478
7573
|
};
|
|
7479
7574
|
ApolloClient.prototype.mutate = function (options) {
|
|
@@ -7576,7 +7671,7 @@ var ApolloClient = (function () {
|
|
|
7576
7671
|
result.queries = queries;
|
|
7577
7672
|
result.results = results;
|
|
7578
7673
|
result.catch(function (error) {
|
|
7579
|
-
globalThis.__DEV__ !== false && invariant.debug(
|
|
7674
|
+
globalThis.__DEV__ !== false && invariant.debug(19, error);
|
|
7580
7675
|
});
|
|
7581
7676
|
return result;
|
|
7582
7677
|
};
|
|
@@ -7620,7 +7715,7 @@ if (globalThis.__DEV__ !== false) {
|
|
|
7620
7715
|
|
|
7621
7716
|
var contextKey = canUseSymbol ? Symbol.for("__APOLLO_CONTEXT__") : "__APOLLO_CONTEXT__";
|
|
7622
7717
|
function getApolloContext() {
|
|
7623
|
-
invariant("createContext" in React__namespace,
|
|
7718
|
+
invariant("createContext" in React__namespace, 58);
|
|
7624
7719
|
var context = React__namespace.createContext[contextKey];
|
|
7625
7720
|
if (!context) {
|
|
7626
7721
|
Object.defineProperty(React__namespace.createContext, contextKey, {
|
|
@@ -7633,12 +7728,17 @@ function getApolloContext() {
|
|
|
7633
7728
|
}
|
|
7634
7729
|
return context;
|
|
7635
7730
|
}
|
|
7636
|
-
var resetApolloContext =
|
|
7731
|
+
var resetApolloContext = function () {
|
|
7732
|
+
if (globalThis.__DEV__ !== false) {
|
|
7733
|
+
globalThis.__DEV__ !== false && invariant.warn(59);
|
|
7734
|
+
}
|
|
7735
|
+
return getApolloContext();
|
|
7736
|
+
};
|
|
7637
7737
|
|
|
7638
7738
|
var ApolloConsumer = function (props) {
|
|
7639
7739
|
var ApolloContext = getApolloContext();
|
|
7640
7740
|
return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
|
|
7641
|
-
invariant(context && context.client,
|
|
7741
|
+
invariant(context && context.client, 57);
|
|
7642
7742
|
return props.children(context.client);
|
|
7643
7743
|
}));
|
|
7644
7744
|
};
|
|
@@ -7650,14 +7750,14 @@ var ApolloProvider = function (_a) {
|
|
|
7650
7750
|
var context = React__namespace.useMemo(function () {
|
|
7651
7751
|
return tslib.__assign(tslib.__assign({}, parentContext), { client: client || parentContext.client });
|
|
7652
7752
|
}, [parentContext, client]);
|
|
7653
|
-
invariant(context.client,
|
|
7753
|
+
invariant(context.client, 60);
|
|
7654
7754
|
return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
|
|
7655
7755
|
};
|
|
7656
7756
|
|
|
7657
7757
|
function useApolloClient(override) {
|
|
7658
7758
|
var context = React__namespace.useContext(getApolloContext());
|
|
7659
7759
|
var client = override || context.client;
|
|
7660
|
-
invariant(!!client,
|
|
7760
|
+
invariant(!!client, 68);
|
|
7661
7761
|
return client;
|
|
7662
7762
|
}
|
|
7663
7763
|
|
|
@@ -7672,7 +7772,7 @@ var useSyncExternalStore = realHook$1 ||
|
|
|
7672
7772
|
!didWarnUncachedGetSnapshot &&
|
|
7673
7773
|
value !== getSnapshot()) {
|
|
7674
7774
|
didWarnUncachedGetSnapshot = true;
|
|
7675
|
-
globalThis.__DEV__ !== false && invariant.error(
|
|
7775
|
+
globalThis.__DEV__ !== false && invariant.error(81);
|
|
7676
7776
|
}
|
|
7677
7777
|
var _a = React__namespace.useState({
|
|
7678
7778
|
inst: { value: value, getSnapshot: getSnapshot },
|
|
@@ -7733,6 +7833,9 @@ function operationName(type) {
|
|
|
7733
7833
|
return name;
|
|
7734
7834
|
}
|
|
7735
7835
|
function parser(document) {
|
|
7836
|
+
warnDeprecated("parser", function () {
|
|
7837
|
+
globalThis.__DEV__ !== false && invariant.warn(83);
|
|
7838
|
+
});
|
|
7736
7839
|
if (!cache) {
|
|
7737
7840
|
cache = new AutoCleanedWeakCache(cacheSizes.parser || 1000 );
|
|
7738
7841
|
}
|
|
@@ -7740,7 +7843,7 @@ function parser(document) {
|
|
|
7740
7843
|
if (cached)
|
|
7741
7844
|
return cached;
|
|
7742
7845
|
var variables, type, name;
|
|
7743
|
-
invariant(!!document && !!document.kind,
|
|
7846
|
+
invariant(!!document && !!document.kind, 84, document);
|
|
7744
7847
|
var fragments = [];
|
|
7745
7848
|
var queries = [];
|
|
7746
7849
|
var mutations = [];
|
|
@@ -7768,10 +7871,10 @@ function parser(document) {
|
|
|
7768
7871
|
invariant(!fragments.length ||
|
|
7769
7872
|
queries.length ||
|
|
7770
7873
|
mutations.length ||
|
|
7771
|
-
subscriptions.length,
|
|
7874
|
+
subscriptions.length, 85);
|
|
7772
7875
|
invariant(
|
|
7773
7876
|
queries.length + mutations.length + subscriptions.length <= 1,
|
|
7774
|
-
|
|
7877
|
+
86,
|
|
7775
7878
|
document,
|
|
7776
7879
|
queries.length,
|
|
7777
7880
|
subscriptions.length,
|
|
@@ -7783,7 +7886,7 @@ function parser(document) {
|
|
|
7783
7886
|
var definitions = queries.length ? queries
|
|
7784
7887
|
: mutations.length ? mutations
|
|
7785
7888
|
: subscriptions;
|
|
7786
|
-
invariant(definitions.length === 1,
|
|
7889
|
+
invariant(definitions.length === 1, 87, document, definitions.length);
|
|
7787
7890
|
var definition = definitions[0];
|
|
7788
7891
|
variables = definition.variableDefinitions || [];
|
|
7789
7892
|
if (definition.name && definition.name.kind === "Name") {
|
|
@@ -7803,12 +7906,12 @@ if (globalThis.__DEV__ !== false) {
|
|
|
7803
7906
|
registerGlobalCache("parser", function () { return (cache ? cache.size : 0); });
|
|
7804
7907
|
}
|
|
7805
7908
|
function verifyDocumentType(document, type) {
|
|
7806
|
-
var operation = parser
|
|
7909
|
+
var operation = muteDeprecations("parser", parser, [document]);
|
|
7807
7910
|
var requiredOperationName = operationName(type);
|
|
7808
7911
|
var usedOperationName = operationName(operation.type);
|
|
7809
7912
|
invariant(
|
|
7810
7913
|
operation.type === type,
|
|
7811
|
-
|
|
7914
|
+
88,
|
|
7812
7915
|
requiredOperationName,
|
|
7813
7916
|
requiredOperationName,
|
|
7814
7917
|
usedOperationName
|
|
@@ -7848,6 +7951,16 @@ function useRenderGuard() {
|
|
|
7848
7951
|
}, []);
|
|
7849
7952
|
}
|
|
7850
7953
|
|
|
7954
|
+
function useWarnRemovedOption(options, name, callSite, recommendation) {
|
|
7955
|
+
"use no memo";
|
|
7956
|
+
if (recommendation === void 0) { recommendation = "Please remove this option."; }
|
|
7957
|
+
var didWarn = React__namespace.useRef(false);
|
|
7958
|
+
if (name in options && !didWarn.current) {
|
|
7959
|
+
globalThis.__DEV__ !== false && invariant.warn(67, callSite, name, recommendation);
|
|
7960
|
+
didWarn.current = true;
|
|
7961
|
+
}
|
|
7962
|
+
}
|
|
7963
|
+
|
|
7851
7964
|
var useKey = "use";
|
|
7852
7965
|
var realHook = React__namespace[useKey];
|
|
7853
7966
|
var __use = realHook ||
|
|
@@ -7876,10 +7989,16 @@ function noop() { }
|
|
|
7876
7989
|
var lastWatchOptions = Symbol();
|
|
7877
7990
|
function useQuery(query, options) {
|
|
7878
7991
|
if (options === void 0) { options = Object.create(null); }
|
|
7879
|
-
return wrapHook("useQuery",
|
|
7880
|
-
useQuery_, useApolloClient(options && options.client))(query, options);
|
|
7992
|
+
return wrapHook("useQuery", useQuery_, useApolloClient(options && options.client))(query, options);
|
|
7881
7993
|
}
|
|
7882
7994
|
function useQuery_(query, options) {
|
|
7995
|
+
if (globalThis.__DEV__ !== false) {
|
|
7996
|
+
useWarnRemovedOption(options, "canonizeResults", "useQuery");
|
|
7997
|
+
useWarnRemovedOption(options, "partialRefetch", "useQuery");
|
|
7998
|
+
useWarnRemovedOption(options, "defaultOptions", "useQuery", "Pass the options directly to the hook instead.");
|
|
7999
|
+
useWarnRemovedOption(options, "onCompleted", "useQuery", "If your `onCompleted` callback sets local state, switch to use derived state using `data` returned from the hook instead. Use `useEffect` to perform side-effects as a result of updates to `data`.");
|
|
8000
|
+
useWarnRemovedOption(options, "onError", "useQuery", "If your `onError` callback sets local state, switch to use derived state using `data`, `error` or `errors` returned from the hook instead. Use `useEffect` if you need to perform side-effects as a result of updates to `data`, `error` or `errors`.");
|
|
8001
|
+
}
|
|
7883
8002
|
var _a = useQueryInternals(query, options), result = _a.result, obsQueryFields = _a.obsQueryFields;
|
|
7884
8003
|
return React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign({}, result), obsQueryFields)); }, [result, obsQueryFields]);
|
|
7885
8004
|
}
|
|
@@ -7894,7 +8013,9 @@ function useInternalState(client, query, options, renderPromises, makeWatchQuery
|
|
|
7894
8013
|
(renderPromises &&
|
|
7895
8014
|
renderPromises.getSSRObservable(makeWatchQueryOptions())) ||
|
|
7896
8015
|
ObservableQuery["inactiveOnCreation"].withValue(!renderPromises, function () {
|
|
7897
|
-
return
|
|
8016
|
+
return muteDeprecations("canonizeResults", function () {
|
|
8017
|
+
return client.watchQuery(getObsQueryOptions(void 0, client, options, makeWatchQueryOptions()));
|
|
8018
|
+
});
|
|
7898
8019
|
}),
|
|
7899
8020
|
resultData: {
|
|
7900
8021
|
previousData: (_a = previous === null || previous === void 0 ? void 0 : previous.resultData.current) === null || _a === void 0 ? void 0 : _a.data,
|
|
@@ -8161,7 +8282,16 @@ var skipStandbyResult = maybeDeepFreeze({
|
|
|
8161
8282
|
function bindObservableMethods(observable) {
|
|
8162
8283
|
return {
|
|
8163
8284
|
refetch: observable.refetch.bind(observable),
|
|
8164
|
-
reobserve:
|
|
8285
|
+
reobserve: function () {
|
|
8286
|
+
var args = [];
|
|
8287
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8288
|
+
args[_i] = arguments[_i];
|
|
8289
|
+
}
|
|
8290
|
+
if (globalThis.__DEV__ !== false) {
|
|
8291
|
+
globalThis.__DEV__ !== false && invariant.warn(73);
|
|
8292
|
+
}
|
|
8293
|
+
return observable.reobserve.apply(observable, args);
|
|
8294
|
+
},
|
|
8165
8295
|
fetchMore: observable.fetchMore.bind(observable),
|
|
8166
8296
|
updateQuery: observable.updateQuery.bind(observable),
|
|
8167
8297
|
startPolling: observable.startPolling.bind(observable),
|
|
@@ -8179,8 +8309,40 @@ var EAGER_METHODS = [
|
|
|
8179
8309
|
"stopPolling",
|
|
8180
8310
|
"subscribeToMore",
|
|
8181
8311
|
];
|
|
8312
|
+
var REMOVED_EXECUTE_OPTIONS = [
|
|
8313
|
+
"initialFetchPolicy",
|
|
8314
|
+
"onCompleted",
|
|
8315
|
+
"onError",
|
|
8316
|
+
"defaultOptions",
|
|
8317
|
+
"partialRefetch",
|
|
8318
|
+
"canonizeResults",
|
|
8319
|
+
];
|
|
8320
|
+
var DEPRECATED_EXECUTE_OPTIONS = [
|
|
8321
|
+
"query",
|
|
8322
|
+
"ssr",
|
|
8323
|
+
"client",
|
|
8324
|
+
"fetchPolicy",
|
|
8325
|
+
"nextFetchPolicy",
|
|
8326
|
+
"refetchWritePolicy",
|
|
8327
|
+
"errorPolicy",
|
|
8328
|
+
"pollInterval",
|
|
8329
|
+
"notifyOnNetworkStatusChange",
|
|
8330
|
+
"returnPartialData",
|
|
8331
|
+
"skipPollAttempt",
|
|
8332
|
+
];
|
|
8182
8333
|
function useLazyQuery(query, options) {
|
|
8183
8334
|
var _a;
|
|
8335
|
+
if (globalThis.__DEV__ !== false) {
|
|
8336
|
+
var warnOpts = options || {};
|
|
8337
|
+
useWarnRemovedOption(warnOpts, "canonizeResults", "useLazyQuery");
|
|
8338
|
+
useWarnRemovedOption(warnOpts, "variables", "useLazyQuery", "Pass all `variables` to the returned `execute` function instead.");
|
|
8339
|
+
useWarnRemovedOption(warnOpts, "context", "useLazyQuery", "Pass `context` to the returned `execute` function instead.");
|
|
8340
|
+
useWarnRemovedOption(warnOpts, "onCompleted", "useLazyQuery", "If your `onCompleted` callback sets local state, switch to use derived state using `data` returned from the hook instead. Use `useEffect` to perform side-effects as a result of updates to `data`.");
|
|
8341
|
+
useWarnRemovedOption(warnOpts, "onError", "useLazyQuery", "If your `onError` callback sets local state, switch to use derived state using `data`, `error` or `errors` returned from the hook instead. Use `useEffect` if you need to perform side-effects as a result of updates to `data`, `error` or `errors`.");
|
|
8342
|
+
useWarnRemovedOption(warnOpts, "defaultOptions", "useLazyQuery", "Pass the options directly to the hook instead.");
|
|
8343
|
+
useWarnRemovedOption(warnOpts, "initialFetchPolicy", "useLazyQuery", "Use the `fetchPolicy` option instead.");
|
|
8344
|
+
useWarnRemovedOption(warnOpts, "partialRefetch", "useLazyQuery");
|
|
8345
|
+
}
|
|
8184
8346
|
var execOptionsRef = React__namespace.useRef(void 0);
|
|
8185
8347
|
var optionsRef = React__namespace.useRef(void 0);
|
|
8186
8348
|
var queryRef = React__namespace.useRef(void 0);
|
|
@@ -8198,6 +8360,11 @@ function useLazyQuery(query, options) {
|
|
|
8198
8360
|
var _loop_1 = function (key) {
|
|
8199
8361
|
var method = obsQueryFields[key];
|
|
8200
8362
|
eagerMethods[key] = function () {
|
|
8363
|
+
if (globalThis.__DEV__ !== false) {
|
|
8364
|
+
if (key === "reobserve") {
|
|
8365
|
+
globalThis.__DEV__ !== false && invariant.warn(69);
|
|
8366
|
+
}
|
|
8367
|
+
}
|
|
8201
8368
|
if (!execOptionsRef.current) {
|
|
8202
8369
|
execOptionsRef.current = Object.create(null);
|
|
8203
8370
|
forceUpdateState();
|
|
@@ -8213,7 +8380,28 @@ function useLazyQuery(query, options) {
|
|
|
8213
8380
|
}, [forceUpdateState, obsQueryFields]);
|
|
8214
8381
|
var called = !!execOptionsRef.current;
|
|
8215
8382
|
var result = React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign(tslib.__assign({}, useQueryResult), eagerMethods), { called: called })); }, [useQueryResult, eagerMethods, called]);
|
|
8383
|
+
var calledDuringRender = useRenderGuard();
|
|
8384
|
+
var warnRef = React__namespace.useRef(new Set());
|
|
8216
8385
|
var execute = React__namespace.useCallback(function (executeOptions) {
|
|
8386
|
+
if (globalThis.__DEV__ !== false) {
|
|
8387
|
+
if (calledDuringRender()) {
|
|
8388
|
+
globalThis.__DEV__ !== false && invariant.warn(70);
|
|
8389
|
+
}
|
|
8390
|
+
for (var _i = 0, REMOVED_EXECUTE_OPTIONS_1 = REMOVED_EXECUTE_OPTIONS; _i < REMOVED_EXECUTE_OPTIONS_1.length; _i++) {
|
|
8391
|
+
var name_1 = REMOVED_EXECUTE_OPTIONS_1[_i];
|
|
8392
|
+
if (!warnRef.current.has(name_1)) {
|
|
8393
|
+
warnRemovedOption(executeOptions || {}, name_1, "useLazyQuery.execute");
|
|
8394
|
+
warnRef.current.add(name_1);
|
|
8395
|
+
}
|
|
8396
|
+
}
|
|
8397
|
+
for (var _a = 0, DEPRECATED_EXECUTE_OPTIONS_1 = DEPRECATED_EXECUTE_OPTIONS; _a < DEPRECATED_EXECUTE_OPTIONS_1.length; _a++) {
|
|
8398
|
+
var name_2 = DEPRECATED_EXECUTE_OPTIONS_1[_a];
|
|
8399
|
+
if (!warnRef.current.has(name_2)) {
|
|
8400
|
+
warnRemovedOption(executeOptions || {}, name_2, "useLazyQuery.execute", "Please pass the option to the `useLazyQuery` hook instead.");
|
|
8401
|
+
warnRef.current.add(name_2);
|
|
8402
|
+
}
|
|
8403
|
+
}
|
|
8404
|
+
}
|
|
8217
8405
|
execOptionsRef.current =
|
|
8218
8406
|
executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
8219
8407
|
fetchPolicy: initialFetchPolicy,
|
|
@@ -8223,6 +8411,7 @@ function useLazyQuery(query, options) {
|
|
|
8223
8411
|
promise.catch(function () { });
|
|
8224
8412
|
return promise;
|
|
8225
8413
|
}, [
|
|
8414
|
+
calledDuringRender,
|
|
8226
8415
|
client,
|
|
8227
8416
|
document,
|
|
8228
8417
|
eagerMethods,
|
|
@@ -8266,6 +8455,9 @@ function executeQuery(resultData, observable, client, currentQuery, options, onQ
|
|
|
8266
8455
|
}
|
|
8267
8456
|
|
|
8268
8457
|
function useMutation(mutation, options) {
|
|
8458
|
+
if (globalThis.__DEV__ !== false) {
|
|
8459
|
+
useWarnRemovedOption(options || {}, "ignoreResults", "useMutation", "If you don't want to synchronize component state with the mutation, please use the `useApolloClient` hook to get the client instance and call `client.mutate` directly.");
|
|
8460
|
+
}
|
|
8269
8461
|
var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
|
|
8270
8462
|
verifyDocumentType(mutation, exports.DocumentType.Mutation);
|
|
8271
8463
|
var _a = React__namespace.useState({
|
|
@@ -8384,10 +8576,10 @@ function useSubscription(subscription, options) {
|
|
|
8384
8576
|
if (!hasIssuedDeprecationWarningRef.current) {
|
|
8385
8577
|
hasIssuedDeprecationWarningRef.current = true;
|
|
8386
8578
|
if (options.onSubscriptionData) {
|
|
8387
|
-
globalThis.__DEV__ !== false && invariant.warn(options.onData ?
|
|
8579
|
+
globalThis.__DEV__ !== false && invariant.warn(options.onData ? 74 : 75);
|
|
8388
8580
|
}
|
|
8389
8581
|
if (options.onSubscriptionComplete) {
|
|
8390
|
-
globalThis.__DEV__ !== false && invariant.warn(options.onComplete ?
|
|
8582
|
+
globalThis.__DEV__ !== false && invariant.warn(options.onComplete ? 76 : 77);
|
|
8391
8583
|
}
|
|
8392
8584
|
}
|
|
8393
8585
|
var skip = options.skip, fetchPolicy = options.fetchPolicy, errorPolicy = options.errorPolicy, shouldResubscribe = options.shouldResubscribe, context = options.context, extensions = options.extensions, ignoreResults = options.ignoreResults;
|
|
@@ -8508,7 +8700,7 @@ function useSubscription(subscription, options) {
|
|
|
8508
8700
|
: fallbackResult;
|
|
8509
8701
|
}, function () { return fallbackResult; });
|
|
8510
8702
|
var restart = React__namespace.useCallback(function () {
|
|
8511
|
-
invariant(!optionsRef.current.skip,
|
|
8703
|
+
invariant(!optionsRef.current.skip, 78);
|
|
8512
8704
|
setObservable(recreateRef.current());
|
|
8513
8705
|
}, [optionsRef, recreateRef]);
|
|
8514
8706
|
return React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign({}, ret), { restart: restart })); }, [ret, restart]);
|
|
@@ -8556,6 +8748,9 @@ function useFragment(options) {
|
|
|
8556
8748
|
useFragment_, useApolloClient(options.client))(options);
|
|
8557
8749
|
}
|
|
8558
8750
|
function useFragment_(options) {
|
|
8751
|
+
if (globalThis.__DEV__ !== false) {
|
|
8752
|
+
useWarnRemovedOption(options, "canonizeResults", "useFragment");
|
|
8753
|
+
}
|
|
8559
8754
|
var client = useApolloClient(options.client);
|
|
8560
8755
|
var cache = client.cache;
|
|
8561
8756
|
var from = options.from, rest = tslib.__rest(options, ["from"]);
|
|
@@ -8576,7 +8771,9 @@ function useFragment_(options) {
|
|
|
8576
8771
|
};
|
|
8577
8772
|
}
|
|
8578
8773
|
var cache = client.cache;
|
|
8579
|
-
var diff =
|
|
8774
|
+
var diff = muteDeprecations("canonizeResults", function () {
|
|
8775
|
+
return cache.diff(tslib.__assign(tslib.__assign({}, stableOptions), { returnPartialData: true, id: from, query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic }));
|
|
8776
|
+
});
|
|
8580
8777
|
return {
|
|
8581
8778
|
result: diffToResult(tslib.__assign(tslib.__assign({}, diff), { result: client["queryManager"].maskFragment({
|
|
8582
8779
|
fragment: fragment,
|
|
@@ -8588,17 +8785,19 @@ function useFragment_(options) {
|
|
|
8588
8785
|
var getSnapshot = React__namespace.useCallback(function () { return diff.result; }, [diff]);
|
|
8589
8786
|
return useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
|
|
8590
8787
|
var lastTimeout = 0;
|
|
8591
|
-
var subscription =
|
|
8592
|
-
null
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8788
|
+
var subscription = muteDeprecations("canonizeResults", function () {
|
|
8789
|
+
return stableOptions.from === null ?
|
|
8790
|
+
null
|
|
8791
|
+
: client.watchFragment(stableOptions).subscribe({
|
|
8792
|
+
next: function (result) {
|
|
8793
|
+
if (equal__default(result, diff.result))
|
|
8794
|
+
return;
|
|
8795
|
+
diff.result = result;
|
|
8796
|
+
clearTimeout(lastTimeout);
|
|
8797
|
+
lastTimeout = setTimeout(forceUpdate);
|
|
8798
|
+
},
|
|
8799
|
+
});
|
|
8800
|
+
});
|
|
8602
8801
|
return function () {
|
|
8603
8802
|
subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
|
|
8604
8803
|
clearTimeout(lastTimeout);
|
|
@@ -8631,7 +8830,7 @@ function wrapQueryRef(internalQueryRef) {
|
|
|
8631
8830
|
return ref;
|
|
8632
8831
|
}
|
|
8633
8832
|
function assertWrappedQueryRef(queryRef) {
|
|
8634
|
-
invariant(!queryRef || QUERY_REFERENCE_SYMBOL in queryRef,
|
|
8833
|
+
invariant(!queryRef || QUERY_REFERENCE_SYMBOL in queryRef, 82);
|
|
8635
8834
|
}
|
|
8636
8835
|
function getWrappedPromise(queryRef) {
|
|
8637
8836
|
var internalQueryRef = unwrapQueryRef(queryRef);
|
|
@@ -9044,6 +9243,9 @@ function useSuspenseQuery(query, options) {
|
|
|
9044
9243
|
useSuspenseQuery_, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
|
|
9045
9244
|
}
|
|
9046
9245
|
function useSuspenseQuery_(query, options) {
|
|
9246
|
+
if (globalThis.__DEV__ !== false) {
|
|
9247
|
+
useWarnRemovedOption(typeof options === "symbol" ? {} : options, "canonizeResults", "useSuspenseQuery");
|
|
9248
|
+
}
|
|
9047
9249
|
var client = useApolloClient(options.client);
|
|
9048
9250
|
var suspenseCache = getSuspenseCache(client);
|
|
9049
9251
|
var watchQueryOptions = useWatchQueryOptions({
|
|
@@ -9057,8 +9259,10 @@ function useSuspenseQuery_(query, options) {
|
|
|
9057
9259
|
query,
|
|
9058
9260
|
canonicalStringify(variables)
|
|
9059
9261
|
], [].concat(queryKey), true);
|
|
9060
|
-
var queryRef =
|
|
9061
|
-
return
|
|
9262
|
+
var queryRef = muteDeprecations("canonizeResults", function () {
|
|
9263
|
+
return suspenseCache.getQueryRef(cacheKey, function () {
|
|
9264
|
+
return client.watchQuery(watchQueryOptions);
|
|
9265
|
+
});
|
|
9062
9266
|
});
|
|
9063
9267
|
var _b = React__namespace.useState([queryRef.key, queryRef.promise]), current = _b[0], setPromise = _b[1];
|
|
9064
9268
|
if (current[0] !== queryRef.key) {
|
|
@@ -9127,11 +9331,11 @@ function validateFetchPolicy(fetchPolicy) {
|
|
|
9127
9331
|
"no-cache",
|
|
9128
9332
|
"cache-and-network",
|
|
9129
9333
|
];
|
|
9130
|
-
invariant(supportedFetchPolicies.includes(fetchPolicy),
|
|
9334
|
+
invariant(supportedFetchPolicies.includes(fetchPolicy), 79, fetchPolicy);
|
|
9131
9335
|
}
|
|
9132
9336
|
function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
9133
9337
|
if (fetchPolicy === "no-cache" && returnPartialData) {
|
|
9134
|
-
globalThis.__DEV__ !== false && invariant.warn(
|
|
9338
|
+
globalThis.__DEV__ !== false && invariant.warn(80);
|
|
9135
9339
|
}
|
|
9136
9340
|
}
|
|
9137
9341
|
function toApolloError(result) {
|
|
@@ -9166,6 +9370,9 @@ function useBackgroundQuery(query, options) {
|
|
|
9166
9370
|
useBackgroundQuery_, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
|
|
9167
9371
|
}
|
|
9168
9372
|
function useBackgroundQuery_(query, options) {
|
|
9373
|
+
if (globalThis.__DEV__ !== false) {
|
|
9374
|
+
useWarnRemovedOption(typeof options === "symbol" ? {} : options, "canonizeResults", "useBackgroundQuery");
|
|
9375
|
+
}
|
|
9169
9376
|
var client = useApolloClient(options.client);
|
|
9170
9377
|
var suspenseCache = getSuspenseCache(client);
|
|
9171
9378
|
var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
|
|
@@ -9177,8 +9384,10 @@ function useBackgroundQuery_(query, options) {
|
|
|
9177
9384
|
query,
|
|
9178
9385
|
canonicalStringify(variables)
|
|
9179
9386
|
], [].concat(queryKey), true);
|
|
9180
|
-
var queryRef =
|
|
9181
|
-
return
|
|
9387
|
+
var queryRef = muteDeprecations("canonizeResults", function () {
|
|
9388
|
+
return suspenseCache.getQueryRef(cacheKey, function () {
|
|
9389
|
+
return client.watchQuery(watchQueryOptions);
|
|
9390
|
+
});
|
|
9182
9391
|
});
|
|
9183
9392
|
var _b = React__namespace.useState(wrapQueryRef(queryRef)), wrappedQueryRef = _b[0], setWrappedQueryRef = _b[1];
|
|
9184
9393
|
if (unwrapQueryRef(wrappedQueryRef) !== queryRef) {
|
|
@@ -9260,6 +9469,9 @@ function useSuspenseFragment_(options) {
|
|
|
9260
9469
|
|
|
9261
9470
|
function useLoadableQuery(query, options) {
|
|
9262
9471
|
if (options === void 0) { options = Object.create(null); }
|
|
9472
|
+
if (globalThis.__DEV__ !== false) {
|
|
9473
|
+
useWarnRemovedOption(options, "canonizeResults", "useLoadableQuery");
|
|
9474
|
+
}
|
|
9263
9475
|
var client = useApolloClient(options.client);
|
|
9264
9476
|
var suspenseCache = getSuspenseCache(client);
|
|
9265
9477
|
var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
|
|
@@ -9293,14 +9505,16 @@ function useLoadableQuery(query, options) {
|
|
|
9293
9505
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
9294
9506
|
args[_i] = arguments[_i];
|
|
9295
9507
|
}
|
|
9296
|
-
invariant(!calledDuringRender(),
|
|
9508
|
+
invariant(!calledDuringRender(), 71);
|
|
9297
9509
|
var variables = args[0];
|
|
9298
9510
|
var cacheKey = tslib.__spreadArray([
|
|
9299
9511
|
query,
|
|
9300
9512
|
canonicalStringify(variables)
|
|
9301
9513
|
], [].concat(queryKey), true);
|
|
9302
|
-
var queryRef =
|
|
9303
|
-
return
|
|
9514
|
+
var queryRef = muteDeprecations("canonizeResults", function () {
|
|
9515
|
+
return suspenseCache.getQueryRef(cacheKey, function () {
|
|
9516
|
+
return client.watchQuery(tslib.__assign(tslib.__assign({}, watchQueryOptions), { variables: variables }));
|
|
9517
|
+
});
|
|
9304
9518
|
});
|
|
9305
9519
|
setQueryRef(wrapQueryRef(queryRef));
|
|
9306
9520
|
}, [
|
|
@@ -9312,7 +9526,7 @@ function useLoadableQuery(query, options) {
|
|
|
9312
9526
|
client,
|
|
9313
9527
|
]);
|
|
9314
9528
|
var subscribeToMore = React__namespace.useCallback(function (options) {
|
|
9315
|
-
invariant(internalQueryRef,
|
|
9529
|
+
invariant(internalQueryRef, 72);
|
|
9316
9530
|
return internalQueryRef.observable.subscribeToMore(
|
|
9317
9531
|
options);
|
|
9318
9532
|
}, [internalQueryRef]);
|
|
@@ -9397,14 +9611,22 @@ function createQueryPreloader(client) {
|
|
|
9397
9611
|
return wrapHook("createQueryPreloader", _createQueryPreloader, client)(client);
|
|
9398
9612
|
}
|
|
9399
9613
|
var _createQueryPreloader = function (client) {
|
|
9400
|
-
|
|
9401
|
-
var _a, _b;
|
|
9614
|
+
function preloadQuery(query, options) {
|
|
9402
9615
|
if (options === void 0) { options = Object.create(null); }
|
|
9403
|
-
|
|
9404
|
-
|
|
9616
|
+
warnRemovedOption(options, "canonizeResults", "preloadQuery");
|
|
9617
|
+
var queryRef = muteDeprecations("canonizeResults", function () {
|
|
9618
|
+
var _a, _b;
|
|
9619
|
+
return new InternalQueryReference(client.watchQuery(tslib.__assign(tslib.__assign({}, options), { query: query })), {
|
|
9620
|
+
autoDisposeTimeoutMs: (_b = (_a = client.defaultOptions.react) === null || _a === void 0 ? void 0 : _a.suspense) === null || _b === void 0 ? void 0 : _b.autoDisposeTimeoutMs,
|
|
9621
|
+
});
|
|
9405
9622
|
});
|
|
9406
9623
|
return wrapQueryRef(queryRef);
|
|
9407
|
-
}
|
|
9624
|
+
}
|
|
9625
|
+
return Object.assign(preloadQuery, {
|
|
9626
|
+
toPromise: function (queryRef) {
|
|
9627
|
+
return queryRef.toPromise();
|
|
9628
|
+
},
|
|
9629
|
+
});
|
|
9408
9630
|
};
|
|
9409
9631
|
|
|
9410
9632
|
exports.setLogVerbosity = tsInvariant.setVerbosity;
|