-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(gatsby-source-drupal): secrets and delete functionality #18345
Changes from 5 commits
108d1e5
a78598a
7ef9603
941d6f4
d0f9c29
f5442f8
d6d5500
9087af2
de6eaa9
41e3748
ffd774e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,13 +176,21 @@ exports.onCreateDevServer = ( | |
bodyParser.text({ | ||
type: `application/json`, | ||
}), | ||
async (req, res) => { | ||
// we are missing handling of node deletion | ||
const nodeToUpdate = JSON.parse(JSON.parse(req.body)).data | ||
|
||
await handleWebhookUpdate( | ||
async (req, _res) => { | ||
const requestBody = JSON.parse(JSON.parse(req.body)) | ||
const { data, secret, action, id } = requestBody | ||
grantglidewell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (pluginOptions.secret && pluginOptions.secret !== secret) { | ||
return reporter.warn( | ||
`The secret in this request did not match your plugin options secret.` | ||
) | ||
} | ||
if (action === `delete`) { | ||
actions.deleteNode({ node: getNode(createNodeId(id)) }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do have question here: We definitely will need to add some code here to handle back references (I can work on that), question is if we need to handle normal references as well or drupal actually updates those automatically There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a great question. Ive asked for some insight into this on drupal, but I think a modified/extended version of what we already use to update relationships should be able to handle this. Is this something There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is something that gatsby core potentially could handle, but doesn't do it right now (it's up to plugins to keep track of relationships - mostly because it's usually more efficient than any generic solution we could have in core) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems from my conversation with someone who knows Drupal, the relationship are not necessarily updated on delete and it depends on how content and relationships are set up as to when and how that update or removal may happen. ugh. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here is an issue discussing the problem https://www.drupal.org/project/drupal/issues/2723323 |
||
return reporter.log(`Deleted node: ${id}`) | ||
} | ||
return await handleWebhookUpdate( | ||
{ | ||
nodeToUpdate, | ||
data, | ||
actions, | ||
cache, | ||
createNodeId, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this exist in an environment variable rather than committed in code for security purposes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totally agree, Ill update the documentation to reflect that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I think the documentation is much clearer and consistent with the rest of the readme file now.