@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
|
@@ -8,6 +8,8 @@ var tslib = require('tslib');
|
|
|
8
8
|
var React = require('rehackt');
|
|
9
9
|
var hoistNonReactStatics = require('hoist-non-react-statics');
|
|
10
10
|
var components = require('../components');
|
|
11
|
+
var invariant = require('ts-invariant');
|
|
12
|
+
var optimism = require('optimism');
|
|
11
13
|
var context = require('../context');
|
|
12
14
|
|
|
13
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
@@ -26,6 +28,7 @@ function _interopNamespace(e) {
|
|
|
26
28
|
|
|
27
29
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
30
|
var hoistNonReactStatics__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonReactStatics);
|
|
31
|
+
var invariant__default = /*#__PURE__*/_interopDefaultLegacy(invariant);
|
|
29
32
|
|
|
30
33
|
var defaultMapPropsToOptions = function () { return ({}); };
|
|
31
34
|
var defaultMapPropsToSkip = function () { return false; };
|
|
@@ -59,7 +62,7 @@ var GraphQLBase = (function (_super) {
|
|
|
59
62
|
return _this;
|
|
60
63
|
}
|
|
61
64
|
GraphQLBase.prototype.getWrappedInstance = function () {
|
|
62
|
-
globals.invariant(this.withRef,
|
|
65
|
+
globals.invariant(this.withRef, 62);
|
|
63
66
|
return this.wrappedInstance;
|
|
64
67
|
};
|
|
65
68
|
GraphQLBase.prototype.setWrappedInstance = function (ref) {
|
|
@@ -68,9 +71,31 @@ var GraphQLBase = (function (_super) {
|
|
|
68
71
|
return GraphQLBase;
|
|
69
72
|
}(React__namespace.Component));
|
|
70
73
|
|
|
74
|
+
var slot = new optimism.Slot();
|
|
75
|
+
function isMuted(name) {
|
|
76
|
+
return (slot.getValue() || []).includes(name);
|
|
77
|
+
}
|
|
78
|
+
function muteDeprecations(name) {
|
|
79
|
+
var args = [];
|
|
80
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
81
|
+
args[_i - 1] = arguments[_i];
|
|
82
|
+
}
|
|
83
|
+
return slot.withValue.apply(slot, tslib.__spreadArray([Array.isArray(name) ? name : [name]], args, false));
|
|
84
|
+
}
|
|
85
|
+
function warnDeprecated(name, cb) {
|
|
86
|
+
if (!isMuted(name)) {
|
|
87
|
+
cb();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
71
91
|
function withQuery(document, operationOptions) {
|
|
72
92
|
if (operationOptions === void 0) { operationOptions = {}; }
|
|
73
|
-
|
|
93
|
+
if (globalThis.__DEV__ !== false) {
|
|
94
|
+
warnDeprecated("withQuery", function () {
|
|
95
|
+
globalThis.__DEV__ !== false && invariant__default.warn(64);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
var operation = muteDeprecations("parser", parser.parser, [document]);
|
|
74
99
|
var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.skip, skip = _b === void 0 ? defaultMapPropsToSkip : _b, _c = operationOptions.alias, alias = _c === void 0 ? "Apollo" : _c;
|
|
75
100
|
var mapPropsToOptions = options;
|
|
76
101
|
if (typeof mapPropsToOptions !== "function") {
|
|
@@ -132,7 +157,12 @@ function withQuery(document, operationOptions) {
|
|
|
132
157
|
|
|
133
158
|
function withMutation(document, operationOptions) {
|
|
134
159
|
if (operationOptions === void 0) { operationOptions = {}; }
|
|
135
|
-
|
|
160
|
+
if (globalThis.__DEV__ !== false) {
|
|
161
|
+
warnDeprecated("withMutation", function () {
|
|
162
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(63);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
var operation = muteDeprecations("parser", parser.parser, [document]);
|
|
136
166
|
var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.alias, alias = _b === void 0 ? "Apollo" : _b;
|
|
137
167
|
var mapPropsToOptions = options;
|
|
138
168
|
if (typeof mapPropsToOptions !== "function")
|
|
@@ -195,7 +225,12 @@ function withMutation(document, operationOptions) {
|
|
|
195
225
|
|
|
196
226
|
function withSubscription(document, operationOptions) {
|
|
197
227
|
if (operationOptions === void 0) { operationOptions = {}; }
|
|
198
|
-
|
|
228
|
+
if (globalThis.__DEV__ !== false) {
|
|
229
|
+
warnDeprecated("withSubscription", function () {
|
|
230
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(65);
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
var operation = muteDeprecations("parser", parser.parser, [document]);
|
|
199
234
|
var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.skip, skip = _b === void 0 ? defaultMapPropsToSkip : _b, _c = operationOptions.alias, alias = _c === void 0 ? "Apollo" : _c, shouldResubscribe = operationOptions.shouldResubscribe;
|
|
200
235
|
var mapPropsToOptions = options;
|
|
201
236
|
if (typeof mapPropsToOptions !== "function")
|
|
@@ -266,14 +301,25 @@ function withSubscription(document, operationOptions) {
|
|
|
266
301
|
|
|
267
302
|
function graphql(document, operationOptions) {
|
|
268
303
|
if (operationOptions === void 0) { operationOptions = {}; }
|
|
269
|
-
|
|
304
|
+
if (globalThis.__DEV__ !== false) {
|
|
305
|
+
warnDeprecated("graphql", function () {
|
|
306
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(61);
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
switch (muteDeprecations("parser", function () { return parser.parser(document).type; })) {
|
|
270
310
|
case parser.DocumentType.Mutation:
|
|
271
|
-
return withMutation
|
|
311
|
+
return muteDeprecations("withMutation", function () {
|
|
312
|
+
return withMutation(document, operationOptions);
|
|
313
|
+
});
|
|
272
314
|
case parser.DocumentType.Subscription:
|
|
273
|
-
return withSubscription
|
|
315
|
+
return muteDeprecations("withSubscription", function () {
|
|
316
|
+
return withSubscription(document, operationOptions);
|
|
317
|
+
});
|
|
274
318
|
case parser.DocumentType.Query:
|
|
275
319
|
default:
|
|
276
|
-
return withQuery
|
|
320
|
+
return muteDeprecations("withQuery", function () {
|
|
321
|
+
return withQuery(document, operationOptions);
|
|
322
|
+
});
|
|
277
323
|
}
|
|
278
324
|
}
|
|
279
325
|
|
|
@@ -291,7 +337,7 @@ function withApollo(WrappedComponent, operationOptions) {
|
|
|
291
337
|
return _this;
|
|
292
338
|
}
|
|
293
339
|
WithApollo.prototype.getWrappedInstance = function () {
|
|
294
|
-
globals.invariant(operationOptions.withRef,
|
|
340
|
+
globals.invariant(operationOptions.withRef, 66);
|
|
295
341
|
return this.wrappedInstance;
|
|
296
342
|
};
|
|
297
343
|
WithApollo.prototype.setWrappedInstance = function (ref) {
|
|
@@ -4,6 +4,8 @@ import hoistNonReactStatics from "hoist-non-react-statics";
|
|
|
4
4
|
import { parser } from "../parser/index.js";
|
|
5
5
|
import { Mutation } from "../components/index.js";
|
|
6
6
|
import { defaultMapPropsToOptions, getDisplayName, calculateVariablesFromProps, GraphQLBase, } from "./hoc-utils.js";
|
|
7
|
+
import { muteDeprecations, warnDeprecated, } from "../../utilities/deprecation/index.js";
|
|
8
|
+
import { invariant } from "../../utilities/globals/index.js";
|
|
7
9
|
/**
|
|
8
10
|
* @deprecated
|
|
9
11
|
* Official support for React Apollo higher order components ended in March 2020.
|
|
@@ -11,8 +13,13 @@ import { defaultMapPropsToOptions, getDisplayName, calculateVariablesFromProps,
|
|
|
11
13
|
*/
|
|
12
14
|
export function withMutation(document, operationOptions) {
|
|
13
15
|
if (operationOptions === void 0) { operationOptions = {}; }
|
|
16
|
+
if (globalThis.__DEV__ !== false) {
|
|
17
|
+
warnDeprecated("withMutation", function () {
|
|
18
|
+
globalThis.__DEV__ !== false && invariant.warn(63);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
14
21
|
// this is memoized so if coming from `graphql` there is nearly no extra cost
|
|
15
|
-
var operation = parser
|
|
22
|
+
var operation = muteDeprecations("parser", parser, [document]);
|
|
16
23
|
// extract options
|
|
17
24
|
var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.alias, alias = _b === void 0 ? "Apollo" : _b;
|
|
18
25
|
var mapPropsToOptions = options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutation-hoc.js","sourceRoot":"","sources":["../../../src/react/hoc/mutation-hoc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAGjC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,2BAA2B,EAC3B,WAAW,GACZ,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"mutation-hoc.js","sourceRoot":"","sources":["../../../src/react/hoc/mutation-hoc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAGjC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,2BAA2B,EAC3B,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,gBAAgB,EAChB,cAAc,GACf,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAQ1B,QAAsB,EACtB,gBAKM;IALN,iCAAA,EAAA,qBAKM;IAEN,IAAI,OAAO,EAAE,CAAC;QACZ,cAAc,CAAC,cAAc,EAAE;YAC7B,SAAS,CAAC,IAAI,CACZ,gLAAgL,CACjL,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACD,6EAA6E;IAC7E,IAAM,SAA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AmE;oBACnE,6BAA6B;;oBAJnB,IAAA,IAAI,UAAA,EAAK,CAAC,cAAZ,QAAc,CAAF;oBAMpB,2EAA2E;oBAC3E,IAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;oBAC5C,IAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,IAAI,QAAQ,CAAC;oBAC/C,IAAM,UAAU,GACd,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,UAAG,IAAI,WAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;oBACrD,IAAI,UAAU,GAAG,CAAA;wBACf,GAAC,IAAI,IAAG,MAAM;wBACd,GAAC,UAAU,IAAG,MAAM;0BACC,CAAA,CAAC;oBACxB,IAAI,gBAAgB,CAAC,KAAK,EAAE,CAAC;wBAC3B,IAAM,SAAS;4BAEX,GAAC,IAAI,IAAG,MAAM;4BACd,GAAC,UAAU,IAAG,MAAM;4BACpB,WAAQ,GAAE,KAAK;+BAChB,CAAC;wBACJ,UAAU,GAAG,gBAAgB,CAAC,KAAK,CAAC,SAAS,CAAQ,CAAC;oBACxD,CAAC;oBAED,OAAO,oBAAC,gBAAgB,eAAK,KAAK,EAAM,UAAU,EAAI,CAAC;gBACzD,CAAC,CACQ,CACZ,CAAC;YACJ,CAAC;YAxDM,mBAAW,GAAG,kBAAkB,CAAC;YACjC,wBAAgB,GAAG,gBAAgB,CAAC;YAwD7C,cAAC;SAAA,AA1DD,CAAsB,WAAW,GA0DhC;QAED,sEAAsE;QACtE,OAAO,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"rehackt\";\nimport type * as ReactTypes from \"react\";\nimport type { DocumentNode } from \"graphql\";\nimport hoistNonReactStatics from \"hoist-non-react-statics\";\n\nimport { parser } from \"../parser/index.js\";\nimport type { DefaultContext, OperationVariables } from \"../../core/types.js\";\nimport type { BaseMutationOptions } from \"../types/types.js\";\nimport { Mutation } from \"../components/index.js\";\n\nimport {\n defaultMapPropsToOptions,\n getDisplayName,\n calculateVariablesFromProps,\n GraphQLBase,\n} from \"./hoc-utils.js\";\nimport type { OperationOption, OptionProps, MutateProps } from \"./types.js\";\nimport type { ApolloCache } from \"../../core/index.js\";\nimport {\n muteDeprecations,\n warnDeprecated,\n} from \"../../utilities/deprecation/index.js\";\nimport { invariant } from \"../../utilities/globals/index.js\";\n\n/**\n * @deprecated\n * Official support for React Apollo higher order components ended in March 2020.\n * This library is still included in the `@apollo/client` package, but it no longer receives feature updates or bug fixes.\n */\nexport function withMutation<\n TProps extends TGraphQLVariables | {} = {},\n TData extends Record<string, any> = {},\n TGraphQLVariables extends OperationVariables = {},\n TChildProps = MutateProps<TData, TGraphQLVariables>,\n TContext extends Record<string, any> = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n>(\n document: DocumentNode,\n operationOptions: OperationOption<\n TProps,\n TData,\n TGraphQLVariables,\n TChildProps\n > = {}\n) {\n if (__DEV__) {\n warnDeprecated(\"withMutation\", () => {\n invariant.warn(\n \"[withMutation]: The `withMutation` higher order component is deprecated and will be removed in Apollo Client 4.0. Please switch to an available React hook such as `useQuery`.\"\n );\n });\n }\n // this is memoized so if coming from `graphql` there is nearly no extra cost\n const operation = muteDeprecations(\"parser\", parser, [document]);\n // extract options\n\n const { options = defaultMapPropsToOptions, alias = \"Apollo\" } =\n operationOptions;\n\n let mapPropsToOptions = options as (\n props: any\n ) => BaseMutationOptions<TData, TGraphQLVariables, TContext, TCache>;\n if (typeof mapPropsToOptions !== \"function\")\n mapPropsToOptions = () =>\n options as BaseMutationOptions<\n TData,\n TGraphQLVariables,\n TContext,\n TCache\n >;\n\n return (\n WrappedComponent: ReactTypes.ComponentType<TProps & TChildProps>\n ): ReactTypes.ComponentClass<TProps> => {\n const graphQLDisplayName = `${alias}(${getDisplayName(WrappedComponent)})`;\n class GraphQL extends GraphQLBase<TProps, TChildProps> {\n static displayName = graphQLDisplayName;\n static WrappedComponent = WrappedComponent;\n render() {\n let props = this.props as TProps;\n const opts = mapPropsToOptions(props) as BaseMutationOptions<\n TData,\n TGraphQLVariables,\n TContext,\n TCache\n >;\n\n if (operationOptions.withRef) {\n this.withRef = true;\n props = Object.assign({}, props, {\n ref: this.setWrappedInstance,\n });\n }\n if (!opts.variables && operation.variables.length > 0) {\n opts.variables = calculateVariablesFromProps(\n operation,\n props\n ) as TGraphQLVariables;\n }\n\n return (\n // @ts-expect-error\n <Mutation ignoreResults {...opts} mutation={document}>\n {(mutate, { data, ...r }) => {\n // the HOC's historically hoisted the data from the execution result\n // up onto the result since it was passed as a nested prop\n // we massage the Mutation component's shape here to replicate that\n // this matches the query HoC\n\n // @ts-ignore Type instantiation is excessively deep and possibly infinite.\n const result = Object.assign(r, data || {});\n const name = operationOptions.name || \"mutate\";\n const resultName =\n operationOptions.name ? `${name}Result` : \"result\";\n let childProps = {\n [name]: mutate,\n [resultName]: result,\n } as any as TChildProps;\n if (operationOptions.props) {\n const newResult: OptionProps<TProps, TData, TGraphQLVariables> =\n {\n [name]: mutate,\n [resultName]: result,\n ownProps: props,\n };\n childProps = operationOptions.props(newResult) as any;\n }\n\n return <WrappedComponent {...props} {...childProps} />;\n }}\n </Mutation>\n );\n }\n }\n\n // Make sure we preserve any custom statics on the original component.\n return hoistNonReactStatics(GraphQL, WrappedComponent, {});\n };\n}\n"]}
|
package/react/hoc/query-hoc.js
CHANGED
|
@@ -4,6 +4,8 @@ import hoistNonReactStatics from "hoist-non-react-statics";
|
|
|
4
4
|
import { parser } from "../parser/index.js";
|
|
5
5
|
import { Query } from "../components/index.js";
|
|
6
6
|
import { getDisplayName, GraphQLBase, calculateVariablesFromProps, defaultMapPropsToOptions, defaultMapPropsToSkip, } from "./hoc-utils.js";
|
|
7
|
+
import invariant from "ts-invariant";
|
|
8
|
+
import { muteDeprecations, warnDeprecated, } from "../../utilities/deprecation/index.js";
|
|
7
9
|
/**
|
|
8
10
|
* @deprecated
|
|
9
11
|
* Official support for React Apollo higher order components ended in March 2020.
|
|
@@ -11,8 +13,13 @@ import { getDisplayName, GraphQLBase, calculateVariablesFromProps, defaultMapPro
|
|
|
11
13
|
*/
|
|
12
14
|
export function withQuery(document, operationOptions) {
|
|
13
15
|
if (operationOptions === void 0) { operationOptions = {}; }
|
|
16
|
+
if (globalThis.__DEV__ !== false) {
|
|
17
|
+
warnDeprecated("withQuery", function () {
|
|
18
|
+
globalThis.__DEV__ !== false && invariant.warn(64);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
14
21
|
// this is memoized so if coming from `graphql` there is nearly no extra cost
|
|
15
|
-
var operation = parser
|
|
22
|
+
var operation = muteDeprecations("parser", parser, [document]);
|
|
16
23
|
// extract options
|
|
17
24
|
var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.skip, skip = _b === void 0 ? defaultMapPropsToSkip : _b, _c = operationOptions.alias, alias = _c === void 0 ? "Apollo" : _c;
|
|
18
25
|
var mapPropsToOptions = options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-hoc.js","sourceRoot":"","sources":["../../../src/react/hoc/query-hoc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAGjC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,WAAW,EACX,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"query-hoc.js","sourceRoot":"","sources":["../../../src/react/hoc/query-hoc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAGjC,OAAO,oBAAoB,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AED,oEAAoE;oBACpE,0DAA0D;oBAC1D,+DAA+D;oBAC/D,IAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;oBAC5C,IAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,IAAI,MAAM,CAAC;oBAC7C,IAAI,UAAU,aAAK,GAAC,IAAI,IAAG,MAAM,KAAE,CAAC;oBACpC,IAAI,gBAAgB,CAAC,KAAK,EAAE,CAAC;wBAC3B,IAAM,SAAS;4BAEX,GAAC,IAAI,IAAG,MAAM;4BACd,WAAQ,GAAE,KAAe;+BAC1B,CAAC;wBACJ,eAAe,GAAG,gBAAgB,CAAC,KAAK,CACtC,SAAS,EACT,eAAe,CAChB,CAAC;wBACF,UAAU,GAAG,eAAe,CAAC;oBAC/B,CAAC;oBAED,OAAO,CACL,oBAAC,gBAAgB,eACV,KAAgB,EAChB,UAA0B,EAC/B,CACH,CAAC;gBACJ,CAAC,CACK,CACT,CAAC;YACJ,CAAC;YAlEM,mBAAW,GAAG,kBAAkB,CAAC;YACjC,wBAAgB,GAAG,gBAAgB,CAAC;YAkE7C,cAAC;SAAA,AApED,CAAsB,WAAW,GAoEhC;QAED,sEAAsE;QACtE,OAAO,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"rehackt\";\nimport type * as ReactTypes from \"react\";\nimport type { DocumentNode } from \"graphql\";\nimport hoistNonReactStatics from \"hoist-non-react-statics\";\n\nimport { parser } from \"../parser/index.js\";\nimport type { BaseQueryOptions } from \"../types/types.js\";\nimport { Query } from \"../components/index.js\";\nimport {\n getDisplayName,\n GraphQLBase,\n calculateVariablesFromProps,\n defaultMapPropsToOptions,\n defaultMapPropsToSkip,\n} from \"./hoc-utils.js\";\nimport type { OperationOption, OptionProps, DataProps } from \"./types.js\";\nimport invariant from \"ts-invariant\";\nimport {\n muteDeprecations,\n warnDeprecated,\n} from \"../../utilities/deprecation/index.js\";\n\n/**\n * @deprecated\n * Official support for React Apollo higher order components ended in March 2020.\n * This library is still included in the `@apollo/client` package, but it no longer receives feature updates or bug fixes.\n */\nexport function withQuery<\n TProps extends TGraphQLVariables | Record<string, any> = Record<string, any>,\n TData extends object = {},\n TGraphQLVariables extends object = {},\n TChildProps extends object = DataProps<TData, TGraphQLVariables>,\n>(\n document: DocumentNode,\n operationOptions: OperationOption<\n TProps,\n TData,\n TGraphQLVariables,\n TChildProps\n > = {}\n) {\n if (__DEV__) {\n warnDeprecated(\"withQuery\", () => {\n invariant.warn(\n \"[withQuery]: The `withQuery` higher order component is deprecated and will be removed in Apollo Client 4.0. Please switch to an available React hook such as `useQuery`.\"\n );\n });\n }\n // this is memoized so if coming from `graphql` there is nearly no extra cost\n const operation = muteDeprecations(\"parser\", parser, [document]);\n // extract options\n const {\n options = defaultMapPropsToOptions,\n skip = defaultMapPropsToSkip,\n alias = \"Apollo\",\n } = operationOptions;\n\n let mapPropsToOptions = options as (props: any) => BaseQueryOptions;\n if (typeof mapPropsToOptions !== \"function\") {\n mapPropsToOptions = () => options as BaseQueryOptions;\n }\n\n let mapPropsToSkip = skip as (props: any) => boolean;\n if (typeof mapPropsToSkip !== \"function\") {\n mapPropsToSkip = () => skip as any;\n }\n\n // allow for advanced referential equality checks\n let lastResultProps: TChildProps | void;\n return (\n WrappedComponent: ReactTypes.ComponentType<TProps & TChildProps>\n ): ReactTypes.ComponentClass<TProps> => {\n const graphQLDisplayName = `${alias}(${getDisplayName(WrappedComponent)})`;\n class GraphQL extends GraphQLBase<TProps, TChildProps> {\n static displayName = graphQLDisplayName;\n static WrappedComponent = WrappedComponent;\n\n render() {\n let props = this.props;\n const shouldSkip = mapPropsToSkip(props);\n const opts =\n shouldSkip ? Object.create(null) : { ...mapPropsToOptions(props) };\n\n if (!shouldSkip && !opts.variables && operation.variables.length > 0) {\n opts.variables = calculateVariablesFromProps(operation, props);\n }\n\n return (\n <Query\n {...opts}\n displayName={graphQLDisplayName}\n skip={shouldSkip}\n query={document}\n >\n {({ client: _, data, ...r }: any) => {\n if (operationOptions.withRef) {\n this.withRef = true;\n props = Object.assign({}, props, {\n ref: this.setWrappedInstance,\n });\n }\n\n // if we have skipped, no reason to manage any reshaping\n if (shouldSkip) {\n return (\n <WrappedComponent\n {...(props as TProps)}\n {...({} as TChildProps)}\n />\n );\n }\n\n // the HOC's historically hoisted the data from the execution result\n // up onto the result since it was passed as a nested prop\n // we massage the Query components shape here to replicate that\n const result = Object.assign(r, data || {});\n const name = operationOptions.name || \"data\";\n let childProps = { [name]: result };\n if (operationOptions.props) {\n const newResult: OptionProps<TProps, TData, TGraphQLVariables> =\n {\n [name]: result,\n ownProps: props as TProps,\n };\n lastResultProps = operationOptions.props(\n newResult,\n lastResultProps\n );\n childProps = lastResultProps;\n }\n\n return (\n <WrappedComponent\n {...(props as TProps)}\n {...(childProps as TChildProps)}\n />\n );\n }}\n </Query>\n );\n }\n }\n\n // Make sure we preserve any custom statics on the original component.\n return hoistNonReactStatics(GraphQL, WrappedComponent, {});\n };\n}\n"]}
|
|
@@ -4,6 +4,8 @@ import hoistNonReactStatics from "hoist-non-react-statics";
|
|
|
4
4
|
import { parser } from "../parser/index.js";
|
|
5
5
|
import { Subscription } from "../components/index.js";
|
|
6
6
|
import { getDisplayName, GraphQLBase, calculateVariablesFromProps, defaultMapPropsToOptions, defaultMapPropsToSkip, } from "./hoc-utils.js";
|
|
7
|
+
import { muteDeprecations, warnDeprecated, } from "../../utilities/deprecation/index.js";
|
|
8
|
+
import { invariant } from "../../utilities/globals/index.js";
|
|
7
9
|
/**
|
|
8
10
|
* @deprecated
|
|
9
11
|
* Official support for React Apollo higher order components ended in March 2020.
|
|
@@ -11,8 +13,13 @@ import { getDisplayName, GraphQLBase, calculateVariablesFromProps, defaultMapPro
|
|
|
11
13
|
*/
|
|
12
14
|
export function withSubscription(document, operationOptions) {
|
|
13
15
|
if (operationOptions === void 0) { operationOptions = {}; }
|
|
16
|
+
if (globalThis.__DEV__ !== false) {
|
|
17
|
+
warnDeprecated("withSubscription", function () {
|
|
18
|
+
globalThis.__DEV__ !== false && invariant.warn(65);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
14
21
|
// this is memoized so if coming from `graphql` there is nearly no extra cost
|
|
15
|
-
var operation = parser
|
|
22
|
+
var operation = muteDeprecations("parser", parser, [document]);
|
|
16
23
|
// extract options
|
|
17
24
|
var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.skip, skip = _b === void 0 ? defaultMapPropsToSkip : _b, _c = operationOptions.alias, alias = _c === void 0 ? "Apollo" : _c, shouldResubscribe = operationOptions.shouldResubscribe;
|
|
18
25
|
var mapPropsToOptions = options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-hoc.js","sourceRoot":"","sources":["../../../src/react/hoc/subscription-hoc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAGjC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACL,cAAc,EACd,WAAW,EACX,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"subscription-hoc.js","sourceRoot":"","sources":["../../../src/react/hoc/subscription-hoc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAGjC,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACL,cAAc,EACd,WAAW,EACX,2BAA2B,EAC3B,w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D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"rehackt\";\nimport type * as ReactTypes from \"react\";\nimport type { DocumentNode } from \"graphql\";\nimport hoistNonReactStatics from \"hoist-non-react-statics\";\n\nimport { parser } from \"../parser/index.js\";\nimport type { BaseQueryOptions } from \"../types/types.js\";\nimport { Subscription } from \"../components/index.js\";\nimport {\n getDisplayName,\n GraphQLBase,\n calculateVariablesFromProps,\n defaultMapPropsToOptions,\n defaultMapPropsToSkip,\n} from \"./hoc-utils.js\";\nimport type { OperationOption, OptionProps, DataProps } from \"./types.js\";\nimport {\n muteDeprecations,\n warnDeprecated,\n} from \"../../utilities/deprecation/index.js\";\nimport { invariant } from \"../../utilities/globals/index.js\";\n\n/**\n * @deprecated\n * Official support for React Apollo higher order components ended in March 2020.\n * This library is still included in the `@apollo/client` package, but it no longer receives feature updates or bug fixes.\n */\nexport function withSubscription<\n TProps extends TGraphQLVariables | {} = {},\n TData extends object = {},\n TGraphQLVariables extends object = {},\n TChildProps extends object = DataProps<TData, TGraphQLVariables>,\n>(\n document: DocumentNode,\n operationOptions: OperationOption<\n TProps,\n TData,\n TGraphQLVariables,\n TChildProps\n > = {}\n) {\n if (__DEV__) {\n warnDeprecated(\"withSubscription\", () => {\n invariant.warn(\n \"[withSubscription]: The `withSubscription` higher order component is deprecated and will be removed in Apollo Client 4.0. Please switch to an available React hook such as `useSubscription`.\"\n );\n });\n }\n // this is memoized so if coming from `graphql` there is nearly no extra cost\n const operation = muteDeprecations(\"parser\", parser, [document]);\n // extract options\n const {\n options = defaultMapPropsToOptions,\n skip = defaultMapPropsToSkip,\n alias = \"Apollo\",\n shouldResubscribe,\n } = operationOptions;\n\n let mapPropsToOptions = options as (props: any) => BaseQueryOptions;\n if (typeof mapPropsToOptions !== \"function\")\n mapPropsToOptions = () => options as BaseQueryOptions;\n\n let mapPropsToSkip = skip as (props: any) => boolean;\n if (typeof mapPropsToSkip !== \"function\") mapPropsToSkip = () => skip as any;\n\n // allow for advanced referential equality checks\n let lastResultProps: TChildProps | void;\n return (\n WrappedComponent: ReactTypes.ComponentType<TProps & TChildProps>\n ): ReactTypes.ComponentClass<TProps> => {\n const graphQLDisplayName = `${alias}(${getDisplayName(WrappedComponent)})`;\n class GraphQL extends GraphQLBase<\n TProps,\n TChildProps,\n { resubscribe: boolean }\n > {\n static displayName = graphQLDisplayName;\n static WrappedComponent = WrappedComponent;\n constructor(props: TProps) {\n super(props);\n this.state = { resubscribe: false };\n }\n\n updateResubscribe(resubscribe: boolean) {\n this.setState({ resubscribe });\n }\n\n componentDidUpdate(prevProps: TProps) {\n const resubscribe = !!(\n shouldResubscribe && shouldResubscribe(prevProps, this.props)\n );\n if (this.state.resubscribe !== resubscribe) {\n this.updateResubscribe(resubscribe);\n }\n }\n\n render() {\n let props = this.props;\n const shouldSkip = mapPropsToSkip(props);\n const opts =\n shouldSkip ? Object.create(null) : mapPropsToOptions(props);\n\n if (!shouldSkip && !opts.variables && operation.variables.length > 0) {\n opts.variables = calculateVariablesFromProps(operation, props);\n }\n return (\n <Subscription\n {...opts}\n displayName={graphQLDisplayName}\n skip={shouldSkip}\n subscription={document}\n shouldResubscribe={this.state.resubscribe}\n >\n {({ data, ...r }: any) => {\n if (operationOptions.withRef) {\n this.withRef = true;\n props = Object.assign({}, props, {\n ref: this.setWrappedInstance,\n });\n }\n // if we have skipped, no reason to manage any reshaping\n if (shouldSkip) {\n return (\n <WrappedComponent\n {...(props as TProps)}\n {...({} as TChildProps)}\n />\n );\n }\n\n // the HOC's historically hoisted the data from the execution result\n // up onto the result since it was passed as a nested prop\n // we massage the Query components shape here to replicate that\n const result = Object.assign(r, data || {});\n const name = operationOptions.name || \"data\";\n let childProps = { [name]: result };\n if (operationOptions.props) {\n const newResult: OptionProps<TProps, TData, TGraphQLVariables> =\n {\n [name]: result,\n ownProps: props as TProps,\n };\n lastResultProps = operationOptions.props(\n newResult,\n lastResultProps\n );\n childProps = lastResultProps;\n }\n\n return (\n <WrappedComponent\n {...(props as TProps)}\n {...(childProps as TChildProps)}\n />\n );\n }}\n </Subscription>\n );\n }\n }\n\n // Make sure we preserve any custom statics on the original component.\n return hoistNonReactStatics(GraphQL, WrappedComponent, {});\n };\n}\n"]}
|
package/react/hoc/withApollo.js
CHANGED
|
@@ -22,7 +22,7 @@ export function withApollo(WrappedComponent, operationOptions) {
|
|
|
22
22
|
return _this;
|
|
23
23
|
}
|
|
24
24
|
WithApollo.prototype.getWrappedInstance = function () {
|
|
25
|
-
invariant(operationOptions.withRef,
|
|
25
|
+
invariant(operationOptions.withRef, 66);
|
|
26
26
|
return this.wrappedInstance;
|
|
27
27
|
};
|
|
28
28
|
WithApollo.prototype.setWrappedInstance = function (ref) {
|