amplify-codegen icon indicating copy to clipboard operation
amplify-codegen copied to clipboard

Feature Request: Use codegen in headless mode seperate from push

Open tyler-burkett opened this issue 4 years ago • 4 comments

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.

tyler-burkett avatar Jun 08 '20 18:06 tyler-burkett

Hey,👋 thanks for raising this! I'm going to transfer this over to our API repository for better assistance 🙂

ykethan avatar Apr 22 '24 15:04 ykethan

Hey @ideen1, Thanks for raising this. Can you please update your backend and backend-cli lib to latest and try again?

AnilMaktala avatar Apr 24 '24 00:04 AnilMaktala

Hey @AnilMaktala, I have updated both and reloaded my dev environment. Still encountering the same issue unfortunately.

ideen1 avatar Apr 24 '24 04:04 ideen1

@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.

iartemiev avatar May 02 '24 21:05 iartemiev

Hi @ideen1, Are you still experiencing this issue?

AnilMaktala avatar May 07 '24 15:05 AnilMaktala

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.

AnilMaktala avatar May 20 '24 01:05 AnilMaktala

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.

github-actions[bot] avatar May 20 '24 01:05 github-actions[bot]