Skip to content

Commit

Permalink
fix(stitching): error.path could be undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
evenchange4 committed Feb 6, 2018
1 parent 6bc8731 commit 82e890d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* ...

* Fix `error.path` could be `undefined` for schema stitching [PR #617](https://github.com/apollographql/graphql-tools/pull/617)

### v2.20.0

* Recreate enums and scalars for more consistent behaviour of merged schemas [PR #613](https://github.com/apollographql/graphql-tools/pull/613)
Expand Down
3 changes: 2 additions & 1 deletion src/stitching/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export function annotateWithChildrenErrors(
if (Array.isArray(object)) {
const byIndex = {};
childrenErrors.forEach(error => {
if (!error.path) { return; }
const index = error.path[1];
const current = byIndex[index] || [];
current.push({
Expand All @@ -27,7 +28,7 @@ export function annotateWithChildrenErrors(
...object,
[ERROR_SYMBOL]: childrenErrors.map(error => ({
...error,
path: error.path.slice(1),
...(error.path ? { path: error.path.slice(1) } : {}),
})),
};
}
Expand Down

0 comments on commit 82e890d

Please sign in to comment.