Skip to content

Commit 1677bb3

Browse files
authored
Fix apollographql#3393 by making merge function more defensive. (apollographql#3403)
Thanks to @HoangPaul for reporting this problem in apollographql#3393.
1 parent e48fd74 commit 1677bb3

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

packages/graphql-anywhere/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Change log
22

3-
## 4.1.9
3+
### 4.1.10
4+
- Fix [#3393](https://github.com/apollographql/apollo-client/issues/3393)
5+
[PR #3403](https://github.com/apollographql/apollo-client/pull/3403)
6+
7+
### 4.1.9
48
- Various optimizations for cache read performance [#3300](https://github.com/apollographql/apollo-client/pull/3300)
59

610
### 4.1.8

packages/graphql-anywhere/src/graphql.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,14 @@ function executeSubSelectedArray(field, result, execContext) {
231231
const hasOwn = Object.prototype.hasOwnProperty;
232232

233233
export function merge(dest, src) {
234-
Object.keys(src).forEach(key => {
235-
const srcVal = src[key];
236-
if (!hasOwn.call(dest, key)) {
237-
dest[key] = srcVal;
238-
} else if (srcVal && typeof srcVal === 'object') {
239-
merge(dest[key], srcVal);
240-
}
241-
});
234+
if (src !== null && typeof src === 'object') {
235+
Object.keys(src).forEach(key => {
236+
const srcVal = src[key];
237+
if (!hasOwn.call(dest, key)) {
238+
dest[key] = srcVal;
239+
} else {
240+
merge(dest[key], srcVal);
241+
}
242+
});
243+
}
242244
}

0 commit comments

Comments
 (0)