-
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
Delete a node before creating/updating it, so that the related page q… #33285
Delete a node before creating/updating it, so that the related page q… #33285
Conversation
…ueries are rerun properly
Hey, thanks for your PR but this actually does not solve the issue. Gatsby will do an update if changes are detected. This means something else is wrong. cc @KyleAMathews any ideas? |
Well, the thing is that's not entirely true. I was literally debugging this and manually changing data (like modifying a value on a field, so nothing related to relationships) in the node didn't rerun the queries, only after applying this code it started working on my end. The thing is, I thought that just having a different contentDigest value would be enough to pick up my changes, but that didn't work. |
hey @kszot-ref — yeah like Ward said, you don't need to delete a node to trigger page queries to re-run. So the fact this is working points to some other problem e.g. perhaps the contentDigest isn't getting updated. Perhaps you could log out what the node object looks like? I'm working a lot with the Drupal integration right now so happy to jump in and help debug this with you. Don't know where you're at in the world but if any times on here work for you, feel free to schedule a meeting https://calendly.com/kyle-gatsby/30min?back=1&month=2021-09 |
This is how the node looks before it's modified:
and this is how it looks after the change, this one is passed to the "createNode" method:
Differences: new relationship, contentDigest was updated, node owner has been removed. So without this PR related page queries wouldn't be rerun. I even tried to modify a field manually in the node (before the digest is generated, using a debugger) and that also didn't trigger page queries rerun. I've scheduled a meeting so we can do some live debugging on this example if you want to know more. |
We've went through the code with Kyle, so I've got a few tips where to look to debug this issue. During the call we didn't pinpoint it, but I've tried again the next day. I've went through the node creation process with a debugger and came to a conclusion that this is indeed an issue inside the gatsby-source-drupal plugin. To create a backlink for a referenced node, the plugin does the following steps:
gatsby/packages/gatsby/src/utils/nodes.ts Lines 9 to 16 in 08c5b2a
When the code reaches this point, it gets the node from the datastore, but the issue is that data was modified inplace, the updated values are already in there. So it actually compares the new contentDigest with the already updated contentDigest, which means that the code thinks that the node didn't update at all, as in this scenario they will always be the same. |
oooo dang. That's bad. I'll add a shallow-clone real quick right now in gatsby-source-drupal. This is a tricky issue to uncover, and an easy footgun for source plugin authors. Thanks for digging deep and figuring it out! |
Got a PR up #33328. Huge thanks @kszot-ref for digging in and finding the root cause. Gonna close this PR now in favor of #33328 |
This PR is directly related to this issue - #33284. Deleting a node before updating it forces it properly rerun page queries. I'm not sure if this would be the correct way to fix this issue, but just leaving it as a reference for a potential fix.
Related Issues
Fixes #33284