@apollo/client 3.12.0-alpha.0 → 3.12.0-rc.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/cold-apes-bow.md +5 -0
- package/.changeset/early-bobcats-eat.md +5 -0
- package/.changeset/flat-beans-knock.md +15 -0
- package/.changeset/kind-toys-tie.md +5 -0
- package/.changeset/nervous-owls-hear.md +5 -0
- package/.changeset/pre.json +7 -2
- package/CHANGELOG.md +34 -0
- package/apollo-client.cjs +133 -77
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +30 -20
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +30 -20
- package/cache/inmemory/policies.js +12 -9
- package/cache/inmemory/policies.js.map +1 -1
- package/config/jest/setup.js +5 -0
- package/config/jest/setup.js.map +1 -1
- package/core/ApolloClient.js +7 -3
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.js +2 -0
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.d.ts +4 -1
- package/core/QueryManager.js +26 -2
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +57 -20
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +57 -20
- package/core/masking.d.ts +6 -0
- package/core/masking.js +33 -15
- package/core/masking.js.map +1 -1
- package/dev/dev.cjs +66 -62
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +66 -62
- package/invariantErrorCodes.js +66 -61
- 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/index.js.map +1 -1
- 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/types.d.ts +2 -2
- package/masking/types.js.map +1 -1
- package/package.json +4 -3
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs +3 -3
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +3 -3
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc.cjs +2 -2
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +2 -2
- package/react/hoc/withApollo.js +1 -1
- package/react/hooks/hooks.cjs +9 -9
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +9 -9
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useLoadableQuery.js +2 -2
- package/react/hooks/useSubscription.js +3 -3
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/internal/cache/QueryReference.js +2 -2
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/internal.cjs +3 -3
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +3 -3
- package/react/parser/index.js +5 -5
- package/react/parser/parser.cjs +5 -5
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +5 -5
- package/testing/core/core.cjs +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/internal/ObservableStream.d.ts +11 -15
- package/testing/internal/ObservableStream.js +18 -62
- package/testing/internal/ObservableStream.js.map +1 -1
- package/testing/internal/index.d.ts +1 -2
- package/testing/internal/index.js +1 -2
- package/testing/internal/index.js.map +1 -1
- package/testing/internal/renderHelpers.d.ts +13 -2
- package/testing/internal/renderHelpers.js +20 -12
- package/testing/internal/renderHelpers.js.map +1 -1
- package/testing/matchers/index.js +0 -3
- package/testing/matchers/index.js.map +1 -1
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/utilities/graphql/DocumentTransform.js +1 -1
- package/utilities/graphql/directives.js +7 -7
- package/utilities/graphql/fragments.d.ts +1 -0
- package/utilities/graphql/fragments.js +18 -3
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/transform.js +8 -2
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +1 -1
- package/utilities/index.js +1 -1
- package/utilities/index.js.map +1 -1
- package/utilities/utilities.cjs +41 -22
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +41 -22
- package/version.js +1 -1
- package/testing/internal/profile/Render.d.ts +0 -69
- package/testing/internal/profile/Render.js +0 -144
- package/testing/internal/profile/Render.js.map +0 -1
- package/testing/internal/profile/context.d.ts +0 -10
- package/testing/internal/profile/context.js +0 -14
- package/testing/internal/profile/context.js.map +0 -1
- package/testing/internal/profile/index.d.ts +0 -4
- package/testing/internal/profile/index.js +0 -2
- package/testing/internal/profile/index.js.map +0 -1
- package/testing/internal/profile/profile.d.ts +0 -109
- package/testing/internal/profile/profile.js +0 -304
- package/testing/internal/profile/profile.js.map +0 -1
- package/testing/internal/profile/traces.d.ts +0 -7
- package/testing/internal/profile/traces.js +0 -30
- package/testing/internal/profile/traces.js.map +0 -1
- package/testing/matchers/ProfiledComponent.d.ts +0 -8
- package/testing/matchers/ProfiledComponent.js +0 -110
- package/testing/matchers/ProfiledComponent.js.map +0 -1
package/cache/cache.cjs
CHANGED
|
@@ -126,6 +126,7 @@ function directiveIsNonreactive(dir) {
|
|
|
126
126
|
return dir.name.value === "nonreactive";
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
var disableWarningsSlot = new optimism.Slot();
|
|
129
130
|
function maskFragment(data, document, cache, fragmentName) {
|
|
130
131
|
if (!cache.fragmentMatches) {
|
|
131
132
|
if (globalThis.__DEV__ !== false) {
|
|
@@ -137,14 +138,17 @@ function maskFragment(data, document, cache, fragmentName) {
|
|
|
137
138
|
return node.kind === graphql.Kind.FRAGMENT_DEFINITION;
|
|
138
139
|
});
|
|
139
140
|
if (typeof fragmentName === "undefined") {
|
|
140
|
-
globals.invariant(fragments.length === 1,
|
|
141
|
+
globals.invariant(fragments.length === 1, 39, fragments.length);
|
|
141
142
|
fragmentName = fragments[0].name.value;
|
|
142
143
|
}
|
|
143
144
|
var fragment = fragments.find(function (fragment) { return fragment.name.value === fragmentName; });
|
|
144
|
-
globals.invariant(!!fragment,
|
|
145
|
+
globals.invariant(!!fragment, 40, fragmentName);
|
|
145
146
|
if (data == null) {
|
|
146
147
|
return data;
|
|
147
148
|
}
|
|
149
|
+
if (equal.equal(data, {})) {
|
|
150
|
+
return data;
|
|
151
|
+
}
|
|
148
152
|
var context = {
|
|
149
153
|
operationType: "fragment",
|
|
150
154
|
operationName: fragment.name.value,
|
|
@@ -153,9 +157,7 @@ function maskFragment(data, document, cache, fragmentName) {
|
|
|
153
157
|
};
|
|
154
158
|
var _a = maskSelectionSet(data, fragment.selectionSet, context), masked = _a[0], changed = _a[1];
|
|
155
159
|
if (Object.isFrozen(data)) {
|
|
156
|
-
|
|
157
|
-
utilities.maybeDeepFreeze(masked);
|
|
158
|
-
context.disableWarnings = false;
|
|
160
|
+
disableWarningsSlot.withValue(true, utilities.maybeDeepFreeze, [masked]);
|
|
159
161
|
}
|
|
160
162
|
return changed ? masked : data;
|
|
161
163
|
}
|
|
@@ -179,7 +181,10 @@ function maskSelectionSet(data, selectionSet, context, path) {
|
|
|
179
181
|
var keyName = utilities.resultKeyNameFromField(selection);
|
|
180
182
|
var childSelectionSet = selection.selectionSet;
|
|
181
183
|
memo[keyName] = data[keyName];
|
|
182
|
-
if (
|
|
184
|
+
if (memo[keyName] === void 0) {
|
|
185
|
+
delete memo[keyName];
|
|
186
|
+
}
|
|
187
|
+
if (keyName in memo && childSelectionSet && data[keyName] !== null) {
|
|
183
188
|
var _b = maskSelectionSet(data[keyName], childSelectionSet, context, globalThis.__DEV__ !== false ? "".concat(path || "", ".").concat(keyName) : void 0), masked = _b[0], childChanged = _b[1];
|
|
184
189
|
if (childChanged ||
|
|
185
190
|
Object.keys(masked).length !== Object.keys(data[keyName]).length) {
|
|
@@ -205,7 +210,7 @@ function maskSelectionSet(data, selectionSet, context, path) {
|
|
|
205
210
|
var fragment = context.fragmentMap[fragmentName] ||
|
|
206
211
|
(context.fragmentMap[fragmentName] =
|
|
207
212
|
context.cache.lookupFragment(fragmentName));
|
|
208
|
-
globals.invariant(fragment,
|
|
213
|
+
globals.invariant(fragment, 41, fragmentName);
|
|
209
214
|
var mode = utilities.getFragmentMaskMode(selection);
|
|
210
215
|
if (mode === "mask") {
|
|
211
216
|
return [memo, true];
|
|
@@ -223,7 +228,7 @@ function maskSelectionSet(data, selectionSet, context, path) {
|
|
|
223
228
|
}
|
|
224
229
|
}
|
|
225
230
|
}, [Object.create(null), false]);
|
|
226
|
-
if ("__typename" in data && !("__typename" in result[0])) {
|
|
231
|
+
if (data && "__typename" in data && !("__typename" in result[0])) {
|
|
227
232
|
result[0].__typename = data.__typename;
|
|
228
233
|
}
|
|
229
234
|
return result;
|
|
@@ -273,11 +278,14 @@ function addFieldAccessorWarnings(memo, data, selectionSetNode, path, context) {
|
|
|
273
278
|
}, memo);
|
|
274
279
|
}
|
|
275
280
|
function addAccessorWarning(data, value, fieldName, path, context) {
|
|
281
|
+
if (value === void 0) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
276
284
|
var getValue = function () {
|
|
277
|
-
if (
|
|
285
|
+
if (disableWarningsSlot.getValue()) {
|
|
278
286
|
return value;
|
|
279
287
|
}
|
|
280
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
288
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(42, context.operationName ?
|
|
281
289
|
"".concat(context.operationType, " '").concat(context.operationName, "'")
|
|
282
290
|
: "anonymous ".concat(context.operationType), "".concat(path, ".").concat(fieldName).replace(/^\./, ""));
|
|
283
291
|
getValue = function () { return value; };
|
|
@@ -298,7 +306,7 @@ var issuedWarning = false;
|
|
|
298
306
|
function warnOnImproperCacheImplementation() {
|
|
299
307
|
if (!issuedWarning) {
|
|
300
308
|
issuedWarning = true;
|
|
301
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
309
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(43);
|
|
302
310
|
}
|
|
303
311
|
}
|
|
304
312
|
|
|
@@ -1648,16 +1656,18 @@ var Policies = (function () {
|
|
|
1648
1656
|
var id;
|
|
1649
1657
|
var policy = typename && this.getTypePolicy(typename);
|
|
1650
1658
|
var keyFn = (policy && policy.keyFn) || this.config.dataIdFromObject;
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
+
disableWarningsSlot.withValue(true, function () {
|
|
1660
|
+
while (keyFn) {
|
|
1661
|
+
var specifierOrId = keyFn(tslib.__assign(tslib.__assign({}, object), storeObject), context);
|
|
1662
|
+
if (utilities.isArray(specifierOrId)) {
|
|
1663
|
+
keyFn = keyFieldsFnFromSpecifier(specifierOrId);
|
|
1664
|
+
}
|
|
1665
|
+
else {
|
|
1666
|
+
id = specifierOrId;
|
|
1667
|
+
break;
|
|
1668
|
+
}
|
|
1659
1669
|
}
|
|
1660
|
-
}
|
|
1670
|
+
});
|
|
1661
1671
|
id = id ? String(id) : void 0;
|
|
1662
1672
|
return context.keyObject ? [id, context.keyObject] : [id];
|
|
1663
1673
|
};
|