Skip to content

Commit 11c0d9f

Browse files
Shane ThomasKyleAMathews
Shane Thomas
andauthored
fix(gatsby-source-drupal): Fix Drupal webhook delete issues (#32180)
* fix(gatsby-source-drupal): Fix Drupal webhook delete issues * Update packages/gatsby-source-drupal/src/gatsby-node.js Co-authored-by: Kyle Mathews <[email protected]> Co-authored-by: Kyle Mathews <[email protected]>
1 parent e5574c8 commit 11c0d9f

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

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

+22-3
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ exports.sourceNodes = async (
111111
changesActivity.start()
112112

113113
try {
114-
const { secret, action, id, data } = webhookBody
114+
const { secret, action, data } = webhookBody
115115
if (pluginOptions.secret && pluginOptions.secret !== secret) {
116116
reporter.warn(
117117
`The secret in this request did not match your plugin options secret.`
@@ -120,8 +120,27 @@ exports.sourceNodes = async (
120120
return
121121
}
122122
if (action === `delete`) {
123-
actions.deleteNode(getNode(createNodeId(id)))
124-
reporter.log(`Deleted node: ${id}`)
123+
let nodesToDelete = data
124+
if (!Array.isArray(data)) {
125+
nodesToDelete = [data]
126+
}
127+
128+
for (const nodeToDelete of nodesToDelete) {
129+
const nodeIdToDelete = createNodeId(
130+
createNodeIdWithVersion(
131+
nodeToDelete.id,
132+
nodeToDelete.type,
133+
getOptions().languageConfig
134+
? nodeToDelete.attributes?.langcode
135+
: `und`,
136+
nodeToDelete.attributes?.drupal_internal__revision_id,
137+
entityReferenceRevisions
138+
)
139+
)
140+
actions.deleteNode(getNode(nodeIdToDelete))
141+
reporter.log(`Deleted node: ${nodeIdToDelete}`)
142+
}
143+
125144
changesActivity.end()
126145
return
127146
}

0 commit comments

Comments
 (0)