4

Currently, the enums that Graphql Code Generator produces looks like this

export enum Test_Type {
    Test: 'TEST',
}

however I want the generated enums to be in pascal case like this:

export enum TestType {
  Test: 'TEST',
}

Edit, my codegen.yml:

overwrite: true
generates:
  src/graphql/generated/graphql.ts:
    schema: ${API_ENDPOINT}
    documents: ['src/graphql/**/*.graphql', 'src/graphql/**/*.gql']
    plugins:
      - 'typescript'
      - 'typescript-operations'
      - 'typescript-react-apollo'
  ./graphql.schema.json:
    schema: ${API_ENDPOINT}
    plugins:
      - 'introspection'
hooks:
  afterAllFileWrite:
    - prettier --write

The schema for the enum is

enum TEST_TYPE {
    TEST
}
4
  • graphql-code-generator.com/docs/getting-started/…? Please add the graphql schema containing the enum as well as your codegen.yaml configuration, otherwise we're unable to help you. Commented Oct 1, 2021 at 0:54
  • @Bergi I edited the post to my codegen.yml . I don't think I can provide the graphql schema since that's private. Is it necessary in this case since I'm asking a general question that's not related to the actual schemas? Commented Oct 1, 2021 at 5:10
  • Thanks. Not the entire schema, only the enum TestType = TEST Commented Oct 1, 2021 at 8:33
  • @Bergi I've included the schema for that enum. thanks in advance for your help. Commented Oct 1, 2021 at 18:14

1 Answer 1

4

You can set the naming convention in config in your codegen.yml file.

config:
  namingConvention: change-case-all#pascalCase
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.