@graphql-codegen/cli 7.3.1 → 7.4.0-alpha-20260831150731-308349d17a63278dee2bccc6aaac7be3ced4bf55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/codegen.js CHANGED
@@ -378,6 +378,9 @@ async function executeCodegen(input) {
378
378
  filename: outputArgs.filename,
379
379
  content: output,
380
380
  hooks: outputConfig.hooks || {},
381
+ // A preset sets `outputArgs` per output via `buildGeneratesSection`.
382
+ // Fall back to `outputConfig` so plugin outputs can opt in too.
383
+ contentComparison: outputArgs.contentComparison ?? outputConfig.contentComparison,
381
384
  });
382
385
  };
383
386
  await context.profiler.run(() => Promise.all(outputs.map(process)), `Codegen: ${filename}`);
@@ -37,6 +37,10 @@ async function generate(input, saveToFile = true) {
37
37
  }
38
38
  previouslyGeneratedFilenames = filenames;
39
39
  }
40
+ // Records the hash of the content codegen last wrote per file. This is always
41
+ // kept up to date; `FileOutput.contentComparison` only decides whether the
42
+ // skip-check trusts this record ('cache-first') or re-reads the file from disk
43
+ // ('disk'), for outputs whose content depends on the file's existing content.
40
44
  const recentOutputHash = new Map();
41
45
  async function writeOutput(generationResult) {
42
46
  if (!saveToFile) {
@@ -49,9 +53,24 @@ async function generate(input, saveToFile = true) {
49
53
  await (0, hooks_js_1.lifecycleHooks)(config.hooks).beforeAllFileWrite(generationResult.map(r => r.filename));
50
54
  }, 'Lifecycle: beforeAllFileWrite');
51
55
  await context.profiler.run(() => Promise.all(generationResult.map(async (result) => {
52
- const previousHash = recentOutputHash.get(result.filename) || (await hashFile(result.filename));
56
+ // The "previous" hash the skip-check compares against:
57
+ // - 'cache-first' trusts the in-memory record of what codegen last wrote
58
+ // (falling back to disk when there's no entry).
59
+ // - 'disk' always re-reads the file, because the output's content
60
+ // depends on the file's existing content
61
+ // (e.g. a preset that reads the file and rewrites part of it), so the
62
+ // in-memory record could wrongly skip a write when the file was changed
63
+ // on disk but the regenerated content matches a previous run.
64
+ const previousHash = await (async function getPreviousHash() {
65
+ const { contentComparison = 'cache-first' } = result;
66
+ if (contentComparison === 'disk') {
67
+ return await hashFile(result.filename);
68
+ }
69
+ return recentOutputHash.get(result.filename) || (await hashFile(result.filename));
70
+ })();
53
71
  const exists = previousHash !== null;
54
- // Store previous hash to avoid reading from disk again
72
+ // Always update the cache, regardless of `cache-first` or `disk` option,
73
+ // so subsequent runs have consistent entry to compare against
55
74
  if (previousHash) {
56
75
  recentOutputHash.set(result.filename, previousHash);
57
76
  }
package/cjs/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = '7.3.1';
4
+ exports.version = '7.4.0-alpha-20260831150731-308349d17a63278dee2bccc6aaac7be3ced4bf55';
package/esm/codegen.js CHANGED
@@ -374,6 +374,9 @@ export async function executeCodegen(input) {
374
374
  filename: outputArgs.filename,
375
375
  content: output,
376
376
  hooks: outputConfig.hooks || {},
377
+ // A preset sets `outputArgs` per output via `buildGeneratesSection`.
378
+ // Fall back to `outputConfig` so plugin outputs can opt in too.
379
+ contentComparison: outputArgs.contentComparison ?? outputConfig.contentComparison,
377
380
  });
378
381
  };
379
382
  await context.profiler.run(() => Promise.all(outputs.map(process)), `Codegen: ${filename}`);
@@ -33,6 +33,10 @@ export async function generate(input, saveToFile = true) {
33
33
  }
34
34
  previouslyGeneratedFilenames = filenames;
35
35
  }
36
+ // Records the hash of the content codegen last wrote per file. This is always
37
+ // kept up to date; `FileOutput.contentComparison` only decides whether the
38
+ // skip-check trusts this record ('cache-first') or re-reads the file from disk
39
+ // ('disk'), for outputs whose content depends on the file's existing content.
36
40
  const recentOutputHash = new Map();
37
41
  async function writeOutput(generationResult) {
38
42
  if (!saveToFile) {
@@ -45,9 +49,24 @@ export async function generate(input, saveToFile = true) {
45
49
  await lifecycleHooks(config.hooks).beforeAllFileWrite(generationResult.map(r => r.filename));
46
50
  }, 'Lifecycle: beforeAllFileWrite');
47
51
  await context.profiler.run(() => Promise.all(generationResult.map(async (result) => {
48
- const previousHash = recentOutputHash.get(result.filename) || (await hashFile(result.filename));
52
+ // The "previous" hash the skip-check compares against:
53
+ // - 'cache-first' trusts the in-memory record of what codegen last wrote
54
+ // (falling back to disk when there's no entry).
55
+ // - 'disk' always re-reads the file, because the output's content
56
+ // depends on the file's existing content
57
+ // (e.g. a preset that reads the file and rewrites part of it), so the
58
+ // in-memory record could wrongly skip a write when the file was changed
59
+ // on disk but the regenerated content matches a previous run.
60
+ const previousHash = await (async function getPreviousHash() {
61
+ const { contentComparison = 'cache-first' } = result;
62
+ if (contentComparison === 'disk') {
63
+ return await hashFile(result.filename);
64
+ }
65
+ return recentOutputHash.get(result.filename) || (await hashFile(result.filename));
66
+ })();
49
67
  const exists = previousHash !== null;
50
- // Store previous hash to avoid reading from disk again
68
+ // Always update the cache, regardless of `cache-first` or `disk` option,
69
+ // so subsequent runs have consistent entry to compare against
51
70
  if (previousHash) {
52
71
  recentOutputHash.set(result.filename, previousHash);
53
72
  }
package/esm/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '7.3.1';
1
+ export const version = '7.4.0-alpha-20260831150731-308349d17a63278dee2bccc6aaac7be3ced4bf55';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/cli",
3
- "version": "7.3.1",
3
+ "version": "7.4.0-alpha-20260831150731-308349d17a63278dee2bccc6aaac7be3ced4bf55",
4
4
  "peerDependenciesMeta": {
5
5
  "@parcel/watcher": {
6
6
  "optional": true
@@ -45,7 +45,7 @@
45
45
  "yargs": "^18.0.0",
46
46
  "@graphql-codegen/client-preset": "^6.1.3",
47
47
  "@graphql-codegen/core": "^6.2.0",
48
- "@graphql-codegen/plugin-helpers": "^7.2.1"
48
+ "@graphql-codegen/plugin-helpers": "^7.3.0-alpha-20260831150731-308349d17a63278dee2bccc6aaac7be3ced4bf55"
49
49
  },
50
50
  "repository": {
51
51
  "type": "git",