From df29dc927f698582e3bf71dd59455c172a92c1aa Mon Sep 17 00:00:00 2001 From: GatsbyJS Bot Date: Thu, 10 Nov 2022 00:01:58 -0700 Subject: [PATCH 1/2] fix(gatsby): write out sq files when result doesn't change but query hash changes (#36997) (#37004) Co-authored-by: Lennart (cherry picked from commit 3e87026e73b9a2c539b343b8e4ddd32b8cd4b11f) Co-authored-by: Michal Piechowiak --- packages/gatsby/src/query/query-runner.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/gatsby/src/query/query-runner.ts b/packages/gatsby/src/query/query-runner.ts index ca5bda33573fe..c1caabd13e1c1 100644 --- a/packages/gatsby/src/query/query-runner.ts +++ b/packages/gatsby/src/query/query-runner.ts @@ -183,12 +183,22 @@ export async function queryRunner( .digest(`base64`) const resultHashCache = getResultHashCache() + + let resultHashCacheKey = queryJob.id + if (queryJob.queryType === `static`) { + // For static queries we use hash for a file path we output results to. + // With automatic sort and aggregation graphql codemod it is possible + // to have same result, but different query text hashes which would skip + // writing out file to disk if we don't check query hash as well + resultHashCacheKey += `-${queryJob.hash}` + } + if ( - resultHash !== (await resultHashCache.get(queryJob.id)) || + resultHash !== (await resultHashCache.get(resultHashCacheKey)) || (queryJob.queryType === `page` && !pageDataExists(path.join(program.directory, `public`), queryJob.id)) ) { - await resultHashCache.set(queryJob.id, resultHash) + await resultHashCache.set(resultHashCacheKey, resultHash) if (queryJob.queryType === `page` || queryJob.queryType === `slice`) { // We need to save this temporarily in cache because From 3007cd39c045ba0a1069a03f8ba343cc7af6ed69 Mon Sep 17 00:00:00 2001 From: pieh Date: Thu, 10 Nov 2022 08:08:14 +0100 Subject: [PATCH 2/2] chore(release): Publish - gatsby@5.0.1 --- packages/gatsby/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index 9d313ce275363..af83e974eca4d 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -1,7 +1,7 @@ { "name": "gatsby", "description": "Blazing fast modern site generator for React", - "version": "5.0.0", + "version": "5.0.1", "author": "Kyle Mathews ", "bin": { "gatsby": "./cli.js"