-
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
feat(gatsby): Expose plugin-specific refresh endpoint in gatsby-serve #27931
Conversation
Does this work to keep around untouched nodes from plugins that aren't being refreshed? Or will selectively refreshing 1 plugin incidentally garbage collect all the nodes from another plugin? |
@TylerBarnes the other nodes should stick around, based on my testing when you hit |
e2e-tests/development-runtime/cypress/integration/gatsby-preview/refreshing.js
Outdated
Show resolved
Hide resolved
3a2f286
to
6c75f63
Compare
e2e-tests/development-runtime/plugins/gatsby-source-fake-data/api.js
Outdated
Show resolved
Hide resolved
e2e-tests/development-runtime/plugins/gatsby-source-fake-data/gatsby-node.js
Outdated
Show resolved
Hide resolved
c4e34c7
to
4a871d1
Compare
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.
Thanks @sslotsky! You did it , this is amazing! ❤️
Woo 🎉 so stoked for this! Amazing work @sslotsky ! |
Description
In order to use incremental builds for preview, we need to be able to refresh content through
gatsby-serve
, and we need to be able to refresh content from a single data source - that being the one that sends the webhook.The server currently exposes a
/__refresh
endpoint that refreshes all content. This PR adds a/__refresh/:plugin_name
endpoint that will refresh content only for the specified plugin.Documentation
Testing
1. Build a Gatsby Site
gatsby
is running (e.g. viayarn watch --scope=gatsby
in the project root),gatsby-contentful-starter
) usinggatsby-dev --packages=gatsby
Assuming you build
gatsby-contentful-starter
you should see some output like this2. Run a regular refresh
Hit the full refresh endpoint using
curl
:This should cause all data sources to refresh. Observe the output again and it should look similar to the original build, e.g.
3. Run a no-op refresh
Using a plugin name that doesn't exist, try the plugin specific refresh endpoint, e.g.
This time it should skip sourcing altogether, since there is no matching plugin to refresh. You should end up with the same number of nodes as the regular refresh had. Sample output:
3. Run a refresh for a single plugin
Now use the plugin-specific refresh hook with a real, matching plugin name:
It should source the nodes from Contentful and end up with the same number of nodes as previous runs.
Related Issues
https://app.clubhouse.io/gatsbyjs/story/18377/only-refresh-relevant-content