Closed renovate[bot] closed 1 year ago
Latest commit: 5169c3affde6f4aea6f8369adb03d140f3a5e9b3
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
This PR contains the following updates:
3.2.1
->3.3.0
4.0.0
->4.2.0
3.0.0
->3.2.0
3.1.0
->3.2.0
Release Notes
dotansimha/graphql-code-generator (@graphql-codegen/cli)
### [`v3.3.0`](https://togithub.com/dotansimha/graphql-code-generator/blob/HEAD/packages/graphql-codegen-cli/CHANGELOG.md#330) [Compare Source](https://togithub.com/dotansimha/graphql-code-generator/compare/@graphql-codegen/cli@3.2.2...@graphql-codegen/cli@3.3.0) ##### Minor Changes - [#9151](https://togithub.com/dotansimha/graphql-code-generator/pull/9151) [`b7dacb21f`](https://togithub.com/dotansimha/graphql-code-generator/commit/b7dacb21fb0ed1173d1e45120dc072e29231ed29) Thanks [@'./user/schema.mappers#UserMapper',](https://togithub.com/'./user/schema.mappers#UserMapper',)! - Add `watchPattern` config option for `generates` sections. 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. ```ts // codegen.ts const config: CodegenConfig = { schema: 'src/schema/**/*.graphql', generates: { 'src/schema/types.ts': { plugins: ['typescript', 'typescript-resolvers'], config: { mappers: { 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']` }, }, }; ``` Then, run Codegen CLI in `watch` mode: ```shell yarn graphql-codegen --watch ``` Now, updating `*.mappers.ts` files re-runs Codegen! π Note: `watchPattern` is only used in `watch` mode i.e. running CLI with `--watch` flag. ##### Patch Changes - Updated dependencies \[[`b7dacb21f`](https://togithub.com/dotansimha/graphql-code-generator/commit/b7dacb21fb0ed1173d1e45120dc072e29231ed29), [`f104619ac`](https://togithub.com/dotansimha/graphql-code-generator/commit/f104619acd27c9d62a06bc577737500880731087)]: - [@graphql-codegen/plugin-helpers](https://togithub.com/graphql-codegen/plugin-helpers)[@4](https://togithub.com/4).2.0 ### [`v3.2.2`](https://togithub.com/dotansimha/graphql-code-generator/blob/HEAD/packages/graphql-codegen-cli/CHANGELOG.md#322) [Compare Source](https://togithub.com/dotansimha/graphql-code-generator/compare/@graphql-codegen/cli@3.2.1...@graphql-codegen/cli@3.2.2) ##### Patch Changes - [#9086](https://togithub.com/dotansimha/graphql-code-generator/pull/9086) [`a34cef35b`](https://togithub.com/dotansimha/graphql-code-generator/commit/a34cef35b4cbbe83c54bd92f88882b325df173fd) Thanks [@beerose](https://togithub.com/beerose)! - dependencies updates: - Updated dependency [`graphql-config@^4.5.0` βοΈ](https://www.npmjs.com/package/graphql-config/v/4.5.0) (from `^4.4.0`, in `dependencies`) - Added dependency [`jiti@^1.17.1` βοΈ](https://www.npmjs.com/package/jiti/v/1.17.1) (to `dependencies`) - Removed dependency [`cosmiconfig-typescript-loader@^4.3.0` βοΈ](https://www.npmjs.com/package/cosmiconfig-typescript-loader/v/4.3.0) (from `dependencies`) - Removed dependency [`ts-node@^10.9.1` βοΈ](https://www.npmjs.com/package/ts-node/v/10.9.1) (from `dependencies`) - [#9086](https://togithub.com/dotansimha/graphql-code-generator/pull/9086) [`a34cef35b`](https://togithub.com/dotansimha/graphql-code-generator/commit/a34cef35b4cbbe83c54bd92f88882b325df173fd) Thanks [@beerose](https://togithub.com/beerose)! - Support `codegen.ts` in ESM projectsdotansimha/graphql-code-generator (@graphql-codegen/plugin-helpers)
### [`v4.2.0`](https://togithub.com/dotansimha/graphql-code-generator/blob/HEAD/packages/utils/plugins-helpers/CHANGELOG.md#420) [Compare Source](https://togithub.com/dotansimha/graphql-code-generator/compare/8af0f220506b077f3cdde9a11bdd489ec1e5bdb5...@graphql-codegen/plugin-helpers@4.2.0) ##### Minor Changes - [#9151](https://togithub.com/dotansimha/graphql-code-generator/pull/9151) [`b7dacb21f`](https://togithub.com/dotansimha/graphql-code-generator/commit/b7dacb21fb0ed1173d1e45120dc072e29231ed29) Thanks [@'./user/schema.mappers#UserMapper',](https://togithub.com/'./user/schema.mappers#UserMapper',)! - Add `watchPattern` config option for `generates` sections. 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. ```ts // codegen.ts const config: CodegenConfig = { schema: 'src/schema/**/*.graphql', generates: { 'src/schema/types.ts': { plugins: ['typescript', 'typescript-resolvers'], config: { mappers: { 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']` }, }, }; ``` Then, run Codegen CLI in `watch` mode: ```shell yarn graphql-codegen --watch ``` Now, updating `*.mappers.ts` files re-runs Codegen! π Note: `watchPattern` is only used in `watch` mode i.e. running CLI with `--watch` flag. ##### Patch Changes - [`f104619ac`](https://togithub.com/dotansimha/graphql-code-generator/commit/f104619acd27c9d62a06bc577737500880731087) Thanks [@saihaj](https://togithub.com/saihaj)! - Resolve issue with nesting fields in `@provides` directive being prevented ### [`v4.1.0`](https://togithub.com/dotansimha/graphql-code-generator/blob/HEAD/packages/utils/plugins-helpers/CHANGELOG.md#410) [Compare Source](https://togithub.com/dotansimha/graphql-code-generator/compare/@graphql-codegen/plugin-helpers@4.0.0...8af0f220506b077f3cdde9a11bdd489ec1e5bdb5) ##### Minor Changes - [#8893](https://togithub.com/dotansimha/graphql-code-generator/pull/8893) [`a118c307a`](https://togithub.com/dotansimha/graphql-code-generator/commit/a118c307a35bbb97b7cbca0f178a88276032a26c) Thanks [@n1ru4l](https://togithub.com/n1ru4l)! - mark `plugins` in config optional - [#8723](https://togithub.com/dotansimha/graphql-code-generator/pull/8723) [`a3309e63e`](https://togithub.com/dotansimha/graphql-code-generator/commit/a3309e63efed880e6f74ce6fcbf82dd3d7857a15) Thanks [@kazekyo](https://togithub.com/kazekyo)! - Introduce a new feature called DocumentTransform. DocumentTransform is a functionality that allows you to modify `documents` before they are processed by plugins. You can use functions passed to the `documentTransforms` option to make changes to GraphQL documents. To use this feature, you can write `documentTransforms` as follows: ```ts import type { CodegenConfig } from '@graphql-codegen/cli'; const config: CodegenConfig = { schema: 'https://localhost:4000/graphql', documents: ['src/**/*.tsx'], generates: { './src/gql/': { preset: 'client', documentTransforms: [ { transform: ({ documents }) => { // Make some changes to the documents return documents; }, }, ], }, }, }; export default config; ``` For instance, to remove a `@localOnlyDirective` directive from `documents`, you can write the following code: ```js import type { CodegenConfig } from '@graphql-codegen/cli'; import { visit } from 'graphql'; const config: CodegenConfig = { schema: 'https://localhost:4000/graphql', documents: ['src/**/*.tsx'], generates: { './src/gql/': { preset: 'client', documentTransforms: [ { transform: ({ documents }) => { return documents.map(documentFile => { documentFile.document = visit(documentFile.document, { Directive: { leave(node) { if (node.name.value === 'localOnlyDirective') return null; }, }, }); return documentFile; }); }, }, ], }, }, }; export default config; ``` DocumentTransform can also be specified by file name. You can create a custom file for a specific transformation and pass it to `documentTransforms`. Let's create the document transform as a file: ```js module.exports = { transform: ({ documents }) => { // Make some changes to the documents return documents; }, }; ``` Then, you can specify the file name as follows: ```ts import type { CodegenConfig } from '@graphql-codegen/cli'; const config: CodegenConfig = { schema: 'https://localhost:4000/graphql', documents: ['src/**/*.tsx'], generates: { './src/gql/': { preset: 'client', documentTransforms: ['./my-document-transform.js'], }, }, }; export default config; ``` ##### Patch Changes - [#8879](https://togithub.com/dotansimha/graphql-code-generator/pull/8879) [`8206b268d`](https://togithub.com/dotansimha/graphql-code-generator/commit/8206b268dfb485a748fd7783a163cb0ee9931491) Thanks [@renovate](https://togithub.com/apps/renovate)! - dependencies updates: - Updated dependency [`tslib@~2.5.0` βοΈ](https://www.npmjs.com/package/tslib/v/2.5.0) (from `~2.4.0`, in `dependencies`)dotansimha/graphql-code-generator (@graphql-codegen/typescript-resolvers)
### [`v3.2.0`](https://togithub.com/dotansimha/graphql-code-generator/blob/HEAD/packages/plugins/typescript/resolvers/CHANGELOG.md#320) [Compare Source](https://togithub.com/dotansimha/graphql-code-generator/compare/@graphql-codegen/typescript-resolvers@3.1.1...@graphql-codegen/typescript-resolvers@3.2.0) ##### Minor Changes - [#9146](https://togithub.com/dotansimha/graphql-code-generator/pull/9146) [`9f4d9c5a4`](https://togithub.com/dotansimha/graphql-code-generator/commit/9f4d9c5a479d34da25df8e060a8c2b3b162647dd) Thanks [@eddeee888](https://togithub.com/eddeee888)! - \[typescript-resolvers] Add `resolversNonOptionalTypename` config option. This is extending on `ResolversUnionTypes` implemented in [https://github.com/dotansimha/graphql-code-generator/pull/9069](https://togithub.com/dotansimha/graphql-code-generator/pull/9069) `resolversNonOptionalTypename` adds non-optional `__typename` to union members of `ResolversUnionTypes`, without affecting the union members' base intefaces. A common use case for non-optional `__typename` of union members is using it as the common field to work out the final schema type. This makes implementing the union's `__resolveType` very simple as we can use `__typename` to decide which union member the resolved object is. Without this, we have to check the existence of field/s on the incoming object which could be verbose. For example, consider this schema: ```graphql type Query { book(id: ID!): BookPayload! } type Book { id: ID! isbn: String! } type BookResult { node: Book } type PayloadError { message: String! } union BookPayload = BookResult | PayloadError ``` *With optional `__typename`:* We need to check existence of certain fields to resolve type in the union resolver: ```ts // Query/book.ts export const book = async () => { try { const book = await fetchBook(); // 1. No `__typename` in resolver results... return { node: book, }; } catch (e) { return { message: 'Failed to fetch book', }; } }; // BookPayload.ts export const BookPayload = { __resolveType: parent => { // 2. ... means more checks in `__resolveType` if ('message' in parent) { return 'PayloadError'; } return 'BookResult'; }, }; ``` *With non-optional `__typename`:* Resolvers declare the type. This which gives us better TypeScript support in resolvers and simplify `__resolveType` implementation: ```ts // Query/book.ts export const book = async () => { try { const book = await fetchBook(); // 1. `__typename` is declared in resolver results... return { __typename: 'BookResult', // 1a. this also types `node` for us π node: book, }; } catch (e) { return { __typename: 'PayloadError', message: 'Failed to fetch book', }; } }; // BookPayload.ts export const BookPayload = { __resolveType: parent => parent.__typename, // 2. ... means a very simple check in `__resolveType` }; ``` *Using `resolversNonOptionalTypename`:* add it into `typescript-resolvers` plugin config: ```ts // codegen.ts const config: CodegenConfig = { schema: 'src/schema/**/*.graphql', generates: { 'src/schema/types.ts': { plugins: ['typescript', 'typescript-resolvers'], config: { resolversNonOptionalTypename: true, // Or `resolversNonOptionalTypename: { unionMember: true }` }, }, }, }; ``` ##### Patch Changes - [#9206](https://togithub.com/dotansimha/graphql-code-generator/pull/9206) [`e56790104`](https://togithub.com/dotansimha/graphql-code-generator/commit/e56790104ae56d6c5b48ef71823345bd09d3b835) Thanks [@eddeee888](https://togithub.com/eddeee888)! - Fix `ResolversUnionTypes` being used in `ResolversParentTypes` Previously, objects with mappable fields are converted to Omit format that references its own type group or `ResolversTypes` or `ResolversParentTypes` e.g. ```ts export type ResolversTypes = { Book: ResolverTypeWrapperConfiguration
π Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
π¦ Automerge: Disabled by config. Please merge this manually once you are satisfied.
β» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
π» Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.
This PR has been generated by Mend Renovate. View repository job log here.