Typescript codegen from graphql schema has types issues

I鈥檝e found a solution for this, which involves setting a custom naming function - Duplicate identifier on Typescript type generation due to _ prefix 路 Issue #6925 路 dotansimha/graphql-code-generator 路 GitHub

Using this, I can get the generator to produce the following types output:

export enum CategoryModelOrderBy {
  _CreatedAtAsc = '_createdAt_ASC',
  _CreatedAtDesc = '_createdAt_DESC',
  _FirstPublishedAtAsc = '_firstPublishedAt_ASC',
  _FirstPublishedAtDesc = '_firstPublishedAt_DESC',
  _IsValidAsc = '_isValid_ASC',
  _IsValidDesc = '_isValid_DESC',
  _PublicationScheduledAtAsc = '_publicationScheduledAt_ASC',
  _PublicationScheduledAtDesc = '_publicationScheduledAt_DESC',
  _PublishedAtAsc = '_publishedAt_ASC',
  _PublishedAtDesc = '_publishedAt_DESC',
  _StatusAsc = '_status_ASC',
  _StatusDesc = '_status_DESC',
  _UnpublishingScheduledAtAsc = '_unpublishingScheduledAt_ASC',
  _UnpublishingScheduledAtDesc = '_unpublishingScheduledAt_DESC',
  _UpdatedAtAsc = '_updatedAt_ASC',
  _UpdatedAtDesc = '_updatedAt_DESC',
  CategoryIdAsc = 'categoryId_ASC',
  CategoryIdDesc = 'categoryId_DESC',
  CreatedAtAsc = 'createdAt_ASC',
  CreatedAtDesc = 'createdAt_DESC',
  IdAsc = 'id_ASC',
  IdDesc = 'id_DESC',
  TitleAsc = 'title_ASC',
  TitleDesc = 'title_DESC',
  UpdatedAtAsc = 'updatedAt_ASC',
  UpdatedAtDesc = 'updatedAt_DESC'
}
1 Like