amplify-codegen
amplify-codegen copied to clipboard
Feature Request: Use codegen in headless mode seperate from push
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 useamplify 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 usingamplify push --codegen
in headless mode. This doesn't work in this case since just pulling the backend means there are no changes and thusamplify 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.
Hey,👋 thanks for raising this! I'm going to transfer this over to our API repository for better assistance 🙂
Hey @ideen1, Thanks for raising this. Can you please update your backend
and backend-cli
lib to latest and try again?
Hey @AnilMaktala, I have updated both and reloaded my dev environment. Still encountering the same issue unfortunately.
@ideen1 could you please try upgrading the following 3 dependencies to the following versions:
"dependencies": {
"aws-amplify": "^6.2.0",
...
},
"devDependencies": {
"@aws-amplify/backend": "^1.0.0",
"@aws-amplify/backend-cli": "^1.0.0",
...
}
If that doesn't fix the issue, please share your schema and client code.
Hi @ideen1, Are you still experiencing this issue?
Hey 👋 , This issue is being closed due to inactivity. If you are still experiencing the same problem and need further assistance, please feel free to leave a comment. This will enable us to reopen the issue and provide you with the necessary support.
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.