@apollo/client 4.1.0-alpha.8 → 4.1.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/CHANGELOG.md +67 -0
- package/__cjs/cache/core/cache.cjs +64 -24
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +47 -0
- package/__cjs/cache/core/types/Cache.d.cts +39 -0
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs +47 -0
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +47 -0
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +76 -17
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +33 -6
- package/__cjs/cache/inmemory/readFromStore.cjs +3 -3
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/types.d.cts +3 -0
- package/__cjs/cache/inmemory/writeToStore.cjs +24 -9
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +1 -1
- package/__cjs/core/ApolloClient.cjs +14 -14
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +21 -1
- package/__cjs/core/ObservableQuery.cjs +22 -8
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +1 -0
- package/__cjs/core/QueryInfo.cjs +9 -1
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +4 -3
- package/__cjs/core/QueryManager.cjs +40 -20
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +19 -2
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs +39 -0
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +1 -0
- package/__cjs/incremental/types.d.cts +9 -0
- package/__cjs/invariantErrorCodes.cjs +39 -33
- package/__cjs/link/error/index.cjs +1 -1
- package/__cjs/link/error/index.cjs.map +1 -1
- package/__cjs/link/error/index.d.cts +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.cjs +1 -0
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.cjs +7 -4
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs +2 -0
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.cjs +41 -1
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/utilities/internal/checkDocument.cjs +2 -4
- package/__cjs/utilities/internal/checkDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/constants.cjs +26 -0
- package/__cjs/utilities/internal/constants.cjs.map +1 -0
- package/__cjs/utilities/internal/constants.d.cts +23 -0
- package/__cjs/utilities/internal/index.cjs +7 -1
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +4 -0
- package/__cjs/utilities/internal/mapObservableFragment.cjs +27 -0
- package/__cjs/utilities/internal/mapObservableFragment.cjs.map +1 -0
- package/__cjs/utilities/internal/mapObservableFragment.d.cts +3 -0
- package/__cjs/utilities/internal/memoize.cjs +31 -0
- package/__cjs/utilities/internal/memoize.cjs.map +1 -0
- package/__cjs/utilities/internal/memoize.d.cts +8 -0
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.cjs +61 -0
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.cjs.map +1 -0
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.d.cts +11 -0
- package/__cjs/utilities/internal/ponyfills/index.cjs +6 -0
- package/__cjs/utilities/internal/ponyfills/index.cjs.map +1 -0
- package/__cjs/utilities/internal/ponyfills/index.d.cts +3 -0
- package/__cjs/utilities/internal/ponyfills/index.react-native.cjs +6 -0
- package/__cjs/utilities/internal/ponyfills/index.react-native.cjs.map +1 -0
- package/__cjs/utilities/internal/ponyfills/index.react-native.d.cts +2 -0
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.cjs +3 -0
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.cjs.map +1 -0
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.d.cts +12 -0
- package/__cjs/utilities/internal/types/StreamInfoTrie.cjs +3 -0
- package/__cjs/utilities/internal/types/StreamInfoTrie.cjs.map +1 -0
- package/__cjs/utilities/internal/types/StreamInfoTrie.d.cts +16 -0
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/cache/core/cache.d.ts +47 -0
- package/cache/core/cache.js +65 -25
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +39 -0
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/index.d.ts +1 -1
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +47 -0
- package/cache/inmemory/inMemoryCache.js +47 -0
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.d.ts +33 -6
- package/cache/inmemory/policies.js +65 -7
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +3 -3
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +3 -0
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +1 -1
- package/cache/inmemory/writeToStore.js +26 -11
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +21 -1
- package/core/ApolloClient.js +15 -15
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +1 -0
- package/core/ObservableQuery.js +23 -9
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +4 -3
- package/core/QueryInfo.js +10 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +19 -2
- package/core/QueryManager.js +41 -21
- package/core/QueryManager.js.map +1 -1
- package/incremental/handlers/graphql17Alpha9.d.ts +1 -0
- package/incremental/handlers/graphql17Alpha9.js +40 -1
- package/incremental/handlers/graphql17Alpha9.js.map +1 -1
- package/incremental/types.d.ts +9 -0
- package/incremental/types.js.map +1 -1
- package/invariantErrorCodes.js +39 -33
- package/legacyEntryPoints/utilities/internal/ponyfills/index.d.ts +1 -0
- package/legacyEntryPoints/utilities/internal/ponyfills/index.js +1 -0
- package/legacyEntryPoints/utilities/internal/ponyfills/ponyfills.cjs +1 -0
- package/legacyEntryPoints/utilities/internal/ponyfills/ponyfills.d.cts +1 -0
- package/link/error/index.d.ts +1 -1
- package/link/error/index.js +1 -1
- package/link/error/index.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/package.json +15 -1
- package/react/hooks/useLazyQuery.js +2 -1
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useQuery.js +8 -5
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +2 -0
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.js +2 -1
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useQuery.js +9 -5
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.js +3 -1
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.js +41 -1
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/utilities/internal/checkDocument.js +2 -4
- package/utilities/internal/checkDocument.js.map +1 -1
- package/utilities/internal/constants.d.ts +23 -0
- package/utilities/internal/constants.js +23 -0
- package/utilities/internal/constants.js.map +1 -0
- package/utilities/internal/index.d.ts +4 -0
- package/utilities/internal/index.js +2 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/mapObservableFragment.d.ts +3 -0
- package/utilities/internal/mapObservableFragment.js +24 -0
- package/utilities/internal/mapObservableFragment.js.map +1 -0
- package/utilities/internal/memoize.d.ts +8 -0
- package/utilities/internal/memoize.js +28 -0
- package/utilities/internal/memoize.js.map +1 -0
- package/utilities/internal/ponyfills/FinalizationRegistry.d.ts +11 -0
- package/utilities/internal/ponyfills/FinalizationRegistry.js +57 -0
- package/utilities/internal/ponyfills/FinalizationRegistry.js.map +1 -0
- package/utilities/internal/ponyfills/index.d.ts +3 -0
- package/utilities/internal/ponyfills/index.js +3 -0
- package/utilities/internal/ponyfills/index.js.map +1 -0
- package/utilities/internal/ponyfills/index.react-native.d.ts +2 -0
- package/utilities/internal/ponyfills/index.react-native.js +2 -0
- package/utilities/internal/ponyfills/index.react-native.js.map +1 -0
- package/utilities/internal/types/ExtensionsWithStreamDetails.d.ts +12 -0
- package/utilities/internal/types/ExtensionsWithStreamDetails.js +2 -0
- package/utilities/internal/types/ExtensionsWithStreamDetails.js.map +1 -0
- package/utilities/internal/types/StreamInfoTrie.d.ts +16 -0
- package/utilities/internal/types/StreamInfoTrie.js +2 -0
- package/utilities/internal/types/StreamInfoTrie.js.map +1 -0
- package/version.js +1 -1
- package/version.js.map +1 -1
|
@@ -4,19 +4,21 @@ const {
|
|
|
4
4
|
} = require("@apollo/client/utilities/environment");
|
|
5
5
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.Policies = void 0;
|
|
7
|
+
exports.Policies = exports.defaultStreamFieldMergeFn = void 0;
|
|
8
8
|
exports.normalizeReadFieldOptions = normalizeReadFieldOptions;
|
|
9
|
+
const equality_1 = require("@wry/equality");
|
|
9
10
|
const masking_1 = require("@apollo/client/masking");
|
|
10
11
|
const utilities_1 = require("@apollo/client/utilities");
|
|
11
12
|
const environment_1 = require("@apollo/client/utilities/environment");
|
|
12
13
|
const internal_1 = require("@apollo/client/utilities/internal");
|
|
14
|
+
const internal_2 = require("@apollo/client/utilities/internal");
|
|
13
15
|
const invariant_1 = require("@apollo/client/utilities/invariant");
|
|
14
16
|
const helpers_js_1 = require("./helpers.cjs");
|
|
15
17
|
const key_extractor_js_1 = require("./key-extractor.cjs");
|
|
16
18
|
const reactiveVars_js_1 = require("./reactiveVars.cjs");
|
|
17
19
|
function argsFromFieldSpecifier(spec) {
|
|
18
20
|
return (spec.args !== void 0 ? spec.args
|
|
19
|
-
: spec.field ? (0,
|
|
21
|
+
: spec.field ? (0, internal_2.argumentsObjectFromField)(spec.field, spec.variables)
|
|
20
22
|
: null);
|
|
21
23
|
}
|
|
22
24
|
const nullKeyFieldsFn = () => void 0;
|
|
@@ -25,6 +27,21 @@ const simpleKeyArgsFn = (_args, context) => context.fieldName;
|
|
|
25
27
|
// merge:false in a field policy.
|
|
26
28
|
const mergeTrueFn = (existing, incoming, { mergeObjects }) => mergeObjects(existing, incoming);
|
|
27
29
|
const mergeFalseFn = (_, incoming) => incoming;
|
|
30
|
+
const defaultStreamFieldMergeFn = (existing, incoming, { streamFieldInfo, existingData }) => {
|
|
31
|
+
if (!existing && !existingData) {
|
|
32
|
+
return incoming;
|
|
33
|
+
}
|
|
34
|
+
const results = [];
|
|
35
|
+
const previous = existing ?? existingData;
|
|
36
|
+
const length = streamFieldInfo?.isLastChunk ?
|
|
37
|
+
incoming.length
|
|
38
|
+
: Math.max(previous.length, incoming.length);
|
|
39
|
+
for (let i = 0; i < length; i++) {
|
|
40
|
+
results[i] = incoming[i] === undefined ? previous[i] : incoming[i];
|
|
41
|
+
}
|
|
42
|
+
return results;
|
|
43
|
+
};
|
|
44
|
+
exports.defaultStreamFieldMergeFn = defaultStreamFieldMergeFn;
|
|
28
45
|
class Policies {
|
|
29
46
|
config;
|
|
30
47
|
typePolicies = {};
|
|
@@ -94,7 +111,7 @@ class Policies {
|
|
|
94
111
|
masking_1.disableWarningsSlot.withValue(true, () => {
|
|
95
112
|
while (keyFn) {
|
|
96
113
|
const specifierOrId = keyFn({ ...object, ...storeObject }, context);
|
|
97
|
-
if ((0,
|
|
114
|
+
if ((0, internal_2.isArray)(specifierOrId)) {
|
|
98
115
|
keyFn = (0, key_extractor_js_1.keyFieldsFnFromSpecifier)(specifierOrId);
|
|
99
116
|
}
|
|
100
117
|
else {
|
|
@@ -159,7 +176,7 @@ class Policies {
|
|
|
159
176
|
keyFields === false ? nullKeyFieldsFn
|
|
160
177
|
// Pass an array of strings to use those fields to compute a
|
|
161
178
|
// composite ID for objects of this typename.
|
|
162
|
-
: (0,
|
|
179
|
+
: (0, internal_2.isArray)(keyFields) ? (0, key_extractor_js_1.keyFieldsFnFromSpecifier)(keyFields)
|
|
163
180
|
// Pass a function to take full control over identification.
|
|
164
181
|
: typeof keyFields === "function" ? keyFields
|
|
165
182
|
// Leave existing.keyFn unchanged if above cases fail.
|
|
@@ -187,7 +204,7 @@ class Policies {
|
|
|
187
204
|
keyArgs === false ? simpleKeyArgsFn
|
|
188
205
|
// Pass an array of strings to use named arguments to
|
|
189
206
|
// compute a composite identity for the field.
|
|
190
|
-
: (0,
|
|
207
|
+
: (0, internal_2.isArray)(keyArgs) ? (0, key_extractor_js_1.keyArgsFnFromSpecifier)(keyArgs)
|
|
191
208
|
// Pass a function to take full control over field identity.
|
|
192
209
|
: typeof keyArgs === "function" ? keyArgs
|
|
193
210
|
// Leave existing.keyFn unchanged if above cases fail.
|
|
@@ -212,7 +229,7 @@ class Policies {
|
|
|
212
229
|
const rootId = "ROOT_" + which.toUpperCase();
|
|
213
230
|
const old = this.rootTypenamesById[rootId];
|
|
214
231
|
if (typename !== old) {
|
|
215
|
-
(0, invariant_1.invariant)(!old || old === which,
|
|
232
|
+
(0, invariant_1.invariant)(!old || old === which, 103, which);
|
|
216
233
|
// First, delete any old __typename associated with this rootId from
|
|
217
234
|
// rootIdsByTypename.
|
|
218
235
|
if (old)
|
|
@@ -355,7 +372,7 @@ class Policies {
|
|
|
355
372
|
if (supertypeSet.has(supertype)) {
|
|
356
373
|
if (!typenameSupertypeSet.has(supertype)) {
|
|
357
374
|
if (checkingFuzzySubtypes) {
|
|
358
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
375
|
+
__DEV__ && invariant_1.invariant.warn(104, typename, supertype);
|
|
359
376
|
}
|
|
360
377
|
// Record positive results for faster future lookup.
|
|
361
378
|
// Unfortunately, we cannot safely cache negative results,
|
|
@@ -414,7 +431,7 @@ class Policies {
|
|
|
414
431
|
const args = argsFromFieldSpecifier(fieldSpec);
|
|
415
432
|
while (keyFn) {
|
|
416
433
|
const specifierOrString = keyFn(args, context);
|
|
417
|
-
if ((0,
|
|
434
|
+
if ((0, internal_2.isArray)(specifierOrString)) {
|
|
418
435
|
keyFn = (0, key_extractor_js_1.keyArgsFnFromSpecifier)(specifierOrString);
|
|
419
436
|
}
|
|
420
437
|
else {
|
|
@@ -428,8 +445,8 @@ class Policies {
|
|
|
428
445
|
if (storeFieldName === void 0) {
|
|
429
446
|
storeFieldName =
|
|
430
447
|
fieldSpec.field ?
|
|
431
|
-
(0,
|
|
432
|
-
: (0,
|
|
448
|
+
(0, internal_2.storeKeyNameFromField)(fieldSpec.field, fieldSpec.variables)
|
|
449
|
+
: (0, internal_2.getStoreKeyName)(fieldName, argsFromFieldSpecifier(fieldSpec));
|
|
433
450
|
}
|
|
434
451
|
// Returning false from a keyArgs function is like configuring
|
|
435
452
|
// keyArgs: false, but more dynamic.
|
|
@@ -484,7 +501,9 @@ class Policies {
|
|
|
484
501
|
}
|
|
485
502
|
return merge;
|
|
486
503
|
}
|
|
487
|
-
runMergeFunction(existing, incoming, { field, typename, merge }, context, storage) {
|
|
504
|
+
runMergeFunction(existing, incoming, { field, typename, merge, path }, context, storage) {
|
|
505
|
+
// Preserve the value in case `context.overwrite` is set.
|
|
506
|
+
const existingData = existing;
|
|
488
507
|
if (merge === mergeTrueFn) {
|
|
489
508
|
// Instead of going to the trouble of creating a full
|
|
490
509
|
// FieldFunctionOptions object and calling mergeTrueFn, we can
|
|
@@ -502,7 +521,18 @@ class Policies {
|
|
|
502
521
|
if (context.overwrite) {
|
|
503
522
|
existing = void 0;
|
|
504
523
|
}
|
|
505
|
-
|
|
524
|
+
const streamInfo = context.extensions?.[internal_1.streamInfoSymbol]
|
|
525
|
+
?.deref()
|
|
526
|
+
?.peekArray(path);
|
|
527
|
+
if (streamInfo) {
|
|
528
|
+
const { current, previous } = streamInfo;
|
|
529
|
+
if (previous &&
|
|
530
|
+
(0, equality_1.equal)(previous.incoming, incoming) &&
|
|
531
|
+
(0, equality_1.equal)(previous.streamFieldInfo, current)) {
|
|
532
|
+
return previous.result;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
const result = merge(existing, incoming, makeMergeFieldFunctionOptions(this,
|
|
506
536
|
// Unlike options.readField for read functions, we do not fall
|
|
507
537
|
// back to the current object if no foreignObjOrRef is provided,
|
|
508
538
|
// because it's not clear what the current object should be for
|
|
@@ -519,7 +549,16 @@ class Policies {
|
|
|
519
549
|
fieldName: field.name.value,
|
|
520
550
|
field,
|
|
521
551
|
variables: context.variables,
|
|
522
|
-
|
|
552
|
+
path,
|
|
553
|
+
}, context, storage || {}, existingData));
|
|
554
|
+
if (streamInfo) {
|
|
555
|
+
streamInfo.previous = {
|
|
556
|
+
incoming,
|
|
557
|
+
streamFieldInfo: streamInfo.current,
|
|
558
|
+
result,
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
return result;
|
|
523
562
|
}
|
|
524
563
|
}
|
|
525
564
|
exports.Policies = Policies;
|
|
@@ -545,6 +584,26 @@ function makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, contex
|
|
|
545
584
|
mergeObjects: makeMergeObjectsFunction(context.store),
|
|
546
585
|
};
|
|
547
586
|
}
|
|
587
|
+
function makeMergeFieldFunctionOptions(policies, objectOrReference, fieldSpec, context, storage, existingData) {
|
|
588
|
+
const options = {
|
|
589
|
+
...makeFieldFunctionOptions(policies, objectOrReference, fieldSpec, context, storage),
|
|
590
|
+
extensions: context.extensions,
|
|
591
|
+
existingData,
|
|
592
|
+
};
|
|
593
|
+
const extensions = context.extensions;
|
|
594
|
+
if (extensions && internal_1.streamInfoSymbol in extensions) {
|
|
595
|
+
const { [internal_1.streamInfoSymbol]: streamInfo, ...otherExtensions } = extensions;
|
|
596
|
+
const streamFieldInfo = streamInfo?.deref()?.peekArray(fieldSpec.path);
|
|
597
|
+
if (streamFieldInfo) {
|
|
598
|
+
options.streamFieldInfo = streamFieldInfo.current;
|
|
599
|
+
}
|
|
600
|
+
// If the only key in `extensions` was the stream details key, we didn't
|
|
601
|
+
// receive any remote extensions, so we reset extensions back to undefined
|
|
602
|
+
options.extensions =
|
|
603
|
+
Object.keys(otherExtensions).length === 0 ? undefined : otherExtensions;
|
|
604
|
+
}
|
|
605
|
+
return options;
|
|
606
|
+
}
|
|
548
607
|
function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables) {
|
|
549
608
|
const { 0: fieldNameOrOptions, 1: from, length: argc } = readFieldArgs;
|
|
550
609
|
let options;
|
|
@@ -566,7 +625,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
566
625
|
}
|
|
567
626
|
}
|
|
568
627
|
if (environment_1.__DEV__ && options.from === void 0) {
|
|
569
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
628
|
+
__DEV__ && invariant_1.invariant.warn(105, (0, internal_2.stringifyForDisplay)(Array.from(readFieldArgs)));
|
|
570
629
|
}
|
|
571
630
|
if (void 0 === options.variables) {
|
|
572
631
|
options.variables = variables;
|
|
@@ -575,14 +634,14 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
575
634
|
}
|
|
576
635
|
function makeMergeObjectsFunction(store) {
|
|
577
636
|
return function mergeObjects(existing, incoming) {
|
|
578
|
-
if ((0,
|
|
579
|
-
throw (0, invariant_1.newInvariantError)(
|
|
637
|
+
if ((0, internal_2.isArray)(existing) || (0, internal_2.isArray)(incoming)) {
|
|
638
|
+
throw (0, invariant_1.newInvariantError)(106);
|
|
580
639
|
}
|
|
581
640
|
// These dynamic checks are necessary because the parameters of a
|
|
582
641
|
// custom merge function can easily have the any type, so the type
|
|
583
642
|
// system cannot always enforce the StoreObject | Reference parameter
|
|
584
643
|
// types of options.mergeObjects.
|
|
585
|
-
if ((0,
|
|
644
|
+
if ((0, internal_2.isNonNullObject)(existing) && (0, internal_2.isNonNullObject)(incoming)) {
|
|
586
645
|
const eType = store.getFieldValue(existing, "__typename");
|
|
587
646
|
const iType = store.getFieldValue(incoming, "__typename");
|
|
588
647
|
const typesDiffer = eType && iType && eType !== iType;
|