Skip to content

apollo client:codegen Option for different TypeScript enum output #1044

@rautenrieth-da

Description

@rautenrieth-da

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions