0

Are there some sort of options you can configure for Apollo Client Codegen beyond the basic limited options here? Specifically I am trying to:

  1. Remove top level __generated__ folder
  2. Format after generation
  3. Change filename casing

The command I am using is apollo client:codegen --target typescript --globalTypesFile='./src/__generated__/global-types.ts'.

I wanted to move the global types into the src directory, so I used the -globalTypesFile option, but codegen still generates an empty folder at the project root (as well as generating the global types in the src directory).

I'm using Prettier, and whenever I run codegen I am left with a bunch of file diffs because of the way the generated code is formatted. I then have to run Prettier again manually to reformat the generated files. I've used @graphql/codegen before which allows you to set a afterAllFileWrite hook, so you can tell it to run Prettier after generating files but I can’t see how to do this with apollo codegen.

I use kebab-case filenames throughout my codebase, but Apollo Client Codegen creates the generated files using PascalCase. I'd like to have this consistent with the rest of my codebase but I can't see any option to change this.

mrseanbaines
  • 823
  • 2
  • 12
  • 25
  • Hi, I use `apollo codegen:generate --localSchemaFile=./src/__generated__/schema-file.json ./src/__generated__/queries-file.ts --outputFlat --target=typescript --addTypename --passthroughCustomScalars --includes **/*.graphql.* --customScalarsPrefix=GraphQL$;` 1&3 work fine, for prettier, I put it in .prettierignore because I don't care of this 1K+ lines file formatting. – bossno Nov 11 '20 at 15:51

0 Answers0