From 0287531b8f9f851ffd0371cf456ab764c83fe1cd Mon Sep 17 00:00:00 2001 From: Nicolas Charpentier Date: Mon, 25 Sep 2023 14:27:30 -0400 Subject: [PATCH 1/3] Add `futureProofEnums` to client-preset config --- packages/presets/client/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/presets/client/src/index.ts b/packages/presets/client/src/index.ts index 1eb9259c794..f978fc608dd 100644 --- a/packages/presets/client/src/index.ts +++ b/packages/presets/client/src/index.ts @@ -126,6 +126,7 @@ export const preset: Types.OutputPreset = { skipTypename: options.config.skipTypename, arrayInputCoercion: options.config.arrayInputCoercion, enumsAsTypes: options.config.enumsAsTypes, + futureProofEnums: options.config.futureProofEnums, dedupeFragments: options.config.dedupeFragments, nonOptionalTypename: options.config.nonOptionalTypename, avoidOptionals: options.config.avoidOptionals, From ee04099f9623b8c541208e906358e08dc96f0f53 Mon Sep 17 00:00:00 2001 From: Nicolas Charpentier Date: Mon, 25 Sep 2023 14:27:45 -0400 Subject: [PATCH 2/3] Update client's `config` docs --- website/src/pages/plugins/presets/preset-client.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/website/src/pages/plugins/presets/preset-client.mdx b/website/src/pages/plugins/presets/preset-client.mdx index 49b26bf217b..f2c7c139c9d 100644 --- a/website/src/pages/plugins/presets/preset-client.mdx +++ b/website/src/pages/plugins/presets/preset-client.mdx @@ -52,6 +52,7 @@ The `client` preset allows the following `config` options: - [`skipTypename`](/plugins/typescript/typescript#skiptypename): Does not add `__typename` to the generated types, unless it was specified in the selection set. - [`arrayInputCoercion`](/plugins/typescript/typescript-operations#arrayinputcoercion): The [GraphQL spec](https://spec.graphql.org/draft/#sel-FAHjBJFCAACE_Gh7d) allows arrays and a single primitive value for list input. This allows to deactivate that behavior to only accept arrays instead of single values. - [`enumsAsTypes`](/plugins/typescript/typescript#enumsastypes): Generates enum as TypeScript string union `type` instead of an `enum`. Useful if you wish to generate `.d.ts` declaration file instead of `.ts`, or if you want to avoid using TypeScript enums due to bundle size concerns. +- [`futureProofEnums`](/plugins/typescript/typescript#futureproofenums): Adds a catch-all entry to enum type definitions for values that may be added in the future. - [`dedupeFragments`](/plugins/typescript/typescript#dedupefragments): Removes fragment duplicates for reducing data transfer. It is done by removing sub-fragments imports from fragment definition. - [`nonOptionalTypename`](/plugins/typescript/typescript#nonoptionaltypename): Automatically adds `__typename` field to the generated types, even when they are not specified in the selection set, and makes it non-optional. - [`avoidOptionals`](/plugins/typescript/typescript#avoidoptionals): This will cause the generator to avoid using TypeScript optionals (`?`) on types. From 224d49e0e4648b7725d54a6deef21ffa942bb354 Mon Sep 17 00:00:00 2001 From: Nicolas Charpentier Date: Mon, 25 Sep 2023 14:31:23 -0400 Subject: [PATCH 3/3] Add changeset --- .changeset/chilled-impalas-prove.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/chilled-impalas-prove.md diff --git a/.changeset/chilled-impalas-prove.md b/.changeset/chilled-impalas-prove.md new file mode 100644 index 00000000000..0b423b6e317 --- /dev/null +++ b/.changeset/chilled-impalas-prove.md @@ -0,0 +1,5 @@ +--- +'@graphql-codegen/client-preset': minor +--- + +The client preset now allows the use of the `futureProofEnums` config option