Skip to content

Commit 58d28a7

Browse files
authored
Add futureProofEnums config to client preset (#9683)
* Add `futureProofEnums` to client-preset config * Update client's `config` docs * Add changeset
1 parent 5d6b6d9 commit 58d28a7

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

.changeset/chilled-impalas-prove.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/client-preset': minor
3+
---
4+
5+
The client preset now allows the use of the `futureProofEnums` config option

packages/presets/client/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export const preset: Types.OutputPreset<ClientPresetConfig> = {
126126
skipTypename: options.config.skipTypename,
127127
arrayInputCoercion: options.config.arrayInputCoercion,
128128
enumsAsTypes: options.config.enumsAsTypes,
129+
futureProofEnums: options.config.futureProofEnums,
129130
dedupeFragments: options.config.dedupeFragments,
130131
nonOptionalTypename: options.config.nonOptionalTypename,
131132
avoidOptionals: options.config.avoidOptionals,

website/src/pages/plugins/presets/preset-client.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ The `client` preset allows the following `config` options:
5252
- [`skipTypename`](/plugins/typescript/typescript#skiptypename): Does not add `__typename` to the generated types, unless it was specified in the selection set.
5353
- [`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.
5454
- [`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.
55+
- [`futureProofEnums`](/plugins/typescript/typescript#futureproofenums): Adds a catch-all entry to enum type definitions for values that may be added in the future.
5556
- [`dedupeFragments`](/plugins/typescript/typescript#dedupefragments): Removes fragment duplicates for reducing data transfer. It is done by removing sub-fragments imports from fragment definition.
5657
- [`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.
5758
- [`avoidOptionals`](/plugins/typescript/typescript#avoidoptionals): This will cause the generator to avoid using TypeScript optionals (`?`) on types.

0 commit comments

Comments
 (0)