graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

ignore git ignored files by default

Open capaj opened this issue 3 years ago • 3 comments

I had a config like this on one react-native project:

documents: ['**/*.gql']

this ran like 40 seconds when trying to generate. Why? Because it is traversing whole node_modules. So I would like to have 2 new features:

  1. ignore git ignored files by default
  2. When I have too many files, emit a warning to stdout and recommend to limit the glob expression

capaj avatar Aug 03 '22 16:08 capaj

Sometimes an input can be the generated files from a different tool or it can be under node_modules etc. I think you should always avoid to have a "broad" expression. If you have a proper file structure, I think it can be something like documents: ['src/pages/**/graphql/*.gql'].

Also "too many" depends on many things. "Too many" can be 100 for a setup/project, or 1000 for another. Not sure about the other option.

ardatan avatar Aug 03 '22 18:08 ardatan

I was thinking of putting the limit somewhere around 5k mark. Basicaly I would expect code gen to always finish within like 10-15 seconds max and unfortunately node/filesystem/JS is just too slow to churn through that much in a reasonable time. My project where I bumped into this has 11500 ts files in node_modules. Counted that with ls node_modules/**/*.ts Also we would have a flag to silent the warning.

Sometimes an input can be the generated files from a different tool or it can be under node_modules etc

Fair point with generated code, that can be gitignored, but I don't agree with node_modules.

You should never generate stuff in there IMHO. I know there are a few tools that do this-for example @prisma. I still hate it. Depoying prisma to a lambda is a mind numbing, thanks to the fact that your ORM client type defs live outside the git repo by default. You end up writing stuff like this:


  await cpy(['../node_modules/@prisma/client/**'], './dist/node_modules', {
    parents: true
  })

  await cpy(['../node_modules/prisma/**'], './dist/node_modules', {
    parents: true,
    ignore: [
      '../node_modules/prisma/libquery_engine-debian-openssl-3.0.x.so.node'
    ]
  })

just to get your lambda build to work.

capaj avatar Aug 04 '22 10:08 capaj

I didn't mean to generate files into node_modules. I mean to generate files by using some files in node_modules as an input. You can basically use narrow glob expressions instead of **/*.ts :)

ardatan avatar Aug 08 '22 08:08 ardatan

Side note - I lost some time today to the surprise inclusion of node_modules/.

Given both tsc and eslint automatically exclude it, it would be nice for this program to do the same thing.

Edit: I filed #8434, which is a much narrower change that would also address this concern.

aaronadamsCA avatar Oct 04 '22 14:10 aaronadamsCA