Skip to content

Commit

Permalink
prevent node to be put in garbage when builded from cache
Browse files Browse the repository at this point in the history
By touching the node it will prevent the node to fail the stale check.

https://www.gatsbyjs.org/docs/bound-action-creators/#touchNode
  • Loading branch information
mathieuforest authored Mar 26, 2018
1 parent a60608d commit d918610
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ const SearchIndex = new GraphQLScalarType({
},
});

exports.sourceNodes = async ({ getNodes, boundActionCreators }) => {
const {
touchNode,
} = boundActionCreators

const existingNodes = getNodes().filter(
n => n.internal.owner === `@andrew-codes/gatsby-plugin-elasticlunr-search`
)
existingNodes.forEach(n => touchNode(n.id))
};

exports.onCreateNode = ({node, boundActionCreators, getNode}, {
resolvers,
}) => {
Expand Down

0 comments on commit d918610

Please sign in to comment.