Skip to content

Commit

Permalink
fix(gatsby-source-drupal): check relationships type exists on node be…
Browse files Browse the repository at this point in the history
…fore filtering (#33181) (#33228)

* 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]>
(cherry picked from commit d4f8355)

Co-authored-by: Kyle Mathews <[email protected]>
  • Loading branch information
GatsbyJS Bot and KyleAMathews authored Sep 17, 2021
1 parent f3f2834 commit c410082
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/gatsby-source-drupal/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const {
nodeFromData,
downloadFile,
isFileNode,
getHref,
createNodeIdWithVersion,
} = require(`./normalize`)

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

const nodeFieldName = `${newNode.internal.type}___NODE`
removedReferencedNodes.forEach(referencedNode => {
referencedNode.relationships[nodeFieldName] =
referencedNode.relationships[nodeFieldName].filter(
id => id !== newNode.id
)
if (
referencedNode.relationships &&
referencedNode.relationships[nodeFieldName]
) {
referencedNode.relationships[nodeFieldName] =
referencedNode.relationships[nodeFieldName].filter(
id => id !== newNode.id
)
}
})

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

0 comments on commit c410082

Please sign in to comment.