Skip to content

Commit df29dc9

Browse files
gatsbybotpieh
andauthored
fix(gatsby): write out sq files when result doesn't change but query hash changes (#36997) (#37004)
Co-authored-by: Lennart <lekoarts@gmail.com> (cherry picked from commit 3e87026) Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
1 parent 0c6cd61 commit df29dc9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

packages/gatsby/src/query/query-runner.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,22 @@ export async function queryRunner(
183183
.digest(`base64`)
184184

185185
const resultHashCache = getResultHashCache()
186+
187+
let resultHashCacheKey = queryJob.id
188+
if (queryJob.queryType === `static`) {
189+
// For static queries we use hash for a file path we output results to.
190+
// With automatic sort and aggregation graphql codemod it is possible
191+
// to have same result, but different query text hashes which would skip
192+
// writing out file to disk if we don't check query hash as well
193+
resultHashCacheKey += `-${queryJob.hash}`
194+
}
195+
186196
if (
187-
resultHash !== (await resultHashCache.get(queryJob.id)) ||
197+
resultHash !== (await resultHashCache.get(resultHashCacheKey)) ||
188198
(queryJob.queryType === `page` &&
189199
!pageDataExists(path.join(program.directory, `public`), queryJob.id))
190200
) {
191-
await resultHashCache.set(queryJob.id, resultHash)
201+
await resultHashCache.set(resultHashCacheKey, resultHash)
192202

193203
if (queryJob.queryType === `page` || queryJob.queryType === `slice`) {
194204
// We need to save this temporarily in cache because

0 commit comments

Comments
 (0)