Skip to content

Commit 9f450e1

Browse files
authored
Prevent throwing errors when item it undefined (#35533)
1 parent 6ec174a commit 9f450e1

File tree

1 file changed

+2
-4
lines changed
  • packages/gatsby-source-wordpress/src/steps/create-schema-customization/transform-fields

1 file changed

+2
-4
lines changed

packages/gatsby-source-wordpress/src/steps/create-schema-customization/transform-fields/transform-union.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ export const transformListOfUnions = ({ field, fieldName }) => {
4242
}
4343

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

5452
if (node) {
5553
accumulator.push(node)
56-
} else if (!item.id) {
54+
} else if (item && !item.id) {
5755
accumulator.push(item)
5856
}
5957

0 commit comments

Comments
 (0)