Skip to content

Commit

Permalink
Prevent throwing errors when item it undefined (#35533)
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerBarnes authored Apr 30, 2022
1 parent 6ec174a commit 9f450e1
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ export const transformListOfUnions = ({ field, fieldName }) => {
}

return resolvedField.reduce((accumulator, item) => {
// @todo use our list of Gatsby node types to do a more performant check
// on wether this is a Gatsby node or not.
const node = item.id
const node = item?.id
? context.nodeModel.getNodeById({
id: item.id,
type: buildTypeName(item.__typename),
Expand All @@ -53,7 +51,7 @@ export const transformListOfUnions = ({ field, fieldName }) => {

if (node) {
accumulator.push(node)
} else if (!item.id) {
} else if (item && !item.id) {
accumulator.push(item)
}

Expand Down

0 comments on commit 9f450e1

Please sign in to comment.