Skip to content

Commit

Permalink
compare both query text and hash when checking if we need to rerun St…
Browse files Browse the repository at this point in the history
…aticQuery (#7846)

* compare both query text and hash when checking if we need to rerun staticquery

* more context on checking query text + fix typo
  • Loading branch information
pieh authored and m-allanson committed Sep 4, 2018
1 parent 512de27 commit 0b7f11e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/gatsby/src/internal-plugins/query-runner/query-watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,18 @@ const handleQuery = (
// If this is a static query
// Add action / reducer + watch staticquery files
if (query.isStaticQuery) {
const isNewQuery = !staticQueryComponents.has(query.jsonName)
const oldQuery = staticQueryComponents.get(query.jsonName)
const isNewQuery = !oldQuery

// Compare query text because text is compiled query with any attached
// fragments and we want to rerun queries if fragments are edited.
// Compare hash because hash is used for identyfing query and
// passing data to component in development. Hash can change if user will
// format query text, but it doesn't mean that compiled text will change.
if (
isNewQuery ||
staticQueryComponents.get(query.jsonName).query !== query.text
oldQuery.hash !== query.hash ||
oldQuery.text !== query.text
) {
boundActionCreators.replaceStaticQuery({
name: query.name,
Expand Down

0 comments on commit 0b7f11e

Please sign in to comment.