By default, watch mode automatically watches all GraphQL schema and document files. This means when a change is detected, Codegen CLI is run.
A user may want to run Codegen CLI when non-schema and non-document files are changed. Each generates section now has a watchPattern option to allow more file patterns to be added to the list of patterns to watch.
In the example below, mappers are exported from schema.mappers.ts files. We want to re-run Codegen if the content of *.mappers.ts files change because they change the generated types file. To solve this, we can add mapper file patterns to watch using the glob pattern used for schema and document files.
Book: './book/schema.mappers#BookMapper',
},
}
watchPattern: 'src/schema/**/*.mappers.ts', // Watches mapper files in `watch` mode. Use an array for multiple patterns e.g. `['src/*.pattern1.ts','src/*.pattern2.ts']`
},
Dependabot commands
You can trigger Dependabot actions by commenting on this MR
$dependabot rebase will rebase this MR
$dependabot recreate will recreate this MR rewriting all the manual changes and resolving conflicts
Bumps [@graphql-codegen/cli](https://github.com/dotansimha/graphql-code-generator/tree/HEAD/packages/graphql-codegen-cli) from 3.2.2 to 3.3.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/dotansimha/graphql-code-generator/blob/master/packages/graphql-codegen-cli/CHANGELOG.md"><code>@graphql-codegen/cli</code>'s changelog</a>.</em></p>
<blockquote>
<h2>3.3.0</h2>
<h3>Minor Changes</h3>
<ul>
<li>
<p><a href="https://github.com/dotansimha/graphql-code-generator/pull/9151">#9151</a> <a href="https://github.com/dotansimha/graphql-code-generator/commit/b7dacb21fb0ed1173d1e45120dc072e29231ed29"><code>b7dacb21f</code></a> Thanks <a href="https://github.com/'./user/schema.mappers#UserMapper',">@'./user/schema.mappers#UserMapper',</a>! - Add <code>watchPattern</code> config option for <code>generates</code> sections.</p>
<p>By default, <code>watch</code> mode automatically watches all GraphQL schema and document files. This means when a change is detected, Codegen CLI is run.</p>
<p>A user may want to run Codegen CLI when non-schema and non-document files are changed. Each <code>generates</code> section now has a <code>watchPattern</code> option to allow more file patterns to be added to the list of patterns to watch.</p>
<p>In the example below, mappers are exported from <code>schema.mappers.ts</code> files. We want to re-run Codegen if the content of <code>*.mappers.ts</code> files change because they change the generated types file. To solve this, we can add mapper file patterns to watch using the glob pattern used for schema and document files.</p>
<pre lang="ts"><code>// codegen.ts
const config: CodegenConfig = {
schema: 'src/schema/**/*.graphql',
generates: {
'src/schema/types.ts': {
plugins: ['typescript', 'typescript-resolvers'],
config: {
mappers: {
<pre><code> Book: './book/schema.mappers#BookMapper',
},
}
watchPattern: 'src/schema/**/*.mappers.ts', // Watches mapper files in `watch` mode. Use an array for multiple patterns e.g. `['src/*.pattern1.ts','src/*.pattern2.ts']`
},
</code></pre>
<p>},
};
</code></pre></p>
<p>Then, run Codegen CLI in <code>watch</code> mode:</p>
<pre lang="shell"><code>yarn graphql-codegen --watch
</code></pre>
<p>Now, updating <code>*.mappers.ts</code> files re-runs Codegen! 🎉</p>
<p>Note: <code>watchPattern</code> is only used in <code>watch</code> mode i.e. running CLI with <code>--watch</code> flag.</p>
</li>
</ul>
<h3>Patch Changes</h3>
<ul>
<li>Updated dependencies [<a href="https://github.com/dotansimha/graphql-code-generator/commit/b7dacb21fb0ed1173d1e45120dc072e29231ed29"><code>b7dacb21f</code></a>, <a href="https://github.com/dotansimha/graphql-code-generator/commit/f104619acd27c9d62a06bc577737500880731087"><code>f104619ac</code></a>]:
<ul>
<li><code>@graphql-codegen/plugin-helpers</code><a href="https://github.com/4"><code>@4</code></a>.2.0</li>
</ul>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/dotansimha/graphql-code-generator/commit/6e3fd3809f9a13c6faf6e5ce138f53920f3225dc"><code>6e3fd38</code></a> chore(release): update monorepo packages versions (<a href="https://github.com/dotansimha/graphql-code-generator/tree/HEAD/packages/graphql-codegen-cli/issues/9132">#9132</a>)</li>
<li><a href="https://github.com/dotansimha/graphql-code-generator/commit/d318805a1675363f10326db49497c8ddd4647193"><code>d318805</code></a> eslint fixes (<a href="https://github.com/dotansimha/graphql-code-generator/tree/HEAD/packages/graphql-codegen-cli/issues/9247">#9247</a>)</li>
<li><a href="https://github.com/dotansimha/graphql-code-generator/commit/ef60e81999898a38ae1315b5059725e4b9a8fc58"><code>ef60e81</code></a> chore(deps): update dependency prettier to v2.8.7 (<a href="https://github.com/dotansimha/graphql-code-generator/tree/HEAD/packages/graphql-codegen-cli/issues/9223">#9223</a>)</li>
<li><a href="https://github.com/dotansimha/graphql-code-generator/commit/7de3c703bec77b9f2aa87780ceabe0b18f070457"><code>7de3c70</code></a> chore(deps): update dependency prettier to v2.8.6 (<a href="https://github.com/dotansimha/graphql-code-generator/tree/HEAD/packages/graphql-codegen-cli/issues/9215">#9215</a>)</li>
<li><a href="https://github.com/dotansimha/graphql-code-generator/commit/0f535812af32b2acb127d1bebf4b172e24d13266"><code>0f53581</code></a> chore(deps): update dependency prettier to v2.8.5 (<a href="https://github.com/dotansimha/graphql-code-generator/tree/HEAD/packages/graphql-codegen-cli/issues/9204">#9204</a>)</li>
<li><a href="https://github.com/dotansimha/graphql-code-generator/commit/b7dacb21fb0ed1173d1e45120dc072e29231ed29"><code>b7dacb2</code></a> [cli] Add watchPattern to generates config (<a href="https://github.com/dotansimha/graphql-code-generator/tree/HEAD/packages/graphql-codegen-cli/issues/9151">#9151</a>)</li>
<li><a href="https://github.com/dotansimha/graphql-code-generator/commit/ac44d0c6b1925df11a5f18f049eed6fec217002b"><code>ac44d0c</code></a> fix(deps): update graphql-tools (<a href="https://github.com/dotansimha/graphql-code-generator/tree/HEAD/packages/graphql-codegen-cli/issues/9116">#9116</a>)</li>
<li>See full diff in <a href="https://github.com/dotansimha/graphql-code-generator/commits/@graphql-codegen/cli@3.3.0/packages/graphql-codegen-cli">compare view</a></li>
</ul>
</details>
<br />
---
<details>
<summary>Dependabot commands</summary>
<br />
You can trigger Dependabot actions by commenting on this MR
- `$dependabot rebase` will rebase this MR
- `$dependabot recreate` will recreate this MR rewriting all the manual changes and resolving conflicts
</details>
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.
Bumps @graphql-codegen/cli from 3.2.2 to 3.3.0.
Changelog
Sourced from
@graphql-codegen/cli's changelog.Commits
6e3fd38chore(release): update monorepo packages versions (#9132)d318805eslint fixes (#9247)ef60e81chore(deps): update dependency prettier to v2.8.7 (#9223)7de3c70chore(deps): update dependency prettier to v2.8.6 (#9215)0f53581chore(deps): update dependency prettier to v2.8.5 (#9204)b7dacb2[cli] Add watchPattern to generates config (#9151)ac44d0cfix(deps): update graphql-tools (#9116)Dependabot commands
You can trigger Dependabot actions by commenting on this MR
$dependabot rebasewill rebase this MR$dependabot recreatewill recreate this MR rewriting all the manual changes and resolving conflictsadded 7 commits
master9409840c- Build(deps-dev): bump @graphql-codegen/cli from 3.2.2 to 3.3.0Compare with previous version