Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

graphql enum results in incorrect suggested model #413

Open
jasonkuhrt opened this issue Jan 25, 2019 · 3 comments
Open

graphql enum results in incorrect suggested model #413

jasonkuhrt opened this issue Jan 25, 2019 · 3 comments
Labels
bug/1-repro-available A reproduction exists and needs to be confirmed. kind/bug status/pr-welcome

Comments

@jasonkuhrt
Copy link
Member

jasonkuhrt commented Jan 25, 2019

Given schema:

type SomeType {
  someEnum: SomeEnum
}
enum SomeEnum {
  A_VALUE
  ANOTHER_VALUE
}

graphqlgen suggests model (when no SomeType model is supplied by user):

export interface SomeType {
  someEnum: string | null
}

but, should be:

type SomeEnum =
  | 'A_VALUE'
  | 'ANOTHER_VALUE'

export interface SomeType {
  someEnum: SomeEnum | null
}

related

@jasonkuhrt jasonkuhrt added the bug/1-repro-available A reproduction exists and needs to be confirmed. label Jan 25, 2019
@nunovieira
Copy link
Contributor

Given that schema, shouldn't the typescript be:

export type SomeEnum = 'A_VALUE' | 'ANOTHER_VALUE'
export interface SomeType {
  someEnum: SomeEnum | null
  someString: string | null
}

@nunovieira
Copy link
Contributor

Looks like only scalar fields are shown in the suggested model.

@jasonkuhrt
Copy link
Member Author

jasonkuhrt commented Jan 25, 2019

@nunovieira Thanks, example fixed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/1-repro-available A reproduction exists and needs to be confirmed. kind/bug status/pr-welcome
Projects
None yet
Development

No branches or pull requests

3 participants