-
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
perf(gatsby-plugin-contentful): drop the super expensive fixids cycle #27318
Conversation
packages/gatsby-source-contentful/src/__tests__/__snapshots__/gatsby-node.js.snap
Show resolved
Hide resolved
// We need to add only root level resolvable (assets and entries) | ||
// Derived nodes (markdown or JSON) will be recreated if needed. | ||
const key = `${node.contentful_id}___${ | ||
node.sys.linkType || node.sys.type |
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.
@axe312ger this was the missing fix to make the tests pass
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.
Hmm, I wonder how the nodes can be of type Link while entryList
should contain a fully resolved Contentful API response:
resolvable.add( | ||
`${entry.sys.id}___${entry.sys.linkType || entry.sys.type}` | ||
) | ||
}) | ||
}) | ||
assets.forEach(assetItem => | ||
resolvable.add(`${assetItem.sys.id}___${assetItem.sys.type}`) | ||
resolvable.add( | ||
`${assetItem.sys.id}___${assetItem.sys.linkType || assetItem.sys.type}` | ||
) |
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.
I also applied it to these two, although it did not make a difference in the tests. @axe312ger is this a redundant change or good to keep?
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.
See comment above. We should not have links in here at the first place.
It might be that the test fixtures are wrong/outdated.
contentful_id: process.env.EXPERIMENTAL_CONTENTFUL_SKIP_NORMALIZE_IDS | ||
? entryItem.sys.id | ||
: entryItem.sys.contentful_id, | ||
contentful_id: entryItem.sys.id, |
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.
Tried dropping this entirely but that does break some tests so let's keep it for now. I think it makes sense for there to be a contentful_id
to recognize atomic ids for content from Contentful
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.
yes, we need to be able to identify content via contentful_id 👍
I am curious why did we have this |
Yeah. I'm sorry I forgot the history already but the tldr is that it was useful at some point, no longer at some point, but nobody dared removing it. It's a huge drain on the sourcing time as it has to traverse the entire model, just like inference would. |
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.
In theory this is a breaking change if people for some reason have hard-coded ids.
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.
It seems like there is few of things that are (or might be) breaking changes - this would need major version bump? (not a blocker, just let's try not to break user sites that might rely on those)
@@ -110,22 +109,6 @@ ${formatPluginOptionsForCLI(pluginConfig.getOriginalPluginOptions(), errors)}`) | |||
|
|||
let contentTypeItems = contentTypes.items | |||
|
|||
if (process.env.EXPERIMENTAL_CONTENTFUL_SKIP_NORMALIZE_IDS) { | |||
reporter.info( | |||
`Skipping normalization of \`.id\`, this means \`sys\` objects will not get a \`.contentful_id\`` |
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.
Are those sys
objects accessible via schema? If so - that's breaking change
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.
contentful_id will still available, see discussion
Since not every node will get a |
This is correct. This is a potential breaking change has to be a major bump. The original idea was to release this one together with #25249, but the Rich Text fix will need more time to ready for release and will introduce some refactoring work for everyone using Rich Text. Whats the usual strategy to inform the community about major bumps? I guess the Gatsby newsletter and blog? I can make sure that Contentful will use their channels to inform people :) |
A major bump by itself is not a big deal, especially not here, because the most common way of depending on the package is by Ok, let's prepare a major bump. @axe312ger I assume there's no objections on your side since you haven't left any :) |
// We need to add only root level resolvable (assets and entries) | ||
// Derived nodes (markdown or JSON) will be recreated if needed. | ||
const key = `${node.contentful_id}___${ | ||
node.sys.linkType || node.sys.type |
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.
Hmm, I wonder how the nodes can be of type Link while entryList
should contain a fully resolved Contentful API response:
resolvable.add( | ||
`${entry.sys.id}___${entry.sys.linkType || entry.sys.type}` | ||
) | ||
}) | ||
}) | ||
assets.forEach(assetItem => | ||
resolvable.add(`${assetItem.sys.id}___${assetItem.sys.type}`) | ||
resolvable.add( | ||
`${assetItem.sys.id}___${assetItem.sys.linkType || assetItem.sys.type}` | ||
) |
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.
See comment above. We should not have links in here at the first place.
It might be that the test fixtures are wrong/outdated.
* remove obsolete fixId function * there won't be contentful link objects on root level after the response got resolved
@axe312ger was able to resolve outstanding issues. Provided tests hold this PR is good to go. It will require a major bump so let's make sure the current minor branch is stable before we do merge. |
Merge commit message proposal:
|
We published a new canary version. Feel free to give it a try:
It does contain the rich text fixes from #25249 |
Published in |
This is the diff @axe312ger put up in #25948 but with the last necessary fix.
Also leaving some comments to double check.
This change drops the
fixids
function call which was applied to the entire model and is very expensive to the Contentful data set. It was also no longer needed so this is a huge win for sites sourcing from Contentful.