@apollo/client 3.11.7 → 3.12.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/nasty-camels-pay.md +36 -0
- package/.changeset/pre.json +10 -0
- package/CHANGELOG.md +43 -0
- package/apollo-client.cjs +438 -111
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +218 -22
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +218 -22
- package/cache/core/cache.d.ts +13 -10
- package/cache/core/cache.js +32 -14
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +2 -1
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +4 -3
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/inMemoryCache.d.ts +3 -1
- package/cache/inmemory/inMemoryCache.js +7 -0
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/ApolloClient.d.ts +14 -6
- package/core/ApolloClient.js +14 -6
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.js +2 -2
- package/core/ObservableQuery.d.ts +17 -14
- package/core/ObservableQuery.js +29 -16
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +18 -3
- package/core/QueryManager.js +39 -14
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +285 -37
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +285 -37
- package/core/index.d.ts +1 -0
- package/core/index.js.map +1 -1
- package/core/masking.d.ts +4 -0
- package/core/masking.js +212 -0
- package/core/masking.js.map +1 -0
- package/core/types.d.ts +3 -2
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +8 -6
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +131 -87
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +131 -87
- package/invariantErrorCodes.js +140 -86
- package/link/core/ApolloLink.js +2 -2
- package/link/core/core.cjs +2 -2
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +2 -2
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +1 -1
- package/link/http/http.cjs +6 -6
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +6 -6
- package/link/http/selectHttpOptionsAndBody.js +3 -3
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/persisted-queries/persisted-queries.cjs +2 -2
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
- package/link/utils/toPromise.js +1 -1
- package/link/utils/utils.cjs +2 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +2 -2
- package/link/utils/validateOperation.js +1 -1
- package/masking/index.d.ts +2 -0
- package/masking/index.js +2 -0
- package/masking/index.js.map +1 -0
- package/masking/internal/types.d.ts +15 -0
- package/masking/internal/types.js +2 -0
- package/masking/internal/types.js.map +1 -0
- package/masking/masking.cjs +3 -0
- package/masking/masking.cjs.map +1 -0
- package/masking/masking.cjs.native.js +3 -0
- package/masking/masking.d.cts +1 -0
- package/masking/package.json +8 -0
- package/masking/types.d.ts +44 -0
- package/masking/types.js +2 -0
- package/masking/types.js.map +1 -0
- package/package.json +2 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs +3 -3
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +3 -3
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc.cjs +2 -2
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +2 -2
- package/react/hoc/withApollo.js +1 -1
- package/react/hooks/hooks.cjs +24 -16
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +24 -16
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useFragment.d.ts +4 -3
- package/react/hooks/useFragment.js +12 -5
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.js +1 -1
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.js +2 -2
- package/react/hooks/useQuery.d.ts +4 -3
- package/react/hooks/useQuery.js +2 -1
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +2 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +2 -1
- package/react/hooks/useSubscription.js +3 -3
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +6 -5
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/internal/cache/QueryReference.d.ts +5 -4
- package/react/internal/cache/QueryReference.js +1 -1
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/internal.cjs +2 -2
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +2 -2
- package/react/parser/index.js +5 -5
- package/react/parser/parser.cjs +5 -5
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +5 -5
- package/react/types/types.d.ts +18 -42
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +3 -3
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +3 -3
- package/testing/core/mocking/mockLink.d.ts +3 -2
- package/testing/core/mocking/mockLink.js +3 -3
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts +1 -0
- package/testing/core/mocking/mockQueryManager.js +1 -1
- package/testing/core/mocking/mockQueryManager.js.map +1 -1
- package/testing/internal/disposables/index.d.ts +1 -0
- package/testing/internal/disposables/index.js +1 -0
- package/testing/internal/disposables/index.js.map +1 -1
- package/testing/internal/disposables/withProdMode.d.ts +4 -0
- package/testing/internal/disposables/withProdMode.js +10 -0
- package/testing/internal/disposables/withProdMode.js.map +1 -0
- package/testing/internal/scenarios/index.d.ts +28 -0
- package/testing/internal/scenarios/index.js +18 -2
- package/testing/internal/scenarios/index.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.d.ts +1 -0
- package/utilities/common/maybeDeepFreeze.js +1 -1
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/utilities/graphql/DocumentTransform.js +1 -1
- package/utilities/graphql/directives.d.ts +3 -1
- package/utilities/graphql/directives.js +39 -5
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.js +3 -3
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/transform.d.ts +1 -0
- package/utilities/graphql/transform.js +15 -2
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +7 -3
- package/utilities/index.js +4 -3
- package/utilities/index.js.map +1 -1
- package/utilities/promises/preventUnhandledRejection.d.ts +2 -0
- package/utilities/promises/preventUnhandledRejection.js +5 -0
- package/utilities/promises/preventUnhandledRejection.js.map +1 -0
- package/utilities/subscriptions/relay/relay.cjs.map +1 -1
- package/utilities/subscriptions/urql/urql.cjs.map +1 -1
- package/utilities/types/NoInfer.d.ts +27 -0
- package/utilities/types/NoInfer.js +2 -0
- package/utilities/types/NoInfer.js.map +1 -0
- package/utilities/types/Prettify.d.ts +4 -0
- package/utilities/types/Prettify.js +2 -0
- package/utilities/types/Prettify.js.map +1 -0
- package/utilities/types/UnionToIntersection.d.ts +2 -0
- package/utilities/types/UnionToIntersection.js +2 -0
- package/utilities/types/UnionToIntersection.js.map +1 -0
- package/utilities/utilities.cjs +73 -19
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +73 -19
- package/version.js +1 -1
package/cache/cache.cjs
CHANGED
|
@@ -8,8 +8,8 @@ var optimism = require('optimism');
|
|
|
8
8
|
var utilities = require('../utilities');
|
|
9
9
|
var caches = require('@wry/caches');
|
|
10
10
|
var equal = require('@wry/equality');
|
|
11
|
-
var trie = require('@wry/trie');
|
|
12
11
|
var graphql = require('graphql');
|
|
12
|
+
var trie = require('@wry/trie');
|
|
13
13
|
|
|
14
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
15
15
|
|
|
@@ -126,6 +126,182 @@ function directiveIsNonreactive(dir) {
|
|
|
126
126
|
return dir.name.value === "nonreactive";
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
function maskFragment(data, document, cache, fragmentName) {
|
|
130
|
+
if (!cache.fragmentMatches) {
|
|
131
|
+
if (globalThis.__DEV__ !== false) {
|
|
132
|
+
warnOnImproperCacheImplementation();
|
|
133
|
+
}
|
|
134
|
+
return data;
|
|
135
|
+
}
|
|
136
|
+
var fragments = document.definitions.filter(function (node) {
|
|
137
|
+
return node.kind === graphql.Kind.FRAGMENT_DEFINITION;
|
|
138
|
+
});
|
|
139
|
+
if (typeof fragmentName === "undefined") {
|
|
140
|
+
globals.invariant(fragments.length === 1, 38, fragments.length);
|
|
141
|
+
fragmentName = fragments[0].name.value;
|
|
142
|
+
}
|
|
143
|
+
var fragment = fragments.find(function (fragment) { return fragment.name.value === fragmentName; });
|
|
144
|
+
globals.invariant(!!fragment, 39, fragmentName);
|
|
145
|
+
if (data == null) {
|
|
146
|
+
return data;
|
|
147
|
+
}
|
|
148
|
+
var context = {
|
|
149
|
+
operationType: "fragment",
|
|
150
|
+
operationName: fragment.name.value,
|
|
151
|
+
fragmentMap: utilities.createFragmentMap(utilities.getFragmentDefinitions(document)),
|
|
152
|
+
cache: cache,
|
|
153
|
+
};
|
|
154
|
+
var _a = maskSelectionSet(data, fragment.selectionSet, context), masked = _a[0], changed = _a[1];
|
|
155
|
+
if (Object.isFrozen(data)) {
|
|
156
|
+
context.disableWarnings = true;
|
|
157
|
+
utilities.maybeDeepFreeze(masked);
|
|
158
|
+
context.disableWarnings = false;
|
|
159
|
+
}
|
|
160
|
+
return changed ? masked : data;
|
|
161
|
+
}
|
|
162
|
+
function maskSelectionSet(data, selectionSet, context, path) {
|
|
163
|
+
if (Array.isArray(data)) {
|
|
164
|
+
var changed_1 = false;
|
|
165
|
+
var masked = data.map(function (item, index) {
|
|
166
|
+
if (item === null) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
var _a = maskSelectionSet(item, selectionSet, context, globalThis.__DEV__ !== false ? "".concat(path || "", "[").concat(index, "]") : void 0), masked = _a[0], itemChanged = _a[1];
|
|
170
|
+
changed_1 || (changed_1 = itemChanged);
|
|
171
|
+
return itemChanged ? masked : item;
|
|
172
|
+
});
|
|
173
|
+
return [changed_1 ? masked : data, changed_1];
|
|
174
|
+
}
|
|
175
|
+
var result = selectionSet.selections.reduce(function (_a, selection) {
|
|
176
|
+
var memo = _a[0], changed = _a[1];
|
|
177
|
+
switch (selection.kind) {
|
|
178
|
+
case graphql.Kind.FIELD: {
|
|
179
|
+
var keyName = utilities.resultKeyNameFromField(selection);
|
|
180
|
+
var childSelectionSet = selection.selectionSet;
|
|
181
|
+
memo[keyName] = data[keyName];
|
|
182
|
+
if (childSelectionSet && data[keyName] !== null) {
|
|
183
|
+
var _b = maskSelectionSet(data[keyName], childSelectionSet, context, globalThis.__DEV__ !== false ? "".concat(path || "", ".").concat(keyName) : void 0), masked = _b[0], childChanged = _b[1];
|
|
184
|
+
if (childChanged ||
|
|
185
|
+
Object.keys(masked).length !== Object.keys(data[keyName]).length) {
|
|
186
|
+
memo[keyName] = masked;
|
|
187
|
+
changed = true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return [memo, changed];
|
|
191
|
+
}
|
|
192
|
+
case graphql.Kind.INLINE_FRAGMENT: {
|
|
193
|
+
if (selection.typeCondition &&
|
|
194
|
+
!context.cache.fragmentMatches(selection, data.__typename)) {
|
|
195
|
+
return [memo, changed];
|
|
196
|
+
}
|
|
197
|
+
var _c = maskSelectionSet(data, selection.selectionSet, context, path), fragmentData = _c[0], childChanged = _c[1];
|
|
198
|
+
return [
|
|
199
|
+
tslib.__assign(tslib.__assign({}, memo), fragmentData),
|
|
200
|
+
changed || childChanged,
|
|
201
|
+
];
|
|
202
|
+
}
|
|
203
|
+
case graphql.Kind.FRAGMENT_SPREAD: {
|
|
204
|
+
var fragmentName = selection.name.value;
|
|
205
|
+
var fragment = context.fragmentMap[fragmentName] ||
|
|
206
|
+
(context.fragmentMap[fragmentName] =
|
|
207
|
+
context.cache.lookupFragment(fragmentName));
|
|
208
|
+
globals.invariant(fragment, 40, fragmentName);
|
|
209
|
+
var mode = utilities.getFragmentMaskMode(selection);
|
|
210
|
+
if (mode === "mask") {
|
|
211
|
+
return [memo, true];
|
|
212
|
+
}
|
|
213
|
+
if (globalThis.__DEV__ !== false) {
|
|
214
|
+
if (mode === "migrate") {
|
|
215
|
+
return [
|
|
216
|
+
addFieldAccessorWarnings(memo, data, fragment.selectionSet, path || "", context),
|
|
217
|
+
true,
|
|
218
|
+
];
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
var _d = maskSelectionSet(data, fragment.selectionSet, context, path), fragmentData = _d[0], changed_2 = _d[1];
|
|
222
|
+
return [tslib.__assign(tslib.__assign({}, memo), fragmentData), changed_2];
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}, [Object.create(null), false]);
|
|
226
|
+
if ("__typename" in data && !("__typename" in result[0])) {
|
|
227
|
+
result[0].__typename = data.__typename;
|
|
228
|
+
}
|
|
229
|
+
return result;
|
|
230
|
+
}
|
|
231
|
+
function addFieldAccessorWarnings(memo, data, selectionSetNode, path, context) {
|
|
232
|
+
if (Array.isArray(data)) {
|
|
233
|
+
return data.map(function (item, index) {
|
|
234
|
+
return addFieldAccessorWarnings(memo[index] || Object.create(null), item, selectionSetNode, "".concat(path, "[").concat(index, "]"), context);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
return selectionSetNode.selections.reduce(function (memo, selection) {
|
|
238
|
+
switch (selection.kind) {
|
|
239
|
+
case graphql.Kind.FIELD: {
|
|
240
|
+
var keyName = utilities.resultKeyNameFromField(selection);
|
|
241
|
+
var childSelectionSet = selection.selectionSet;
|
|
242
|
+
if (keyName in memo) {
|
|
243
|
+
return memo;
|
|
244
|
+
}
|
|
245
|
+
var value = data[keyName];
|
|
246
|
+
if (childSelectionSet) {
|
|
247
|
+
value = addFieldAccessorWarnings(memo[keyName] || Object.create(null), data[keyName], childSelectionSet, "".concat(path, ".").concat(keyName), context);
|
|
248
|
+
}
|
|
249
|
+
if (globalThis.__DEV__ !== false) {
|
|
250
|
+
addAccessorWarning(memo, value, keyName, path, context);
|
|
251
|
+
}
|
|
252
|
+
if (!(globalThis.__DEV__ !== false)) {
|
|
253
|
+
memo[keyName] = data[keyName];
|
|
254
|
+
}
|
|
255
|
+
return memo;
|
|
256
|
+
}
|
|
257
|
+
case graphql.Kind.INLINE_FRAGMENT: {
|
|
258
|
+
return addFieldAccessorWarnings(memo, data, selection.selectionSet, path, context);
|
|
259
|
+
}
|
|
260
|
+
case graphql.Kind.FRAGMENT_SPREAD: {
|
|
261
|
+
var fragment = context.fragmentMap[selection.name.value];
|
|
262
|
+
var mode = utilities.getFragmentMaskMode(selection);
|
|
263
|
+
if (mode === "mask") {
|
|
264
|
+
return memo;
|
|
265
|
+
}
|
|
266
|
+
if (mode === "unmask") {
|
|
267
|
+
var fragmentData = maskSelectionSet(data, fragment.selectionSet, context, path)[0];
|
|
268
|
+
return Object.assign(memo, fragmentData);
|
|
269
|
+
}
|
|
270
|
+
return addFieldAccessorWarnings(memo, data, fragment.selectionSet, path, context);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}, memo);
|
|
274
|
+
}
|
|
275
|
+
function addAccessorWarning(data, value, fieldName, path, context) {
|
|
276
|
+
var getValue = function () {
|
|
277
|
+
if (context.disableWarnings) {
|
|
278
|
+
return value;
|
|
279
|
+
}
|
|
280
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(41, context.operationName ?
|
|
281
|
+
"".concat(context.operationType, " '").concat(context.operationName, "'")
|
|
282
|
+
: "anonymous ".concat(context.operationType), "".concat(path, ".").concat(fieldName).replace(/^\./, ""));
|
|
283
|
+
getValue = function () { return value; };
|
|
284
|
+
return value;
|
|
285
|
+
};
|
|
286
|
+
Object.defineProperty(data, fieldName, {
|
|
287
|
+
get: function () {
|
|
288
|
+
return getValue();
|
|
289
|
+
},
|
|
290
|
+
set: function (value) {
|
|
291
|
+
getValue = function () { return value; };
|
|
292
|
+
},
|
|
293
|
+
enumerable: true,
|
|
294
|
+
configurable: true,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
var issuedWarning = false;
|
|
298
|
+
function warnOnImproperCacheImplementation() {
|
|
299
|
+
if (!issuedWarning) {
|
|
300
|
+
issuedWarning = true;
|
|
301
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(42);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
129
305
|
var ApolloCache = (function () {
|
|
130
306
|
function ApolloCache() {
|
|
131
307
|
this.assumeImmutableResults = false;
|
|
@@ -135,6 +311,9 @@ var ApolloCache = (function () {
|
|
|
135
311
|
cache: caches.WeakCache,
|
|
136
312
|
});
|
|
137
313
|
}
|
|
314
|
+
ApolloCache.prototype.lookupFragment = function (fragmentName) {
|
|
315
|
+
return null;
|
|
316
|
+
};
|
|
138
317
|
ApolloCache.prototype.batch = function (options) {
|
|
139
318
|
var _this = this;
|
|
140
319
|
var optimisticId = typeof options.optimistic === "string" ? options.optimistic
|
|
@@ -170,26 +349,36 @@ var ApolloCache = (function () {
|
|
|
170
349
|
var _this = this;
|
|
171
350
|
var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, otherOptions = tslib.__rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
|
|
172
351
|
var query = this.getFragmentDoc(fragment, fragmentName);
|
|
173
|
-
var
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
352
|
+
var id = typeof from === "undefined" || typeof from === "string" ?
|
|
353
|
+
from
|
|
354
|
+
: this.identify(from);
|
|
355
|
+
var dataMasking = !!options[Symbol.for("apollo.dataMasking")];
|
|
356
|
+
if (globalThis.__DEV__ !== false) {
|
|
357
|
+
var actualFragmentName = fragmentName || utilities.getFragmentDefinition(fragment).name.value;
|
|
358
|
+
if (!id) {
|
|
359
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(1, actualFragmentName);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
var diffOptions = tslib.__assign(tslib.__assign({}, otherOptions), { returnPartialData: true, id: id, query: query, optimistic: optimistic });
|
|
177
363
|
var latestDiff;
|
|
178
364
|
return new utilities.Observable(function (observer) {
|
|
179
365
|
return _this.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
|
|
366
|
+
var data = dataMasking ?
|
|
367
|
+
maskFragment(diff.result, fragment, _this, fragmentName)
|
|
368
|
+
: diff.result;
|
|
180
369
|
if (
|
|
181
370
|
latestDiff &&
|
|
182
|
-
equalByQuery(query, { data: latestDiff === null || latestDiff === void 0 ? void 0 : latestDiff.result }, { data:
|
|
371
|
+
equalByQuery(query, { data: latestDiff === null || latestDiff === void 0 ? void 0 : latestDiff.result }, { data: data })) {
|
|
183
372
|
return;
|
|
184
373
|
}
|
|
185
374
|
var result = {
|
|
186
|
-
data:
|
|
375
|
+
data: data,
|
|
187
376
|
complete: !!diff.complete,
|
|
188
377
|
};
|
|
189
378
|
if (diff.missing) {
|
|
190
379
|
result.missing = utilities.mergeDeepArray(diff.missing.map(function (error) { return error.missing; }));
|
|
191
380
|
}
|
|
192
|
-
latestDiff = diff;
|
|
381
|
+
latestDiff = tslib.__assign(tslib.__assign({}, diff), { result: data });
|
|
193
382
|
observer.next(result);
|
|
194
383
|
} }));
|
|
195
384
|
});
|
|
@@ -439,7 +628,7 @@ exports.EntityStore = (function () {
|
|
|
439
628
|
var incoming = typeof newer === "string" ? this.lookup((dataId = newer)) : newer;
|
|
440
629
|
if (!incoming)
|
|
441
630
|
return;
|
|
442
|
-
globals.invariant(typeof dataId === "string",
|
|
631
|
+
globals.invariant(typeof dataId === "string", 2);
|
|
443
632
|
var merged = new utilities.DeepMerger(storeObjectReconciler).merge(existing, incoming);
|
|
444
633
|
this.data[dataId] = merged;
|
|
445
634
|
if (merged !== existing) {
|
|
@@ -516,7 +705,7 @@ exports.EntityStore = (function () {
|
|
|
516
705
|
if (globalThis.__DEV__ !== false) {
|
|
517
706
|
var checkReference = function (ref) {
|
|
518
707
|
if (_this.lookup(ref.__ref) === undefined) {
|
|
519
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
708
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(3, ref);
|
|
520
709
|
return true;
|
|
521
710
|
}
|
|
522
711
|
};
|
|
@@ -542,7 +731,7 @@ exports.EntityStore = (function () {
|
|
|
542
731
|
}
|
|
543
732
|
}
|
|
544
733
|
if (seenReference && someNonReference !== undefined) {
|
|
545
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
734
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(4, someNonReference);
|
|
546
735
|
break;
|
|
547
736
|
}
|
|
548
737
|
}
|
|
@@ -1125,7 +1314,7 @@ var StoreReader = (function () {
|
|
|
1125
1314
|
else {
|
|
1126
1315
|
var fragment = utilities.getFragmentFromSelection(selection, context.lookupFragment);
|
|
1127
1316
|
if (!fragment && selection.kind === graphql.Kind.FRAGMENT_SPREAD) {
|
|
1128
|
-
throw globals.newInvariantError(
|
|
1317
|
+
throw globals.newInvariantError(10, selection.name.value);
|
|
1129
1318
|
}
|
|
1130
1319
|
if (fragment && policies.fragmentMatches(fragment, typename)) {
|
|
1131
1320
|
fragment.selectionSet.selections.forEach(workSet.add, workSet);
|
|
@@ -1208,7 +1397,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
|
|
|
1208
1397
|
if (utilities.isNonNullObject(value)) {
|
|
1209
1398
|
globals.invariant(
|
|
1210
1399
|
!utilities.isReference(value),
|
|
1211
|
-
|
|
1400
|
+
11,
|
|
1212
1401
|
getTypenameFromStoreObject(store, value),
|
|
1213
1402
|
field.name.value
|
|
1214
1403
|
);
|
|
@@ -1301,7 +1490,7 @@ function keyFieldsFnFromSpecifier(specifier) {
|
|
|
1301
1490
|
hasOwn.call(object, schemaKeyPath[0])) {
|
|
1302
1491
|
extracted = extractKeyPath(object, schemaKeyPath, extractKey);
|
|
1303
1492
|
}
|
|
1304
|
-
globals.invariant(extracted !== void 0,
|
|
1493
|
+
globals.invariant(extracted !== void 0, 5, schemaKeyPath.join("."), object);
|
|
1305
1494
|
return extracted;
|
|
1306
1495
|
}));
|
|
1307
1496
|
return "".concat(context.typename, ":").concat(JSON.stringify(keyObject));
|
|
@@ -1537,7 +1726,7 @@ var Policies = (function () {
|
|
|
1537
1726
|
var rootId = "ROOT_" + which.toUpperCase();
|
|
1538
1727
|
var old = this.rootTypenamesById[rootId];
|
|
1539
1728
|
if (typename !== old) {
|
|
1540
|
-
globals.invariant(!old || old === which,
|
|
1729
|
+
globals.invariant(!old || old === which, 6, which);
|
|
1541
1730
|
if (old)
|
|
1542
1731
|
delete this.rootIdsByTypename[old];
|
|
1543
1732
|
this.rootIdsByTypename[typename] = rootId;
|
|
@@ -1634,7 +1823,7 @@ var Policies = (function () {
|
|
|
1634
1823
|
if (supertypeSet.has(supertype)) {
|
|
1635
1824
|
if (!typenameSupertypeSet.has(supertype)) {
|
|
1636
1825
|
if (checkingFuzzySubtypes) {
|
|
1637
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
1826
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(7, typename, supertype);
|
|
1638
1827
|
}
|
|
1639
1828
|
typenameSupertypeSet.add(supertype);
|
|
1640
1829
|
}
|
|
@@ -1797,7 +1986,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
1797
1986
|
}
|
|
1798
1987
|
}
|
|
1799
1988
|
if (globalThis.__DEV__ !== false && options.from === void 0) {
|
|
1800
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
1989
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(8, utilities.stringifyForDisplay(Array.from(readFieldArgs)));
|
|
1801
1990
|
}
|
|
1802
1991
|
if (void 0 === options.variables) {
|
|
1803
1992
|
options.variables = variables;
|
|
@@ -1807,7 +1996,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
1807
1996
|
function makeMergeObjectsFunction(store) {
|
|
1808
1997
|
return function mergeObjects(existing, incoming) {
|
|
1809
1998
|
if (utilities.isArray(existing) || utilities.isArray(incoming)) {
|
|
1810
|
-
throw globals.newInvariantError(
|
|
1999
|
+
throw globals.newInvariantError(9);
|
|
1811
2000
|
}
|
|
1812
2001
|
if (utilities.isNonNullObject(existing) && utilities.isNonNullObject(incoming)) {
|
|
1813
2002
|
var eType = store.getFieldValue(existing, "__typename");
|
|
@@ -1867,7 +2056,7 @@ var StoreWriter = (function () {
|
|
|
1867
2056
|
context: context,
|
|
1868
2057
|
});
|
|
1869
2058
|
if (!utilities.isReference(ref)) {
|
|
1870
|
-
throw globals.newInvariantError(
|
|
2059
|
+
throw globals.newInvariantError(12, result);
|
|
1871
2060
|
}
|
|
1872
2061
|
context.incomingById.forEach(function (_a, dataId) {
|
|
1873
2062
|
var storeObject = _a.storeObject, mergeTree = _a.mergeTree, fieldNodeSet = _a.fieldNodeSet;
|
|
@@ -1975,7 +2164,7 @@ var StoreWriter = (function () {
|
|
|
1975
2164
|
!context.deferred &&
|
|
1976
2165
|
!utilities.addTypenameToDocument.added(field) &&
|
|
1977
2166
|
!policies.getReadFunction(typename, field.name.value)) {
|
|
1978
|
-
globalThis.__DEV__ !== false && globals.invariant.error(
|
|
2167
|
+
globalThis.__DEV__ !== false && globals.invariant.error(13, utilities.resultKeyNameFromField(field), result);
|
|
1979
2168
|
}
|
|
1980
2169
|
});
|
|
1981
2170
|
try {
|
|
@@ -2082,7 +2271,7 @@ var StoreWriter = (function () {
|
|
|
2082
2271
|
else {
|
|
2083
2272
|
var fragment = utilities.getFragmentFromSelection(selection, context.lookupFragment);
|
|
2084
2273
|
if (!fragment && selection.kind === graphql.Kind.FRAGMENT_SPREAD) {
|
|
2085
|
-
throw globals.newInvariantError(
|
|
2274
|
+
throw globals.newInvariantError(14, selection.name.value);
|
|
2086
2275
|
}
|
|
2087
2276
|
if (fragment &&
|
|
2088
2277
|
policies.fragmentMatches(fragment, typename, result, context.variables)) {
|
|
@@ -2222,7 +2411,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
2222
2411
|
}
|
|
2223
2412
|
});
|
|
2224
2413
|
}
|
|
2225
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
2414
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(15, fieldName, parentType, childTypenames.length ?
|
|
2226
2415
|
"either ensure all objects of type " +
|
|
2227
2416
|
childTypenames.join(" and ") +
|
|
2228
2417
|
" have an ID or a custom merge function, or "
|
|
@@ -2496,6 +2685,13 @@ var InMemoryCache = (function (_super) {
|
|
|
2496
2685
|
InMemoryCache.prototype.transformDocument = function (document) {
|
|
2497
2686
|
return this.addTypenameToDocument(this.addFragmentsToDocument(document));
|
|
2498
2687
|
};
|
|
2688
|
+
InMemoryCache.prototype.fragmentMatches = function (fragment, typename) {
|
|
2689
|
+
return this.policies.fragmentMatches(fragment, typename);
|
|
2690
|
+
};
|
|
2691
|
+
InMemoryCache.prototype.lookupFragment = function (fragmentName) {
|
|
2692
|
+
var _a;
|
|
2693
|
+
return ((_a = this.config.fragments) === null || _a === void 0 ? void 0 : _a.lookup(fragmentName)) || null;
|
|
2694
|
+
};
|
|
2499
2695
|
InMemoryCache.prototype.broadcastWatches = function (options) {
|
|
2500
2696
|
var _this = this;
|
|
2501
2697
|
if (!this.txCount) {
|