eddeee888 / graphql-code-generator-plugins

List of GraphQL Code Generator plugins that complements the official plugins.
MIT License
50 stars 12 forks source link

Update graphqlcodegenerator monorepo #107

Closed renovate[bot] closed 1 year ago

renovate[bot] commented 1 year ago

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
@graphql-codegen/cli 3.2.1 -> 3.3.0 age adoption passing confidence
@graphql-codegen/plugin-helpers 4.0.0 -> 4.2.0 age adoption passing confidence
@graphql-codegen/typescript-resolvers 3.0.0 -> 3.2.0 age adoption passing confidence
@graphql-codegen/typescript-resolvers 3.1.0 -> 3.2.0 age adoption passing confidence

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 projects
dotansimha/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: ResolverTypeWrapper; BookPayload: ResolversTypes['BookResult'] | ResolversTypes['StandardError']; // Note: `result` on the next line references `ResolversTypes["Book"]` BookResult: ResolverTypeWrapper & { result?: Maybe }>; StandardError: ResolverTypeWrapper; }; export type ResolversParentTypes = { Book: BookMapper; BookPayload: ResolversParentTypes['BookResult'] | ResolversParentTypes['StandardError']; // Note: `result` on the next line references `ResolversParentTypes["Book"]` BookResult: Omit & { result?: Maybe }; StandardError: StandardError; }; ``` In [https://github.com/dotansimha/graphql-code-generator/pull/9069](https://togithub.com/dotansimha/graphql-code-generator/pull/9069), we extracted resolver union types to its own group: ```ts export type ResolversUnionTypes = { // Note: `result` on the next line references `ResolversTypes["Book"]` which is only correct for the `ResolversTypes` case BookPayload: (Omit & { result?: Maybe }) | StandardError; }; export type ResolversTypes = { Book: ResolverTypeWrapper; BookPayload: ResolverTypeWrapper; BookResult: ResolverTypeWrapper & { result?: Maybe }>; StandardError: ResolverTypeWrapper; }; export type ResolversParentTypes = { Book: BookMapper; BookPayload: ResolversUnionTypes['BookPayload']; BookResult: Omit & { result?: Maybe }; StandardError: StandardError; }; ``` This change creates an extra `ResolversUnionParentTypes` that is referenced by `ResolversParentTypes` to ensure backwards compatibility: ```ts export type ResolversUnionTypes = { BookPayload: (Omit & { result?: Maybe }) | StandardError; }; // ... and the reference is changed in ResolversParentTypes: export type ResolversParentTypes = { // ... other fields BookPayload: ResolversUnionParentTypes['BookPayload']; }; ``` - [`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 - Updated dependencies \[[`e56790104`](https://togithub.com/dotansimha/graphql-code-generator/commit/e56790104ae56d6c5b48ef71823345bd09d3b835), [`b7dacb21f`](https://togithub.com/dotansimha/graphql-code-generator/commit/b7dacb21fb0ed1173d1e45120dc072e29231ed29), [`f104619ac`](https://togithub.com/dotansimha/graphql-code-generator/commit/f104619acd27c9d62a06bc577737500880731087), [`92d86b009`](https://togithub.com/dotansimha/graphql-code-generator/commit/92d86b009579edf70f60b0b8e28658af93ff9fd1), [`acb647e4e`](https://togithub.com/dotansimha/graphql-code-generator/commit/acb647e4efbddecf732b6e55dc47ac40c9bdaf08), [`9f4d9c5a4`](https://togithub.com/dotansimha/graphql-code-generator/commit/9f4d9c5a479d34da25df8e060a8c2b3b162647dd)]: - [@​graphql-codegen/visitor-plugin-common](https://togithub.com/graphql-codegen/visitor-plugin-common)[@​3](https://togithub.com/3).1.0 - [@​graphql-codegen/plugin-helpers](https://togithub.com/graphql-codegen/plugin-helpers)[@​4](https://togithub.com/4).2.0 - [@​graphql-codegen/typescript](https://togithub.com/graphql-codegen/typescript)[@​3](https://togithub.com/3).0.3 ### [`v3.1.1`](https://togithub.com/dotansimha/graphql-code-generator/blob/HEAD/packages/plugins/typescript/resolvers/CHANGELOG.md#​311) [Compare Source](https://togithub.com/dotansimha/graphql-code-generator/compare/a1edaee674bf118f4e352f6864b8ebeb7322851b...@graphql-codegen/typescript-resolvers@3.1.1) ##### Patch Changes - [#​9110](https://togithub.com/dotansimha/graphql-code-generator/pull/9110) [`ba0610bbd`](https://togithub.com/dotansimha/graphql-code-generator/commit/ba0610bbd4578d8a82078014766f56d8ae5fcf7a) Thanks [@​gilgardosh](https://togithub.com/gilgardosh)! - Custom mappers with placeholder will apply omit - [#​9069](https://togithub.com/dotansimha/graphql-code-generator/pull/9069) [`4b49f6fbe`](https://togithub.com/dotansimha/graphql-code-generator/commit/4b49f6fbed802907b460bfb7b6e9a85f88c555bc) Thanks [@​eddeee888](https://togithub.com/eddeee888)! - Extract union types to ResolversUnionTypes - Updated dependencies \[[`ba0610bbd`](https://togithub.com/dotansimha/graphql-code-generator/commit/ba0610bbd4578d8a82078014766f56d8ae5fcf7a), [`4b49f6fbe`](https://togithub.com/dotansimha/graphql-code-generator/commit/4b49f6fbed802907b460bfb7b6e9a85f88c555bc), [`b343626c9`](https://togithub.com/dotansimha/graphql-code-generator/commit/b343626c978b9ee0f14e314cea6c01ae3dad057c)]: - [@​graphql-codegen/visitor-plugin-common](https://togithub.com/graphql-codegen/visitor-plugin-common)[@​3](https://togithub.com/3).0.2 - [@​graphql-codegen/typescript](https://togithub.com/graphql-codegen/typescript)[@​3](https://togithub.com/3).0.2 ### [`v3.1.0`](https://togithub.com/dotansimha/graphql-code-generator/blob/HEAD/packages/plugins/typescript/resolvers/CHANGELOG.md#​310) [Compare Source](https://togithub.com/dotansimha/graphql-code-generator/compare/@graphql-codegen/typescript-resolvers@3.0.0...a1edaee674bf118f4e352f6864b8ebeb7322851b) ##### Minor Changes - [#​8853](https://togithub.com/dotansimha/graphql-code-generator/pull/8853) [`b13aa7449`](https://togithub.com/dotansimha/graphql-code-generator/commit/b13aa7449637eaf28976ea7e31730b0290609919) Thanks [@​KGAdamCook](https://togithub.com/KGAdamCook)! - Updated customResolveInfo to use the correct importType for external imports ##### 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`) - Updated dependencies \[[`8206b268d`](https://togithub.com/dotansimha/graphql-code-generator/commit/8206b268dfb485a748fd7783a163cb0ee9931491), [`8206b268d`](https://togithub.com/dotansimha/graphql-code-generator/commit/8206b268dfb485a748fd7783a163cb0ee9931491), [`8206b268d`](https://togithub.com/dotansimha/graphql-code-generator/commit/8206b268dfb485a748fd7783a163cb0ee9931491), [`a118c307a`](https://togithub.com/dotansimha/graphql-code-generator/commit/a118c307a35bbb97b7cbca0f178a88276032a26c), [`6b6fe3cbc`](https://togithub.com/dotansimha/graphql-code-generator/commit/6b6fe3cbcc7de748754703adce0f62f3e070a098), [`a3309e63e`](https://togithub.com/dotansimha/graphql-code-generator/commit/a3309e63efed880e6f74ce6fcbf82dd3d7857a15)]: - [@​graphql-codegen/plugin-helpers](https://togithub.com/graphql-codegen/plugin-helpers)[@​4](https://togithub.com/4).1.0 - [@​graphql-codegen/typescript](https://togithub.com/graphql-codegen/typescript)[@​3](https://togithub.com/3).0.1 - [@​graphql-codegen/visitor-plugin-common](https://togithub.com/graphql-codegen/visitor-plugin-common)[@​3](https://togithub.com/3).0.1

Configuration

πŸ“… 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.

changeset-bot[bot] commented 1 year ago

⚠️ No Changeset found

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.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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