-
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
createPages() does not re-run when files change #1514
Comments
I'm exploring the wordpress-source plugin - "Seems like if people are creating pages based on graphql data, it will be important that changes to that data trigger new pages to be created" pretty much sums it up: if creating pages from any graphql data source is it the expected behaviour to have to run the build process again on save/ data change? |
Hey! Thanks for bringing this up. This is definitely the plan. Was actually hoping to get this done before v1 launch but it's one of the features that got edited out of the launch plan and postponed. Everything is setup already to do this. I even documented things for this haha https://www.gatsbyjs.org/docs/node-apis/#createPagesStatefully Anyways, the algorithm will be basically
Should work well. Lemme know if you want to take this on and I can give you some more pointers! |
Would that be a (in my case [source-wordpress]) plugin level change or something 'deeper in the core'? Would love to crack this though just finding my feet with gatsby - so probably need some hand-holding. |
@chrisk2020 it's a core issue but fairly tricky. Making this change requires understanding core well. Feel free to dive in though! Happy to help you along where can. |
@KyleAMathews This is what I learned:
And these are my issues:
My work so far (as little as it is) is in this commit: andrewagain@a9e32dd Any light you can shed on these would be appreciated. Thanks! |
@KyleAMathews This is definitely something that will make its way into the |
@sebastienfi this is a core Gatsby concern that needs to work for everyone. @ahfarmer You need to wait until all transformer plugins have finished running. For example, you could add a new markdown file to your site which triggers the creation of a new File node. If you tried to create a page based on Markdown at that point, nothing would happen. Instead you want to wait for the somewhat poorly named You'll also want to listen for new nodes being created as It doesn't matter which plugins created the pages. You'll just take a snapshot of the pages data before running |
Some code links
|
@KyleAMathews AWESOME this clarifies everything. I'll take another stab at this tonight. |
@KyleAMathews I'm getting really close here. The last thing I have to do is the page deletion as you described. I'm not sure how to deal with Is there a way to differentiate pages created statefully from those that were not? Thank you! BTW the changes I'm working with are here: |
Sorry to bring this up on such an old issue - but was there ever any solution to re-run createPages when source changes from something like |
…th GraphQL, and programmatic pages (gatsbyjs#1879) * WIP * WIP * WIP * WIP * Don't create a connection for the Site node * WIP * WIP * WIP * Empty out queuedDirtyActions after running initial queries * Update tests/snapshots * Re-run createPages when nodes are added/removed fixes gatsbyjs#1514 * Edit last bit of page * Link up tutorial
Recently switched to using
createPages()
ingatsby-node.js
for some of my similar pages. Noticed that changes to my data do not trigger updates to my pages.createPages()
seems to only be called once during startup. Would be nice if it was called again when my data changes.Related issues:
#987
#1315
More details:
I'm using
gatsby-transformer-json
and I'm querying that data with graphql increatePages()
. I'm creating one page for each object found in my JSON file.Seems like if people are creating pages based on graphql data, it will be important that changes to that data trigger new pages to be created.
I've attached a simplified version of my use-case.
gatsby-json-update-test.zip
Versions:
Gatsby 1.2.0
Node v6.10.2
Mac 10.12.5
The text was updated successfully, but these errors were encountered: