File tree 1 file changed +22
-3
lines changed
packages/gatsby-source-drupal/src
1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ exports.sourceNodes = async (
111
111
changesActivity . start ( )
112
112
113
113
try {
114
- const { secret, action, id , data } = webhookBody
114
+ const { secret, action, data } = webhookBody
115
115
if ( pluginOptions . secret && pluginOptions . secret !== secret ) {
116
116
reporter . warn (
117
117
`The secret in this request did not match your plugin options secret.`
@@ -120,8 +120,27 @@ exports.sourceNodes = async (
120
120
return
121
121
}
122
122
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
+
125
144
changesActivity . end ( )
126
145
return
127
146
}
You can’t perform that action at this time.
0 commit comments