@apollo/client 4.3.0-alpha.5 → 4.3.0-alpha.7
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 +22 -0
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +28 -6
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +3 -3
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/core/ObservableQuery.cjs +175 -62
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +4 -7
- package/__cjs/core/QueryInfo.cjs +13 -136
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +2 -26
- package/__cjs/core/QueryManager.cjs +26 -25
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/RefetchEventManager.cjs +3 -3
- package/__cjs/invariantErrorCodes.cjs +57 -32
- package/__cjs/utilities/internal/index.cjs +3 -1
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +1 -0
- package/__cjs/utilities/internal/toDiffWithDataState.cjs +20 -0
- package/__cjs/utilities/internal/toDiffWithDataState.cjs.map +1 -0
- package/__cjs/utilities/internal/toDiffWithDataState.d.cts +8 -0
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.js +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +28 -6
- 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/writeToStore.js +4 -4
- package/core/ObservableQuery.d.ts +4 -7
- package/core/ObservableQuery.js +172 -63
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +3 -27
- package/core/QueryInfo.js +14 -137
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +26 -25
- package/core/QueryManager.js.map +1 -1
- package/core/RefetchEventManager.js +3 -3
- package/invariantErrorCodes.js +57 -32
- package/package.json +1 -1
- package/utilities/internal/index.d.ts +1 -0
- package/utilities/internal/index.js +1 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/toDiffWithDataState.d.ts +8 -0
- package/utilities/internal/toDiffWithDataState.js +17 -0
- package/utilities/internal/toDiffWithDataState.js.map +1 -0
- package/version.js +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toDiffWithDataState.cjs","sources":["../../../../src/utilities/internal/toDiffWithDataState.ts"],"sourcesContent":["import type { Cache } from \"@apollo/client/cache\";\n\n/** @internal */\nexport function toDiffWithDataState<TData>(\n diff: Cache.DiffResult<TData> | Cache.InternalDiffResultWithDataState<TData>\n): Cache.InternalDiffResultWithDataState<TData> {\n if (\"dataState\" in diff) {\n return diff;\n }\n\n return {\n ...diff,\n dataState:\n diff.complete ? \"complete\"\n : diff.result === null ? \"empty\"\n : \"partial\",\n } as Cache.InternalDiffResultWithDataState<TData>;\n}\n"],"names":[],"mappings":";;AAGA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;;;;;AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAgB,CAAhB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAmC,CACjC,CADF,CAAA,CAAA,CAC8E,EAD9E;IAGE,CAAF,EAAA,CAAM,CAAN,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAqB,CAArB,CAAA,CAAA,CAAyB,EAAE;QACvB,CAAJ,CAAA,CAAA,CAAA,CAAA,EAAW,CAAX,CAAA,CAAA,CAAe;IACb;IAEA,CAAF,CAAA,CAAA,CAAA,CAAA,EAAS;QACL,CAAJ,CAAA,CAAO,CAAP,CAAA,CAAA,CAAW;QACP,CAAJ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,EACP,CADN,CAAA,CAAA,CACU,CAAC,CADX,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EACoB,EAAE,CADtB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;YAEM,EAAE,CAAR,CAAA,CAAA,CAAY,CAAC,CAAb,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAwB,CAAxB,CAAA,CAAA,EAA6B,EAAE,CAA/B,CAAA,CAAA,CAAA,CAAA,CAAA;gBACM,EAAE,CAAR,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiB;IACjB,CAAmD;AACnD;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Cache } from "@apollo/client/cache";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
6
|
+
*/
|
|
7
|
+
export declare function toDiffWithDataState<TData>(diff: Cache.DiffResult<TData> | Cache.InternalDiffResultWithDataState<TData>): Cache.InternalDiffResultWithDataState<TData>;
|
|
8
|
+
//# sourceMappingURL=toDiffWithDataState.d.cts.map
|
package/__cjs/version.cjs
CHANGED
package/cache/core/cache.js
CHANGED
|
@@ -140,7 +140,7 @@ export class ApolloCache {
|
|
|
140
140
|
if (__DEV__) {
|
|
141
141
|
const actualFragmentName = fragmentName || getFragmentDefinition(fragment).name.value;
|
|
142
142
|
if (id === undefined) {
|
|
143
|
-
__DEV__ && invariant.warn(
|
|
143
|
+
__DEV__ && invariant.warn(122, actualFragmentName);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
return id;
|
|
@@ -73,7 +73,7 @@ export class EntityStore {
|
|
|
73
73
|
// then there are no fields to be merged, so we're done.
|
|
74
74
|
if (!incoming)
|
|
75
75
|
return;
|
|
76
|
-
invariant(typeof dataId === "string",
|
|
76
|
+
invariant(typeof dataId === "string", 106);
|
|
77
77
|
// Parse all scalars before merging so that the storeObjectReconciler can
|
|
78
78
|
// deep compare the parsed value with the existing value
|
|
79
79
|
incoming = this.coerceStoreObject(incoming, (scalar, value) => scalar.coerceToParsed(value), incoming.__typename ||
|
|
@@ -180,7 +180,7 @@ export class EntityStore {
|
|
|
180
180
|
if (__DEV__) {
|
|
181
181
|
const checkReference = (ref) => {
|
|
182
182
|
if (this.lookup(ref.__ref) === undefined) {
|
|
183
|
-
__DEV__ && invariant.warn(
|
|
183
|
+
__DEV__ && invariant.warn(107, ref);
|
|
184
184
|
return true;
|
|
185
185
|
}
|
|
186
186
|
};
|
|
@@ -209,7 +209,7 @@ export class EntityStore {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
if (seenReference && someNonReference !== undefined) {
|
|
212
|
-
__DEV__ && invariant.warn(
|
|
212
|
+
__DEV__ && invariant.warn(108, someNonReference);
|
|
213
213
|
break;
|
|
214
214
|
}
|
|
215
215
|
}
|
|
@@ -34,7 +34,7 @@ export function keyFieldsFnFromSpecifier(specifier) {
|
|
|
34
34
|
// context.readField for this extraction.
|
|
35
35
|
extracted = extractKeyPath(object, schemaKeyPath, extractKey);
|
|
36
36
|
}
|
|
37
|
-
invariant(extracted !== void 0,
|
|
37
|
+
invariant(extracted !== void 0, 109, schemaKeyPath.join("."), object);
|
|
38
38
|
return extracted;
|
|
39
39
|
}));
|
|
40
40
|
return `${context.typename}:${JSON.stringify(keyObject)}`;
|
|
@@ -185,13 +185,32 @@ export class Policies {
|
|
|
185
185
|
}
|
|
186
186
|
const incoming = fields[fieldName];
|
|
187
187
|
if (typeof incoming === "function") {
|
|
188
|
-
existing.
|
|
188
|
+
if (existing.scalar) {
|
|
189
|
+
if (__DEV__) {
|
|
190
|
+
warnAboutScalarConfig(typename, fieldName, existing.scalar, "read");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
existing.read = incoming;
|
|
195
|
+
}
|
|
189
196
|
}
|
|
190
197
|
else {
|
|
191
|
-
|
|
198
|
+
let { keyArgs, read, merge, scalar } = incoming;
|
|
192
199
|
if (scalar) {
|
|
193
200
|
existing.scalar = scalar;
|
|
194
201
|
}
|
|
202
|
+
if (existing.scalar) {
|
|
203
|
+
if (__DEV__) {
|
|
204
|
+
if (read !== undefined || existing.read !== undefined) {
|
|
205
|
+
warnAboutScalarConfig(typename, fieldName, existing.scalar, "read");
|
|
206
|
+
}
|
|
207
|
+
if (merge !== undefined || existing.merge !== undefined) {
|
|
208
|
+
warnAboutScalarConfig(typename, fieldName, existing.scalar, "merge");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
existing.read = read = undefined;
|
|
212
|
+
existing.merge = merge = undefined;
|
|
213
|
+
}
|
|
195
214
|
existing.keyFn =
|
|
196
215
|
// Pass false to disable argument-based differentiation of
|
|
197
216
|
// field identities.
|
|
@@ -223,7 +242,7 @@ export class Policies {
|
|
|
223
242
|
const rootId = "ROOT_" + which.toUpperCase();
|
|
224
243
|
const old = this.rootTypenamesById[rootId];
|
|
225
244
|
if (typename !== old) {
|
|
226
|
-
invariant(!old || old === which,
|
|
245
|
+
invariant(!old || old === which, 110, which);
|
|
227
246
|
// First, delete any old __typename associated with this rootId from
|
|
228
247
|
// rootIdsByTypename.
|
|
229
248
|
if (old)
|
|
@@ -366,7 +385,7 @@ export class Policies {
|
|
|
366
385
|
if (supertypeSet.has(supertype)) {
|
|
367
386
|
if (!typenameSupertypeSet.has(supertype)) {
|
|
368
387
|
if (checkingFuzzySubtypes) {
|
|
369
|
-
__DEV__ && invariant.warn(
|
|
388
|
+
__DEV__ && invariant.warn(111, typename, supertype);
|
|
370
389
|
}
|
|
371
390
|
// Record positive results for faster future lookup.
|
|
372
391
|
// Unfortunately, we cannot safely cache negative results,
|
|
@@ -622,7 +641,7 @@ export function normalizeReadFieldOptions(readFieldArgs, objectOrReference, vari
|
|
|
622
641
|
}
|
|
623
642
|
}
|
|
624
643
|
if (__DEV__ && options.from === void 0) {
|
|
625
|
-
__DEV__ && invariant.warn(
|
|
644
|
+
__DEV__ && invariant.warn(112, stringifyForDisplay(Array.from(readFieldArgs)));
|
|
626
645
|
}
|
|
627
646
|
if (void 0 === options.variables) {
|
|
628
647
|
options.variables = variables;
|
|
@@ -632,7 +651,7 @@ export function normalizeReadFieldOptions(readFieldArgs, objectOrReference, vari
|
|
|
632
651
|
function makeMergeObjectsFunction(store) {
|
|
633
652
|
return function mergeObjects(existing, incoming) {
|
|
634
653
|
if (isArray(existing) || isArray(incoming)) {
|
|
635
|
-
throw newInvariantError(
|
|
654
|
+
throw newInvariantError(113);
|
|
636
655
|
}
|
|
637
656
|
// These dynamic checks are necessary because the parameters of a
|
|
638
657
|
// custom merge function can easily have the any type, so the type
|
|
@@ -668,4 +687,7 @@ function makeMergeObjectsFunction(store) {
|
|
|
668
687
|
return incoming;
|
|
669
688
|
};
|
|
670
689
|
}
|
|
690
|
+
function warnAboutScalarConfig(typename, fieldName, scalar, kind) {
|
|
691
|
+
__DEV__ && invariant.warn(114, `${typename}.${fieldName}`, scalar, kind);
|
|
692
|
+
}
|
|
671
693
|
//# sourceMappingURL=policies.js.map
|