Skip to content

Commit d4f8355

Browse files
KyleAMathewsDSchau
andauthored
fix(gatsby-source-drupal): check relationships type exists on node before filtering (#33181)
* fix(gatsby-source-drupal): check relationships type exists on node before filtering * Update packages/gatsby-source-drupal/src/utils.js Co-authored-by: Dustin Schau <[email protected]> * format Co-authored-by: Dustin Schau <[email protected]>
1 parent 7c726dd commit d4f8355

File tree

1 file changed

+9
-5
lines changed
  • packages/gatsby-source-drupal/src

1 file changed

+9
-5
lines changed

packages/gatsby-source-drupal/src/utils.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const {
44
nodeFromData,
55
downloadFile,
66
isFileNode,
7-
getHref,
87
createNodeIdWithVersion,
98
} = require(`./normalize`)
109

@@ -262,10 +261,15 @@ ${JSON.stringify(nodeToUpdate, null, 4)}
262261

263262
const nodeFieldName = `${newNode.internal.type}___NODE`
264263
removedReferencedNodes.forEach(referencedNode => {
265-
referencedNode.relationships[nodeFieldName] =
266-
referencedNode.relationships[nodeFieldName].filter(
267-
id => id !== newNode.id
268-
)
264+
if (
265+
referencedNode.relationships &&
266+
referencedNode.relationships[nodeFieldName]
267+
) {
268+
referencedNode.relationships[nodeFieldName] =
269+
referencedNode.relationships[nodeFieldName].filter(
270+
id => id !== newNode.id
271+
)
272+
}
269273
})
270274

271275
// see what nodes are newly referenced, and make sure to call `createNode` on them

0 commit comments

Comments
 (0)