-
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
fix(gatsby-source-contentful): maintain back reference map between runs #37442
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gatsbot
bot
added
the
status: triage needed
Issue or pull request that need to be triaged and assigned to a reviewer
label
Jan 11, 2023
pieh
added
topic: source-contentful
Related to Gatsby's integration with Contentful
and removed
status: triage needed
Issue or pull request that need to be triaged and assigned to a reviewer
labels
Jan 11, 2023
pieh
force-pushed
the
contentful-untouched-node-backref
branch
from
January 11, 2023 18:41
c9315d2
to
fcd6f11
Compare
axe312ger
approved these changes
Jan 12, 2023
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.
Can't see any logic issues, plus tests are green.
This should definitely improve the reliability of the plugin!
Thank you!
🥂 |
Published in:
|
This was referenced May 26, 2023
This was referenced May 26, 2023
This was referenced May 26, 2023
This was referenced May 27, 2023
This was referenced May 31, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Some Contentful delta sync updates are currently stripping previously created back reference links when they shouldn't.
This happen because when we create a link map (which we call
foreighReferenceMap
in the plugin) we only used entries that were created or updated since last sync. If sync didn't update referencing entry, then updated entries would lose backreferences to referecing entry.To fix the problem this PR maintains state of
foreighReferenceMap
betweensourceNodes
runs keeping it fully saturated at all times. Traversing everything in eachsourceNodes
runs would be expensive soforeignReferenceMap
now also have sort of "delta updates":foreignReferenceMapState
which is object withbackLinks
(which is exact same structure asforeignReferenceMap
, so can be used as-is in later stages of sourcing, without having to refactor bunch of code in the plugin)links
which is somewhat reverse mapping - keys are contentful's id and values is array of field names inbackLinks
- this is done to be able to do guided deletions without nested for loops if we would only havebackLinks
( similar to what perf(gatsby): fix performance regression with query dependency cleaning #28032 did for increased perf to similar data structure problem)Related Issues
[ch-59240]