Apollo-tooling: Any way to disable globalTypes generation?

Created on 9 Apr 2019  Â·  5Comments  Â·  Source: apollographql/apollo-tooling

I'm trying to use codegen in an existing codebase and can't run it on all files as that fails due to numerous issues (imported fragments from other modules, anonymous operations, etc)

What I've instead been doing is running codegen on new code. It works but whenever globalTypes is generated it overwrites previous data – this leaves older operation types without enums

Is there a way to disable globalTypes generation and keep enums local?

feature 🤖 codegen

Most helpful comment

I'm also interested by this, but for different reasons: I'm generating code for a few GraphQL queries using the Apollo CLI codegen feature, but in my case the globalTypes.ts file is empty, so I assume that I simply don't need it.

The issue is that I'm using the Create React App scripts in my project, and it enforces the isolatedModules option to true. Having empty files is not allowed when that option is enabled.

For now my workaround is to instruct the CLI to generate the globalTypes file outside the compilation scope, but this is a dirt hack that I'd like to avoid :)

Any idea of another (cleaner) solution? I feel like disabling the generation of that empty file would be ideal in my case.

All 5 comments

I'm also interested by this, but for different reasons: I'm generating code for a few GraphQL queries using the Apollo CLI codegen feature, but in my case the globalTypes.ts file is empty, so I assume that I simply don't need it.

The issue is that I'm using the Create React App scripts in my project, and it enforces the isolatedModules option to true. Having empty files is not allowed when that option is enabled.

For now my workaround is to instruct the CLI to generate the globalTypes file outside the compilation scope, but this is a dirt hack that I'd like to avoid :)

Any idea of another (cleaner) solution? I feel like disabling the generation of that empty file would be ideal in my case.

I simply exclude the globalTypes.ts in my tsconfig.json and it workes as promised.

i think apollo should not generate the global-types if its empty. it results in errors also for next.js because that forces isolatedModules to be true as well

+1

damn, just run into that again. Does anyone know a workaround?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gordanhappy picture gordanhappy  Â·  3Comments

ethansinjin picture ethansinjin  Â·  3Comments

lirbank picture lirbank  Â·  4Comments

rasmusprentow picture rasmusprentow  Â·  3Comments

reichhartd picture reichhartd  Â·  4Comments