prisma-labs / graphqlgen

⚙️ Generate type-safe resolvers based upon your GraphQL Schema
MIT License
818 stars 54 forks source link

graphql enum results in incorrect suggested model #413

Open jasonkuhrt opened 5 years ago

jasonkuhrt commented 5 years ago

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

nunovieira commented 5 years ago

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 commented 5 years ago

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

jasonkuhrt commented 5 years ago

@nunovieira Thanks, example fixed