-
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
[gatsby-plugin-mdx] Plugins can't create nodes properly #21804
Comments
Hey @flogy! The As for creating nodes in So correct way to handle this is suggestion number 3 (which require #21592 to be handled) |
Hi @pieh Thanks for your fast reply! Would the created nodes actually survive a restart if they were linked to the I just tryed this but unfortunately I was not able to link them to the parent node (ID of the parent node seems to be If not, I'd go with option 3, but it feels a bit like a workaround to me. |
They should be preserved, but you might also need to use gatsby/packages/gatsby-transformer-json/src/gatsby-node.js Lines 23 to 34 in 4bc595b
But yeah, getting "fake id" is a blocker to make that happen and I don't have insight into this yet (thanks for opening separate issue for it!) |
Very cool! Looking forward to try this again as soon as we have a solution for the "fake id" problem. Using the |
Hi! I'm closing this as a stale issue as in the meantime Gatsby 4 and related packages were released. You can check our Framework Version Support Page to see which versions currently receive active support. If this is a feature request, please create a discussion as we moved feature requests from issues to GitHub Discussions. Please try the mentioned issue on the latest version (using the Thanks! |
Description
Sub-plugins of gatsby-plugin-mdx that are included via
gatsbyRemarkPlugins
array can't properly create nodes. The nodes are only created if cache was cleared before or changes were made to the MDX files. If nothing has changed the sub-plugin's code is not executed and thus no nodes can be created.Steps to reproduce
test
node is available in GraphiQL.For testing that nodes can't be created in
gatsby-node.js
instead (which I tried as workaround as described later in this issue):gatsby-node.js
never appears in the console.Expected result
Having a possibility to create the required nodes consistently.
Actual result
The nodes are only created if cache was cleared before or changes were made to the MDX files. If nothing has changed the sub-plugin's code is not executed and thus no nodes can be created.
Suggestions on how to fix this
I can imagine those three possibilities. The latter two are more like workarounds. Maybe there are even more and cleaner solutions?
gatsby-plugin-mdx
could look for a second exported function (besides the default one) in the sub-plugins that would be called even if all information are taken from the cache. In this function, I could then create my nodes.gatsby-plugin-mdx
could allow disabling the cache.gatsby-node.js
that is executed. Like that, sub-plugins could save all the information they would like to create nodes with to the cache and thegatsby-node.js
- which would be executed on every start - could then get that information from the cache and create the nodes. I actually thought I could use this option, as gatsby-remark-images seems to also work with it'sgatsby-browser.js
, but in my experiments it never executed mygatsby-node.js
when I had my sub-plugin inside thegatsbyRemarkPlugins
array. When I took it out and added it to the main plugins of Gatsby, it worked.Environment
Thanks in advance!
The text was updated successfully, but these errors were encountered: