dotansimha / dotansimha/graphql-code-generator

If enumValues and enumsAsTypes is set, codegen should emit export type

Open
#7,589 2 comments 1 reaction 0 assignees View on GitHub
core stage/0-issue-prerequisites
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

If we set both `enumValues` and `enumsAsTypes`:
```yml
schema: src/schema.json
overwrite: true
generates:
src/graphql-types.ts:
config:
enumsAsTypes: true
enumValues: ./graphql-enums
plugins:
- typescript
```

It will emit exports in the generated file:
```ts
export { CarStatus };
export { ReservationStatus };
// ...
```
Emitting exports is fine, however because these are just types, they will break **babel**. Instead, it needs to be:
```ts
export type { CarStatus };
export type { ReservationStatus };
// ...
```
This should be controlled by `enumsAsTypes` option which is completely logical, even though the enums are not generated by [graphql-code-generator](https://github.com/dotansimha/graphql-code-generator)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.