@isograph/react 0.0.0-main-e403ba82 → 0.0.0-main-4adb5045
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/.turbo/turbo-compile-libs.log +1 -1
- package/dist/core/areEqualWithDeepComparison.d.ts.map +1 -1
- package/dist/core/areEqualWithDeepComparison.js +2 -5
- package/dist/core/cache.js +4 -4
- package/dist/core/check.js +5 -5
- package/dist/core/garbageCollection.js +3 -3
- package/dist/core/optimisticProxy.d.ts.map +1 -1
- package/dist/core/optimisticProxy.js +22 -21
- package/dist/core/read.js +4 -4
- package/dist/loadable-hooks/useConnectionSpecPagination.js +1 -1
- package/dist/loadable-hooks/useSkipLimitPagination.js +1 -1
- package/package.json +4 -4
- package/src/core/areEqualWithDeepComparison.ts +2 -6
- package/src/core/cache.ts +4 -4
- package/src/core/check.ts +5 -5
- package/src/core/garbageCollection.ts +3 -3
- package/src/core/optimisticProxy.ts +25 -21
- package/src/core/read.ts +4 -4
- package/src/loadable-hooks/useConnectionSpecPagination.ts +1 -1
- package/src/loadable-hooks/useSkipLimitPagination.ts +1 -1
- package/src/tests/optimisticProxy.test.ts +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
../.. | WARN Unsupported engine: wanted: {"node":"22.9.0"} (current: {"node":"v22.21.1","pnpm":"10.15.0"})
|
|
2
2
|
|
|
3
|
-
> @isograph/react@0.0.0-main-
|
|
3
|
+
> @isograph/react@0.0.0-main-4adb5045 compile-libs /home/runner/work/isograph/isograph/libs/isograph-react
|
|
4
4
|
> rimraf dist && tsc -p tsconfig.pkg.json
|
|
5
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"areEqualWithDeepComparison.d.ts","sourceRoot":"","sources":["../../src/core/areEqualWithDeepComparison.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAwC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"areEqualWithDeepComparison.d.ts","sourceRoot":"","sources":["../../src/core/areEqualWithDeepComparison.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAwC,MAAM,UAAU,CAAC;AA2DhF,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,SAAS,CAAC,MAAM,CAAC,EACtB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GACpB,MAAM,CAoER"}
|
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeObjectsUsingReaderAst = mergeObjectsUsingReaderAst;
|
|
4
4
|
function mergeUsingReaderAst(field, oldItem, newItem) {
|
|
5
|
-
if (newItem
|
|
6
|
-
return
|
|
7
|
-
}
|
|
8
|
-
if (newItem === undefined) {
|
|
9
|
-
return oldItem === undefined ? oldItem : newItem;
|
|
5
|
+
if (newItem == null || oldItem == null) {
|
|
6
|
+
return newItem;
|
|
10
7
|
}
|
|
11
8
|
if (Array.isArray(newItem)) {
|
|
12
9
|
if (!Array.isArray(oldItem)) {
|
package/dist/core/cache.js
CHANGED
|
@@ -292,7 +292,7 @@ function normalizeScalarField(astNode, networkResponseParentRecord, targetStoreR
|
|
|
292
292
|
const existingValue = targetStoreRecord[parentRecordKey];
|
|
293
293
|
if (networkResponseData == null) {
|
|
294
294
|
targetStoreRecord[parentRecordKey] = null;
|
|
295
|
-
return existingValue
|
|
295
|
+
return existingValue === undefined || existingValue != null;
|
|
296
296
|
}
|
|
297
297
|
if (isScalarOrEmptyArray(networkResponseData)) {
|
|
298
298
|
targetStoreRecord[parentRecordKey] = networkResponseData;
|
|
@@ -316,7 +316,7 @@ function normalizeLinkedField(environment, storeLayer, astNode, networkResponseP
|
|
|
316
316
|
const existingValue = targetParentRecord[parentRecordKey];
|
|
317
317
|
if (networkResponseData == null) {
|
|
318
318
|
targetParentRecord[parentRecordKey] = null;
|
|
319
|
-
return existingValue
|
|
319
|
+
return existingValue === undefined || existingValue != null;
|
|
320
320
|
}
|
|
321
321
|
if (isScalarOrEmptyArray(networkResponseData) &&
|
|
322
322
|
!isNullOrEmptyArray(networkResponseData)) {
|
|
@@ -408,7 +408,7 @@ function isScalarOrEmptyArray(data) {
|
|
|
408
408
|
if (isArray(data)) {
|
|
409
409
|
return data.every((x) => isScalarOrEmptyArray(x));
|
|
410
410
|
}
|
|
411
|
-
const isScalarValue = data
|
|
411
|
+
const isScalarValue = data == null ||
|
|
412
412
|
typeof data === 'string' ||
|
|
413
413
|
typeof data === 'number' ||
|
|
414
414
|
typeof data === 'boolean';
|
|
@@ -421,7 +421,7 @@ function isNullOrEmptyArray(data) {
|
|
|
421
421
|
}
|
|
422
422
|
return data.every((x) => isNullOrEmptyArray(x));
|
|
423
423
|
}
|
|
424
|
-
return data
|
|
424
|
+
return data == null;
|
|
425
425
|
}
|
|
426
426
|
function getParentRecordKey(astNode, variables) {
|
|
427
427
|
let parentRecordKey = astNode.fieldName;
|
package/dist/core/check.js
CHANGED
|
@@ -47,13 +47,13 @@ function checkFromRecord(environment, normalizationAst, variables, record, recor
|
|
|
47
47
|
record: recordLink,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
else if (linkedValue
|
|
50
|
+
else if (linkedValue == null) {
|
|
51
51
|
continue;
|
|
52
52
|
}
|
|
53
53
|
else if (Array.isArray(linkedValue)) {
|
|
54
54
|
arrayItemsLoop: for (const item of linkedValue) {
|
|
55
55
|
const link = (0, IsographEnvironment_1.getLink)(item);
|
|
56
|
-
if (link
|
|
56
|
+
if (link == null) {
|
|
57
57
|
throw new Error('Unexpected non-link in the Isograph store. ' +
|
|
58
58
|
'This is indicative of a bug in Isograph.');
|
|
59
59
|
}
|
|
@@ -64,7 +64,7 @@ function checkFromRecord(environment, normalizationAst, variables, record, recor
|
|
|
64
64
|
record: link,
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
else if (linkedRecord
|
|
67
|
+
else if (linkedRecord == null) {
|
|
68
68
|
continue arrayItemsLoop;
|
|
69
69
|
}
|
|
70
70
|
else {
|
|
@@ -78,7 +78,7 @@ function checkFromRecord(environment, normalizationAst, variables, record, recor
|
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
80
80
|
const link = (0, IsographEnvironment_1.getLink)(linkedValue);
|
|
81
|
-
if (link
|
|
81
|
+
if (link == null) {
|
|
82
82
|
throw new Error('Unexpected non-link in the Isograph store. ' +
|
|
83
83
|
'This is indicative of a bug in Isograph.');
|
|
84
84
|
}
|
|
@@ -89,7 +89,7 @@ function checkFromRecord(environment, normalizationAst, variables, record, recor
|
|
|
89
89
|
record: link,
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
else if (linkedRecord
|
|
92
|
+
else if (linkedRecord == null) {
|
|
93
93
|
continue normalizationAstLoop;
|
|
94
94
|
}
|
|
95
95
|
else {
|
|
@@ -56,7 +56,7 @@ function garbageCollectBaseStoreLayer(retainedQueries, baseStoreLayer) {
|
|
|
56
56
|
continue;
|
|
57
57
|
const retainedTypeIds = retainedIds[typeName];
|
|
58
58
|
// delete all objects
|
|
59
|
-
if (retainedTypeIds
|
|
59
|
+
if (retainedTypeIds === undefined || retainedTypeIds.size === 0) {
|
|
60
60
|
delete baseStoreLayer.data[typeName];
|
|
61
61
|
continue;
|
|
62
62
|
}
|
|
@@ -102,10 +102,10 @@ function recordReachableIdsFromRecord(dataLayer, currentRecord, mutableRetainedI
|
|
|
102
102
|
links.push(link);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
let typeStore = selection.concreteType
|
|
105
|
+
let typeStore = selection.concreteType != null
|
|
106
106
|
? dataLayer[selection.concreteType]
|
|
107
107
|
: null;
|
|
108
|
-
if (typeStore == null && selection.concreteType
|
|
108
|
+
if (typeStore == null && selection.concreteType != null) {
|
|
109
109
|
continue;
|
|
110
110
|
}
|
|
111
111
|
for (const nextRecordLink of links) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimisticProxy.d.ts","sourceRoot":"","sources":["../../src/core/optimisticProxy.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACT,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAE/B,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,SAAS,GACd,WAAW,CAGb;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,SAAS,GACd,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"optimisticProxy.d.ts","sourceRoot":"","sources":["../../src/core/optimisticProxy.ts"],"names":[],"mappings":"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"}
|
|
@@ -23,15 +23,16 @@ function getOrInsertRecord(dataLayer, link) {
|
|
|
23
23
|
function getStoreRecordProxy(storeLayer, link) {
|
|
24
24
|
var _a;
|
|
25
25
|
let startNode = storeLayer;
|
|
26
|
-
while (startNode
|
|
26
|
+
while (startNode != null) {
|
|
27
27
|
const storeRecord = (_a = startNode.data[link.__typename]) === null || _a === void 0 ? void 0 : _a[link.__link];
|
|
28
|
-
if (storeRecord ===
|
|
29
|
-
|
|
28
|
+
if (storeRecord === undefined) {
|
|
29
|
+
startNode = startNode.parentStoreLayer;
|
|
30
|
+
continue;
|
|
30
31
|
}
|
|
31
|
-
if (storeRecord
|
|
32
|
-
return
|
|
32
|
+
if (storeRecord == null) {
|
|
33
|
+
return null;
|
|
33
34
|
}
|
|
34
|
-
startNode
|
|
35
|
+
return getMutableStoreRecordProxy(startNode, link);
|
|
35
36
|
}
|
|
36
37
|
return undefined;
|
|
37
38
|
}
|
|
@@ -40,12 +41,12 @@ function getMutableStoreRecordProxy(childMostStoreLayer, link) {
|
|
|
40
41
|
get(_, propertyName) {
|
|
41
42
|
var _a;
|
|
42
43
|
let currentStoreLayer = childMostStoreLayer;
|
|
43
|
-
while (currentStoreLayer
|
|
44
|
+
while (currentStoreLayer != null) {
|
|
44
45
|
const storeRecord = (_a = currentStoreLayer.data[link.__typename]) === null || _a === void 0 ? void 0 : _a[link.__link];
|
|
45
|
-
if (storeRecord
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
if (storeRecord !== undefined) {
|
|
47
|
+
if (storeRecord == null) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
49
50
|
const value = Reflect.get(storeRecord, propertyName);
|
|
50
51
|
if (value !== undefined) {
|
|
51
52
|
return value;
|
|
@@ -57,14 +58,14 @@ function getMutableStoreRecordProxy(childMostStoreLayer, link) {
|
|
|
57
58
|
has(_, propertyName) {
|
|
58
59
|
var _a;
|
|
59
60
|
let currentStoreLayer = childMostStoreLayer;
|
|
60
|
-
while (currentStoreLayer
|
|
61
|
+
while (currentStoreLayer != null) {
|
|
61
62
|
const storeRecord = (_a = currentStoreLayer.data[link.__typename]) === null || _a === void 0 ? void 0 : _a[link.__link];
|
|
62
|
-
if (storeRecord
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
if (storeRecord !== undefined) {
|
|
64
|
+
if (storeRecord == null) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
66
67
|
const value = Reflect.has(storeRecord, propertyName);
|
|
67
|
-
if (value
|
|
68
|
+
if (value) {
|
|
68
69
|
return true;
|
|
69
70
|
}
|
|
70
71
|
}
|
|
@@ -110,7 +111,7 @@ function mergeDataLayer(target, source) {
|
|
|
110
111
|
}
|
|
111
112
|
const targetRecordById = ((_a = target[typeName]) !== null && _a !== void 0 ? _a : (target[typeName] = {}));
|
|
112
113
|
for (const [id, sourceRecord] of Object.entries(sourceById)) {
|
|
113
|
-
if (sourceRecord
|
|
114
|
+
if (sourceRecord == null) {
|
|
114
115
|
targetRecordById[id] = null;
|
|
115
116
|
continue;
|
|
116
117
|
}
|
|
@@ -240,7 +241,7 @@ function reexecuteUpdatesAndMergeData(storeLayer,
|
|
|
240
241
|
oldMergedData,
|
|
241
242
|
// reflects whatever replaced the optimistic layer
|
|
242
243
|
newMergedData) {
|
|
243
|
-
while (storeLayer
|
|
244
|
+
while (storeLayer != null) {
|
|
244
245
|
mergeDataLayer(oldMergedData, storeLayer.data);
|
|
245
246
|
switch (storeLayer.kind) {
|
|
246
247
|
case 'OptimisticNetworkResponseStoreLayer':
|
|
@@ -273,7 +274,7 @@ newMergedData) {
|
|
|
273
274
|
*/
|
|
274
275
|
function setChildOfNode(environment, storeLayerToModify, newChildStoreLayer) {
|
|
275
276
|
storeLayerToModify.childStoreLayer = newChildStoreLayer;
|
|
276
|
-
if (newChildStoreLayer
|
|
277
|
+
if (newChildStoreLayer != null) {
|
|
277
278
|
newChildStoreLayer.parentStoreLayer = storeLayerToModify;
|
|
278
279
|
}
|
|
279
280
|
else {
|
|
@@ -302,7 +303,7 @@ function revertOptimisticStoreLayerAndMaybeReplace(environment, optimisticNode,
|
|
|
302
303
|
optimisticNode.data = {};
|
|
303
304
|
let newMergedData = {};
|
|
304
305
|
let childNode = optimisticNode.childStoreLayer;
|
|
305
|
-
if (normalizeData
|
|
306
|
+
if (normalizeData != null) {
|
|
306
307
|
const networkResponseStoreLayer = {
|
|
307
308
|
kind: 'NetworkResponseStoreLayer',
|
|
308
309
|
data: {},
|
package/dist/core/read.js
CHANGED
|
@@ -75,7 +75,7 @@ function readData(environment, ast, root, variables, nestedRefetchQueries, netwo
|
|
|
75
75
|
recordLink: root,
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
if (storeRecord
|
|
78
|
+
if (storeRecord == null) {
|
|
79
79
|
return {
|
|
80
80
|
kind: 'Success',
|
|
81
81
|
data: null,
|
|
@@ -435,7 +435,7 @@ function readLinkedFieldData(environment, field, storeRecord, root, variables, n
|
|
|
435
435
|
recordLink: root,
|
|
436
436
|
};
|
|
437
437
|
}
|
|
438
|
-
else if (link
|
|
438
|
+
else if (link == null) {
|
|
439
439
|
results.push(null);
|
|
440
440
|
continue;
|
|
441
441
|
}
|
|
@@ -507,7 +507,7 @@ function readLinkedFieldData(environment, field, storeRecord, root, variables, n
|
|
|
507
507
|
link = altLink;
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
|
-
else if (link
|
|
510
|
+
else if (link == null) {
|
|
511
511
|
return {
|
|
512
512
|
kind: 'Success',
|
|
513
513
|
data: null,
|
|
@@ -537,7 +537,7 @@ function readLinkedFieldData(environment, field, storeRecord, root, variables, n
|
|
|
537
537
|
return data;
|
|
538
538
|
}
|
|
539
539
|
function isClientPointer(field) {
|
|
540
|
-
return field.refetchQueryIndex
|
|
540
|
+
return field.refetchQueryIndex != null;
|
|
541
541
|
}
|
|
542
542
|
function readClientPointerData(environment, field, root, variables, nestedRefetchQueries, readData) {
|
|
543
543
|
const refetchReaderParams = readData([
|
|
@@ -106,7 +106,7 @@ function useConnectionSpecPagination(loadableField, initialState) {
|
|
|
106
106
|
const loadedReferences = state === react_disposable_state_1.UNASSIGNED_STATE ? [] : state;
|
|
107
107
|
const mostRecentItem = loadedReferences[loadedReferences.length - 1];
|
|
108
108
|
const mostRecentFragmentReference = mostRecentItem === null || mostRecentItem === void 0 ? void 0 : mostRecentItem[0].getItemIfNotDisposed();
|
|
109
|
-
if (mostRecentItem != null && mostRecentFragmentReference
|
|
109
|
+
if (mostRecentItem != null && mostRecentFragmentReference == null) {
|
|
110
110
|
throw new Error('FragmentReference is unexpectedly disposed. \
|
|
111
111
|
This is indicative of a bug in Isograph.');
|
|
112
112
|
}
|
|
@@ -99,7 +99,7 @@ function useSkipLimitPagination(loadableField, initialState) {
|
|
|
99
99
|
const loadedReferences = state === react_disposable_state_1.UNASSIGNED_STATE ? [] : state;
|
|
100
100
|
const mostRecentItem = loadedReferences[loadedReferences.length - 1];
|
|
101
101
|
const mostRecentFragmentReference = mostRecentItem === null || mostRecentItem === void 0 ? void 0 : mostRecentItem[0].getItemIfNotDisposed();
|
|
102
|
-
if (mostRecentItem != null && mostRecentFragmentReference
|
|
102
|
+
if (mostRecentItem != null && mostRecentFragmentReference == null) {
|
|
103
103
|
throw new Error('FragmentReference is unexpectedly disposed. \
|
|
104
104
|
This is indicative of a bug in Isograph.');
|
|
105
105
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isograph/react",
|
|
3
|
-
"version": "0.0.0-main-
|
|
3
|
+
"version": "0.0.0-main-4adb5045",
|
|
4
4
|
"description": "Use Isograph with React",
|
|
5
5
|
"homepage": "https://isograph.dev",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"author": "Isograph Labs",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@isograph/disposable-types": "0.0.0-main-
|
|
12
|
-
"@isograph/
|
|
13
|
-
"@isograph/
|
|
11
|
+
"@isograph/disposable-types": "0.0.0-main-4adb5045",
|
|
12
|
+
"@isograph/reference-counted-pointer": "0.0.0-main-4adb5045",
|
|
13
|
+
"@isograph/react-disposable-state": "0.0.0-main-4adb5045"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"react": "^18.0.0 || ^19.0.0"
|
|
@@ -6,12 +6,8 @@ function mergeUsingReaderAst(
|
|
|
6
6
|
oldItem: unknown,
|
|
7
7
|
newItem: unknown,
|
|
8
8
|
): unknown {
|
|
9
|
-
if (newItem
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (newItem === undefined) {
|
|
14
|
-
return oldItem === undefined ? oldItem : newItem;
|
|
9
|
+
if (newItem == null || oldItem == null) {
|
|
10
|
+
return newItem;
|
|
15
11
|
}
|
|
16
12
|
|
|
17
13
|
if (Array.isArray(newItem)) {
|
package/src/core/cache.ts
CHANGED
|
@@ -520,7 +520,7 @@ function normalizeScalarField(
|
|
|
520
520
|
|
|
521
521
|
if (networkResponseData == null) {
|
|
522
522
|
targetStoreRecord[parentRecordKey] = null;
|
|
523
|
-
return existingValue
|
|
523
|
+
return existingValue === undefined || existingValue != null;
|
|
524
524
|
}
|
|
525
525
|
|
|
526
526
|
if (isScalarOrEmptyArray(networkResponseData)) {
|
|
@@ -555,7 +555,7 @@ function normalizeLinkedField(
|
|
|
555
555
|
|
|
556
556
|
if (networkResponseData == null) {
|
|
557
557
|
targetParentRecord[parentRecordKey] = null;
|
|
558
|
-
return existingValue
|
|
558
|
+
return existingValue === undefined || existingValue != null;
|
|
559
559
|
}
|
|
560
560
|
|
|
561
561
|
if (
|
|
@@ -741,7 +741,7 @@ function isScalarOrEmptyArray(
|
|
|
741
741
|
return data.every((x) => isScalarOrEmptyArray(x));
|
|
742
742
|
}
|
|
743
743
|
const isScalarValue =
|
|
744
|
-
data
|
|
744
|
+
data == null ||
|
|
745
745
|
typeof data === 'string' ||
|
|
746
746
|
typeof data === 'number' ||
|
|
747
747
|
typeof data === 'boolean';
|
|
@@ -758,7 +758,7 @@ function isNullOrEmptyArray(
|
|
|
758
758
|
return data.every((x) => isNullOrEmptyArray(x));
|
|
759
759
|
}
|
|
760
760
|
|
|
761
|
-
return data
|
|
761
|
+
return data == null;
|
|
762
762
|
}
|
|
763
763
|
|
|
764
764
|
export function getParentRecordKey(
|
package/src/core/check.ts
CHANGED
|
@@ -108,12 +108,12 @@ function checkFromRecord(
|
|
|
108
108
|
kind: 'MissingData',
|
|
109
109
|
record: recordLink,
|
|
110
110
|
};
|
|
111
|
-
} else if (linkedValue
|
|
111
|
+
} else if (linkedValue == null) {
|
|
112
112
|
continue;
|
|
113
113
|
} else if (Array.isArray(linkedValue)) {
|
|
114
114
|
arrayItemsLoop: for (const item of linkedValue) {
|
|
115
115
|
const link = getLink(item);
|
|
116
|
-
if (link
|
|
116
|
+
if (link == null) {
|
|
117
117
|
throw new Error(
|
|
118
118
|
'Unexpected non-link in the Isograph store. ' +
|
|
119
119
|
'This is indicative of a bug in Isograph.',
|
|
@@ -127,7 +127,7 @@ function checkFromRecord(
|
|
|
127
127
|
kind: 'MissingData',
|
|
128
128
|
record: link,
|
|
129
129
|
};
|
|
130
|
-
} else if (linkedRecord
|
|
130
|
+
} else if (linkedRecord == null) {
|
|
131
131
|
continue arrayItemsLoop;
|
|
132
132
|
} else {
|
|
133
133
|
// TODO in __DEV__ assert linkedRecord is an object
|
|
@@ -146,7 +146,7 @@ function checkFromRecord(
|
|
|
146
146
|
}
|
|
147
147
|
} else {
|
|
148
148
|
const link = getLink(linkedValue);
|
|
149
|
-
if (link
|
|
149
|
+
if (link == null) {
|
|
150
150
|
throw new Error(
|
|
151
151
|
'Unexpected non-link in the Isograph store. ' +
|
|
152
152
|
'This is indicative of a bug in Isograph.',
|
|
@@ -160,7 +160,7 @@ function checkFromRecord(
|
|
|
160
160
|
kind: 'MissingData',
|
|
161
161
|
record: link,
|
|
162
162
|
};
|
|
163
|
-
} else if (linkedRecord
|
|
163
|
+
} else if (linkedRecord == null) {
|
|
164
164
|
continue normalizationAstLoop;
|
|
165
165
|
} else {
|
|
166
166
|
// TODO in __DEV__ assert linkedRecord is an object
|
|
@@ -101,7 +101,7 @@ export function garbageCollectBaseStoreLayer(
|
|
|
101
101
|
const retainedTypeIds = retainedIds[typeName];
|
|
102
102
|
|
|
103
103
|
// delete all objects
|
|
104
|
-
if (retainedTypeIds
|
|
104
|
+
if (retainedTypeIds === undefined || retainedTypeIds.size === 0) {
|
|
105
105
|
delete baseStoreLayer.data[typeName];
|
|
106
106
|
continue;
|
|
107
107
|
}
|
|
@@ -175,11 +175,11 @@ function recordReachableIdsFromRecord(
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
let typeStore =
|
|
178
|
-
selection.concreteType
|
|
178
|
+
selection.concreteType != null
|
|
179
179
|
? dataLayer[selection.concreteType]
|
|
180
180
|
: null;
|
|
181
181
|
|
|
182
|
-
if (typeStore == null && selection.concreteType
|
|
182
|
+
if (typeStore == null && selection.concreteType != null) {
|
|
183
183
|
continue;
|
|
184
184
|
}
|
|
185
185
|
|
|
@@ -29,15 +29,18 @@ export function getStoreRecordProxy(
|
|
|
29
29
|
link: StoreLink,
|
|
30
30
|
): Readonly<StoreRecord> | null | undefined {
|
|
31
31
|
let startNode: StoreLayer | null = storeLayer;
|
|
32
|
-
while (startNode
|
|
32
|
+
while (startNode != null) {
|
|
33
33
|
const storeRecord = startNode.data[link.__typename]?.[link.__link];
|
|
34
|
-
if (storeRecord ===
|
|
35
|
-
|
|
34
|
+
if (storeRecord === undefined) {
|
|
35
|
+
startNode = startNode.parentStoreLayer;
|
|
36
|
+
continue;
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
|
|
39
|
+
if (storeRecord == null) {
|
|
40
|
+
return null;
|
|
39
41
|
}
|
|
40
|
-
|
|
42
|
+
|
|
43
|
+
return getMutableStoreRecordProxy(startNode, link);
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
return undefined;
|
|
@@ -52,13 +55,13 @@ export function getMutableStoreRecordProxy(
|
|
|
52
55
|
{
|
|
53
56
|
get(_, propertyName) {
|
|
54
57
|
let currentStoreLayer: StoreLayer | null = childMostStoreLayer;
|
|
55
|
-
while (currentStoreLayer
|
|
58
|
+
while (currentStoreLayer != null) {
|
|
56
59
|
const storeRecord =
|
|
57
60
|
currentStoreLayer.data[link.__typename]?.[link.__link];
|
|
58
|
-
if (storeRecord
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
if (storeRecord !== undefined) {
|
|
62
|
+
if (storeRecord == null) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
62
65
|
const value = Reflect.get(storeRecord, propertyName);
|
|
63
66
|
if (value !== undefined) {
|
|
64
67
|
return value;
|
|
@@ -69,15 +72,16 @@ export function getMutableStoreRecordProxy(
|
|
|
69
72
|
},
|
|
70
73
|
has(_, propertyName) {
|
|
71
74
|
let currentStoreLayer: StoreLayer | null = childMostStoreLayer;
|
|
72
|
-
while (currentStoreLayer
|
|
75
|
+
while (currentStoreLayer != null) {
|
|
73
76
|
const storeRecord =
|
|
74
77
|
currentStoreLayer.data[link.__typename]?.[link.__link];
|
|
75
|
-
if (storeRecord
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
if (storeRecord !== undefined) {
|
|
79
|
+
if (storeRecord == null) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
79
83
|
const value = Reflect.has(storeRecord, propertyName);
|
|
80
|
-
if (value
|
|
84
|
+
if (value) {
|
|
81
85
|
return true;
|
|
82
86
|
}
|
|
83
87
|
}
|
|
@@ -193,7 +197,7 @@ function mergeDataLayer(target: StoreLayerData, source: StoreLayerData): void {
|
|
|
193
197
|
}
|
|
194
198
|
const targetRecordById = (target[typeName] ??= {});
|
|
195
199
|
for (const [id, sourceRecord] of Object.entries(sourceById)) {
|
|
196
|
-
if (sourceRecord
|
|
200
|
+
if (sourceRecord == null) {
|
|
197
201
|
targetRecordById[id] = null;
|
|
198
202
|
continue;
|
|
199
203
|
}
|
|
@@ -355,7 +359,7 @@ function reexecuteUpdatesAndMergeData(
|
|
|
355
359
|
// reflects whatever replaced the optimistic layer
|
|
356
360
|
newMergedData: StoreLayerData,
|
|
357
361
|
): void {
|
|
358
|
-
while (storeLayer
|
|
362
|
+
while (storeLayer != null) {
|
|
359
363
|
mergeDataLayer(oldMergedData, storeLayer.data);
|
|
360
364
|
switch (storeLayer.kind) {
|
|
361
365
|
case 'OptimisticNetworkResponseStoreLayer':
|
|
@@ -394,7 +398,7 @@ function setChildOfNode<TStoreLayer extends StoreLayer>(
|
|
|
394
398
|
newChildStoreLayer: TStoreLayer['childStoreLayer'],
|
|
395
399
|
) {
|
|
396
400
|
storeLayerToModify.childStoreLayer = newChildStoreLayer;
|
|
397
|
-
if (newChildStoreLayer
|
|
401
|
+
if (newChildStoreLayer != null) {
|
|
398
402
|
newChildStoreLayer.parentStoreLayer = storeLayerToModify;
|
|
399
403
|
} else {
|
|
400
404
|
environment.store = storeLayerToModify;
|
|
@@ -427,7 +431,7 @@ export function revertOptimisticStoreLayerAndMaybeReplace(
|
|
|
427
431
|
|
|
428
432
|
let newMergedData = {};
|
|
429
433
|
let childNode = optimisticNode.childStoreLayer;
|
|
430
|
-
if (normalizeData
|
|
434
|
+
if (normalizeData != null) {
|
|
431
435
|
const networkResponseStoreLayer: NetworkResponseStoreLayer = {
|
|
432
436
|
kind: 'NetworkResponseStoreLayer',
|
|
433
437
|
data: {},
|
package/src/core/read.ts
CHANGED
|
@@ -164,7 +164,7 @@ function readData<TReadFromStore>(
|
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
if (storeRecord
|
|
167
|
+
if (storeRecord == null) {
|
|
168
168
|
return {
|
|
169
169
|
kind: 'Success',
|
|
170
170
|
data: null as any,
|
|
@@ -736,7 +736,7 @@ export function readLinkedFieldData(
|
|
|
736
736
|
JSON.stringify(item),
|
|
737
737
|
recordLink: root,
|
|
738
738
|
};
|
|
739
|
-
} else if (link
|
|
739
|
+
} else if (link == null) {
|
|
740
740
|
results.push(null);
|
|
741
741
|
continue;
|
|
742
742
|
}
|
|
@@ -827,7 +827,7 @@ export function readLinkedFieldData(
|
|
|
827
827
|
} else {
|
|
828
828
|
link = altLink;
|
|
829
829
|
}
|
|
830
|
-
} else if (link
|
|
830
|
+
} else if (link == null) {
|
|
831
831
|
return {
|
|
832
832
|
kind: 'Success',
|
|
833
833
|
data: null,
|
|
@@ -869,7 +869,7 @@ export function readLinkedFieldData(
|
|
|
869
869
|
function isClientPointer(
|
|
870
870
|
field: ReaderLinkedField,
|
|
871
871
|
): field is ReaderClientPointer {
|
|
872
|
-
return field.refetchQueryIndex
|
|
872
|
+
return field.refetchQueryIndex != null;
|
|
873
873
|
}
|
|
874
874
|
|
|
875
875
|
export function readClientPointerData(
|
|
@@ -264,7 +264,7 @@ export function useConnectionSpecPagination<
|
|
|
264
264
|
const mostRecentFragmentReference =
|
|
265
265
|
mostRecentItem?.[0].getItemIfNotDisposed();
|
|
266
266
|
|
|
267
|
-
if (mostRecentItem != null && mostRecentFragmentReference
|
|
267
|
+
if (mostRecentItem != null && mostRecentFragmentReference == null) {
|
|
268
268
|
throw new Error(
|
|
269
269
|
'FragmentReference is unexpectedly disposed. \
|
|
270
270
|
This is indicative of a bug in Isograph.',
|
|
@@ -248,7 +248,7 @@ export function useSkipLimitPagination<
|
|
|
248
248
|
const mostRecentFragmentReference =
|
|
249
249
|
mostRecentItem?.[0].getItemIfNotDisposed();
|
|
250
250
|
|
|
251
|
-
if (mostRecentItem != null && mostRecentFragmentReference
|
|
251
|
+
if (mostRecentItem != null && mostRecentFragmentReference == null) {
|
|
252
252
|
throw new Error(
|
|
253
253
|
'FragmentReference is unexpectedly disposed. \
|
|
254
254
|
This is indicative of a bug in Isograph.',
|
|
@@ -813,7 +813,7 @@ describe('optimisticLayer', () => {
|
|
|
813
813
|
return revertOptimisticStoreLayerAndMaybeReplace(
|
|
814
814
|
environment,
|
|
815
815
|
node,
|
|
816
|
-
counter
|
|
816
|
+
counter == null
|
|
817
817
|
? counter
|
|
818
818
|
: (storeLayer) => update(storeLayer, () => counter),
|
|
819
819
|
);
|
|
@@ -851,7 +851,7 @@ describe('optimisticLayer', () => {
|
|
|
851
851
|
},
|
|
852
852
|
};
|
|
853
853
|
|
|
854
|
-
return counter
|
|
854
|
+
return counter !== nextCounter ? CHANGES : NO_CHANGES;
|
|
855
855
|
};
|
|
856
856
|
|
|
857
857
|
function ignoreReadonly(value: StoreLayer): { data: StoreLayerData } {
|