aws-amplify / aws-amplify/amplify-codegen
Feature Request: Use codegen in headless mode seperate from push
- Dominant language
- TypeScript
- Stars
- 59
- Forks
- 64
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
When setting up the build configuration for multiple frontend environments with a shared backend, I have the need to make the build process use ```amplify pull``` to get the most up-to-date metadata to connect to the backend (e.x. the ```aws-exports.js``` file for a React webapp). However, to use any of the GraphQL statements generated by ```amplify codegen```, it seems like I need to store a copy of the statements in each one of the frontend repositories in order to use them. It would be preferable if I could generate the statements during/after pulling to reduce manually duplicating the same files across multiple repositories.
**Describe the solution you'd like**
I think either one of these proposed solutions would work, though the latter would most likely be easier to implement.
- Give an option when running ```amplify pull``` to generate the GraphQL statements if a GraphQL API is detected in the backend (possibly only on the first pull). Something like
```
The current backend environment has a GraphQL API. Would you like to generate new GraphQl statements? (Y/n)
```
Along with the other prompts which appear when running ```amplify codegen```. For headless mode, it would work similarly to how it does for ```amplify push``` by providing a ```--codegen``` flag to the command.
- Give ```amplify codegen add``` a headless mode, similar to that suggested in aws-amplify/amplify-cli#2005 and aws-amplify/amplify-cli#852. This would allow for automated statement generation if I use ```amplify pull``` to get the entire backend definition, which would include the schema. Alternatively, I could just include the schema file in each repository, which would at least minimize the number of files that need to be manually copied and maintained across each one.
**Describe alternatives you've considered**
- Using ```amplify pull``` to get the entire backend definition and then using ```amplify push --codegen``` in headless mode. This doesn't work in this case since just pulling the backend means there are no changes and thus ```amplify push``` doesn't run. Even if it did, it wouldn't be ideal to allow the build process to potentially change the backend since it doesn't need to do so.
Contributor guide
Assessment
This issue has not been assessed yet.