Skip to content

Commit 60750b4

Browse files
committed
Fix handling of bad pointers in arrays
When refactoring this code, I lost a behavior where a pointer to an object that isn't found is dropped from the results (I had been leaving an `undefined` in its place). There's one tricky wrinkle, which is that if the value in the array is `null`, it should be retained (see #2189 for more details on why this is the expected behavior).
1 parent e9496d0 commit 60750b4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/RestQuery.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -963,9 +963,9 @@ function replacePointers(object, path, replace) {
963963
// this could be either a pointer or an array of pointers
964964
const pointerOrPointers = node[attrName];
965965
if (pointerOrPointers instanceof Array) {
966-
node[attrName] = pointerOrPointers.map(
967-
pointer => pointer && replace[pointer.objectId]
968-
);
966+
node[attrName] = pointerOrPointers
967+
.map(pointer => pointer && replace[pointer.objectId])
968+
.filter(pointer => pointer || pointer === null);
969969
} else if (pointerOrPointers && pointerOrPointers.__type === 'Pointer') {
970970
node[attrName] = replace[pointerOrPointers.objectId];
971971
}

0 commit comments

Comments
 (0)