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

Feedback for “Multi Project”

Open patrickDouglas opened this issue 9 months ago • 1 comments

If you want to run graphql-codegen across all of your projects, is it expected you have to run graphql-codegen --config graphql.config.js --project prj1 and then graphql-codegen --config graphql.config.js --project prj2? My initial thought was that I could just run graphql-codegen, and it would run all the projects 🤔, but that does NOT seem to be the case. Is there anyway to add a flag like... --all-projects which would loop over each project and run graphql-codegen based on it's configuration?

patrickDouglas avatar Feb 11 '25 21:02 patrickDouglas

Hi @patrickDouglas ,

That is a spot on observation. Codegen currently only runs one project at a time.

A few options come to mind right now:

  1. Use one project, if all current projects need to run at the same time
  2. Write a wrapper script that runs multiple projects sequentially or parallelly: This can be done fairly straightforward on the consumer side e.g. to run sequentially: graphql-codegen --config graphql.config.js --project prj1 && graphql-codegen --config graphql.config.js --project prj2. However, if you start to get more than a few projects, it could become efficient
  3. Make Codegen CLI do option 2 OOTB: There are a lot to consider in this option: would projects run in parallel? Would failing one project continue? What is the terminal output if multiple projects run at the same time?

I've a feeling option 3 would need a lot of work, and 1 or 2 would be a quicker workaround if you need to unblock yourself. If you have suggestions/proposals for option 3 or other options, I'm more than happy to discuss!

eddeee888 avatar Feb 13 '25 14:02 eddeee888

I would love option 3 @eddeee888. I think it should behave the same way the old codegen config worked when you had multiple generates.

flippidippi avatar Jul 16 '25 16:07 flippidippi