Here is a similar question that I answered before.
Is it possible to abort the generation of the specific page that failed so it's not generated
Yes. You can do that in gatsby-node.js
:
const path = require(`path`)
exports.createPages = ({ graphql, actions }) => {
const { createPage, deletePage } = actions
const template = path.resolve(`src/templates/template.js`)
return graphql(`
// your query
`, { limit: 10000 }).then(result => {
if (result.errors) {
throw result.errors
}
result.data.allMarkdownRemark.edges.forEach(edge => {
// ##### Abort page generation HERE #######
// Find a graphQL attribute that is undefined or null only when your call fails
// I use callSuccess as an example. It could be the frontmatter or whatever
if (edge.callSuccess != null) { // Only generate a page when the call is successful
createPage({
path: `${edge.node.frontmatter.slug}`,
component: template ,
context: {},
})
}
deletePage(page); // otherwise delete page
})
}
and I can redeploy the others safely without overriding the one that failed?
There is no easy way for this. Gatsby rebuilds all the pages with every build. I am not aware of retrieving pages of previous builds. Maybe there is a way to query your external service again and retrieve the data this way.