Graphql-code-generator: inconsistent naming for enums

Created on 20 Jan 2019  路  7Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug
with version 0.16 the uppercase issue with enums is fixed. but there is something with the name of the enum itself that isn't consistent anymore.

this gets generated for the enum:

export enum CIState {
  NONE = "NONE",
  IN_DEVELOPMENT = "IN_DEVELOPMENT",
  IN_USE = "IN_USE",
  IN_REMOVAL = "IN_REMOVAL",
  REMOVED = "REMOVED"
}

and this is the type which references the enum. you'll notice that the enum CIState has a lowercase I in here. this breaks the reference as it is case sensitive. the actual graphql schema has an uppercase I (CIState as in the enum definition)

 export type Desired = {
    ...
    state: Maybe<CiState>;
  };

To Reproduce
don't really have a repro available as the source is cloud source.

Expected behavior
use the name of the graphql schema for naming in all cases.

Schema/Documents
can't porovide the schema

Environment:

  • OS: WIndows 10
  • Codegen: 0.16.0
  • Node: 8.9.1

Additional context
0.15.x used CiState (lower case I) in all places

bug plugins waiting-for-release

Most helpful comment

@SoyYoRafa you can ask for no naming changes like this:

generates:
  ./src/types/types.ts:
    plugins:
      - typescript-common
      - typescript-server
    config:
      avoidOptionals: true
      namingConvention:
        enumValues: keep

All 7 comments

btw. naming configuration looks like this:

config: {
    namingConvention: {
      default: "change-case#pascalCase",
      enumValues: "change-case#upperCase"
    }
  },

is there something i can change?

Seems like a "no-change-case" mode would solve this.

1214

@OneCyrus fixed and merged, can you please try this alpha version?

 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - graphql-codegen-typescript-graphql-files-modules@0.17.0-alpha.bb76bd65
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - graphql-codegen-graphql-files-typescript-modules@0.17.0-alpha.bb76bd65
 - [email protected]
 - graphql-codegen-typescript-mongodb-template@0.17.0-alpha.bb76bd65
 - graphql-codegen-typescript-react-apollo-template@0.17.0-alpha.bb76bd65
 - graphql-codegen-typescript-resolvers-template@0.17.0-alpha.bb76bd65
 - [email protected]

yes, that works now. thanks!

@SoyYoRafa you can ask for no naming changes like this:

generates:
  ./src/types/types.ts:
    plugins:
      - typescript-common
      - typescript-server
    config:
      avoidOptionals: true
      namingConvention:
        enumValues: keep

Fixed in 0.16.1 :)

Was this page helpful?
0 / 5 - 0 ratings