#10928 90229a5
Thanks @eddeee888! - Add contentComparison?: 'cache-first' | 'disk' to control disk-vs-cache write comparison in watch
mode.
In watch mode the CLI caches the hash of the content it last wrote per file and compares new
output against that cached hash to skip redundant writes. This assumes generated output is a pure
function of the codegen inputs. An output whose content depends on the file's existing content
(e.g. a preset that reads the file and rewrites part of it) breaks that assumption: if the file is
changed on disk and codegen regenerates content identical to a previous run, the cached hash still
matches and the write is skipped, so the on-disk change is never corrected.
contentComparison: 'disk' opts an output into comparing the generated content against the file
on disk instead of the in-memory record of what codegen last wrote, so the file is rewritten when
it was changed externally. It can be set:
by a preset, on the GenerateOptions it returns from buildGeneratesSection, or
on the output config (generates[output].contentComparison) for any output, including plain
plugin outputs without a preset.
When both are present, the preset's value takes precedence. The default, 'cache-first', keeps
the existing in-memory-cache behaviour for outputs that are a pure function of their inputs.
Patch Changes
#10930 448431a
Thanks @eddeee888! - Fix overwrite being ignored for
preset-based generates outputs.
A generates entry that used a preset and set overwrite (e.g. overwrite: { removeStaleFiles: false }) had that setting silently ignored, so in watch mode its
generated files could still be deleted as stale.
The CLI resolved overwrite per generated file by looking the file's path up in config.generates. That fails for a preset: its generates entry is keyed by the preset's baseOutputDir, not by any generated file's path (and a preset can emit files outside that
directory), and the lookup additionally required a plugins key that preset entries don't have.
Both cases fell through to the global config.overwrite (default true).
This PR contains the following updates:
| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@graphql-codegen/cli](https://github.com/dotansimha/graphql-code-generator) ([source](https://github.com/dotansimha/graphql-code-generator/tree/HEAD/packages/graphql-codegen-cli)) | [`7.3.1` → `7.4.0`](https://renovatebot.com/diffs/npm/@graphql-codegen%2fcli/7.3.1/7.4.0) |  |  |
---
### Release Notes
<details>
<summary>dotansimha/graphql-code-generator (@​graphql-codegen/cli)</summary>
### [`v7.4.0`](https://github.com/dotansimha/graphql-code-generator/blob/HEAD/packages/graphql-codegen-cli/CHANGELOG.md#740)
[Compare Source](https://github.com/dotansimha/graphql-code-generator/compare/@graphql-codegen/cli@7.3.1...@graphql-codegen/cli@7.4.0)
##### Minor Changes
- [#​10928](https://github.com/dotansimha/graphql-code-generator/pull/10928)
[`90229a5`](https://github.com/dotansimha/graphql-code-generator/commit/90229a5406ffeaa16422a0172340fcb53b94b1b9)
Thanks [@​eddeee888](https://github.com/eddeee888)! - Add
`contentComparison?: 'cache-first' | 'disk'` to control disk-vs-cache write comparison in watch
mode.
In watch mode the CLI caches the hash of the content it last wrote per file and compares new
output against that cached hash to skip redundant writes. This assumes generated output is a pure
function of the codegen inputs. An output whose content depends on the file's existing content
(e.g. a preset that reads the file and rewrites part of it) breaks that assumption: if the file is
changed on disk and codegen regenerates content identical to a previous run, the cached hash still
matches and the write is skipped, so the on-disk change is never corrected.
`contentComparison: 'disk'` opts an output into comparing the generated content against the file
on disk instead of the in-memory record of what codegen last wrote, so the file is rewritten when
it was changed externally. It can be set:
- by a preset, on the `GenerateOptions` it returns from `buildGeneratesSection`, or
- on the output config (`generates[output].contentComparison`) for any output, including plain
plugin outputs without a preset.
When both are present, the preset's value takes precedence. The default, `'cache-first'`, keeps
the existing in-memory-cache behaviour for outputs that are a pure function of their inputs.
##### Patch Changes
- [#​10930](https://github.com/dotansimha/graphql-code-generator/pull/10930)
[`448431a`](https://github.com/dotansimha/graphql-code-generator/commit/448431a6c4bdbfeb68d7e4a3c3d417139f2e1565)
Thanks [@​eddeee888](https://github.com/eddeee888)! - Fix `overwrite` being ignored for
preset-based `generates` outputs.
A `generates` entry that used a preset and set `overwrite` (e.g.
`overwrite: { removeStaleFiles: false }`) had that setting silently ignored, so in watch mode its
generated files could still be deleted as stale.
The CLI resolved `overwrite` per generated file by looking the file's path up in
`config.generates`. That fails for a preset: its `generates` entry is keyed by the preset's
`baseOutputDir`, not by any generated file's path (and a preset can emit files outside that
directory), and the lookup additionally required a `plugins` key that preset entries don't have.
Both cases fell through to the global `config.overwrite` (default `true`).
- Updated dependencies
\[[`90229a5`](https://github.com/dotansimha/graphql-code-generator/commit/90229a5406ffeaa16422a0172340fcb53b94b1b9),
[`448431a`](https://github.com/dotansimha/graphql-code-generator/commit/448431a6c4bdbfeb68d7e4a3c3d417139f2e1565)]:
- [@​graphql-codegen/plugin-helpers](https://github.com/graphql-codegen/plugin-helpers)@​7.3.0
</details>
---
### Configuration
📅 **Schedule**: (UTC)
- Branch creation
- At any time (no schedule defined)
- Automerge
- At any time (no schedule defined)
🚦 **Automerge**: Enabled.
♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update again.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box
---
This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC41Mi4xIiwidXBkYXRlZEluVmVyIjoiNDQuNTIuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This PR contains the following updates:
7.3.1→7.4.0Release Notes
dotansimha/graphql-code-generator (@graphql-codegen/cli)
v7.4.0Compare Source
Minor Changes
#10928
90229a5Thanks @eddeee888! - Add
contentComparison?: 'cache-first' | 'disk'to control disk-vs-cache write comparison in watchmode.
In watch mode the CLI caches the hash of the content it last wrote per file and compares new
output against that cached hash to skip redundant writes. This assumes generated output is a pure
function of the codegen inputs. An output whose content depends on the file's existing content
(e.g. a preset that reads the file and rewrites part of it) breaks that assumption: if the file is
changed on disk and codegen regenerates content identical to a previous run, the cached hash still
matches and the write is skipped, so the on-disk change is never corrected.
contentComparison: 'disk'opts an output into comparing the generated content against the fileon disk instead of the in-memory record of what codegen last wrote, so the file is rewritten when
it was changed externally. It can be set:
GenerateOptionsit returns frombuildGeneratesSection, orgenerates[output].contentComparison) for any output, including plainplugin outputs without a preset.
When both are present, the preset's value takes precedence. The default,
'cache-first', keepsthe existing in-memory-cache behaviour for outputs that are a pure function of their inputs.
Patch Changes
#10930
448431aThanks @eddeee888! - Fix
overwritebeing ignored forpreset-based
generatesoutputs.A
generatesentry that used a preset and setoverwrite(e.g.overwrite: { removeStaleFiles: false }) had that setting silently ignored, so in watch mode itsgenerated files could still be deleted as stale.
The CLI resolved
overwriteper generated file by looking the file's path up inconfig.generates. That fails for a preset: itsgeneratesentry is keyed by the preset'sbaseOutputDir, not by any generated file's path (and a preset can emit files outside thatdirectory), and the lookup additionally required a
pluginskey that preset entries don't have.Both cases fell through to the global
config.overwrite(defaulttrue).Updated dependencies
[
90229a5,448431a]:Configuration
📅 Schedule: (UTC)
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate CLI.