With this example, we show how you can create a simple rerender-pages
Webiny CLI command that does the following:
- lists all published pages created via the Page Builder application
- visits them and ensures the received HTTP response code is 200
- if not 200, then we rerender the page via a custom
rerenderPage
GraphQL mutation
The mutation can be created by simply registering a new GraphQLSchemaPlugin
plugin.
Check this file api/code/graphql/src/plugins/rerenderPage.ts
to see how it's done. Also, make sure the plugin is imported and registered in api/code/graphql/src/index.ts
file.
Further reading: Extend GraphQL API.
Check this file scripts/rerenderPages.ts
to see how it's done. Also, make sure the plugin is imported and registered in the root webiny.project.ts
file.
Further reading: Adding Custom Commands.
Once all of the above is in place, in your terminal of choice, from your project root, simply run the yarn webiny rerender-pages --env {environment}
command.