graphql-code-generator
graphql-code-generator copied to clipboard
Feedback for “Multi Project”
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?
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:
- Use one project, if all current projects need to run at the same time
- 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 - 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!
I would love option 3 @eddeee888. I think it should behave the same way the old codegen config worked when you had multiple generates.