apollographql / apollographql/apollo-tooling
apollo client:codegen Option for different TypeScript enum output
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
Currently, the following GraphQL type
```
enum Color {
RED
BLUE
}
```
generates the following TypeScript type
```
export enum Color {
RED = "RED",
BLUE = "BLUE",
}
```
I would like to have the option to generate the following type instead:
```
export type Color = "RED" | "BLUE";
```
This definition provides the same safety, but is more efficient and works better with TypeScript structural typing.
Unrelated: consider generating `const enum` instead of `enum`.
Contributor guide
Research direction
The issue does not name files or tests. Start by locating the TypeScript GraphQL code-generation path that emits enum declarations and inspect how generator options are defined. Done means adding a supported option for string-union output, preserving the existing enum behavior, and covering both forms with tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100