amplify-codegen
amplify-codegen copied to clipboard
amplify codegen should auto compile schema before generating statements
How did you install the Amplify CLI?
yarn
If applicable, what version of Node.js are you using?
v18.14.2
Amplify CLI Version
11.0.5
What operating system are you using?
Mac (Apple Silicon)
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual changes made
Describe the bug
Running amplify codegen on the latest version of the Amplify CLI is not resulting in new graphql statements in the src/graphql folder
running amplify api gql-compile before amplify codegen regenerates the statement files
Expected behavior
graphql statements should be updated with changes made to the local schema
Reproduction steps
yarn global add @aws-amplify/[email protected]amplify initamplify add api-> GraphQL- Edit local schema and add a new model
amplify codegen addamplify codegen
Project Identifier
No response
Log output
# Put your logs below this line
Additional information
No response
Before submitting, please confirm:
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
Closing as this was confirmed to be expected behavior. amplify api gql-compile must be run before amplify codegen to update the build schema with any changes to the local schema. The build schema is the input to amplify codegen, unlike amplify codegen models which uses the local schema.
Converting this to a feature request. Would be a nice quality of life change to not have to run two commands to regenerate statements
Closing as this was confirmed to be expected behavior.
amplify api gql-compilemust be run beforeamplify codegento update the build schema with any changes to the local schema. The build schema is the input toamplify codegen, unlikeamplify codegen modelswhich uses the local schema.
The docs doesn't mention having to run amplify api gql-compile: https://docs.amplify.aws/cli/graphql/client-code-generation/
Is it supposed to be in the docs?
Also, I'm observing this behavior in my project:
- If I do an
amplify push, codegen does not pick up the latest schema changes. Afteramplify pushis done, I have to runamplify codegenin order to get the latest changes. - I can also do an
amplify api gql-compilethenamplify codegenin order to get the latest changes without pushing first. This is based on this issue, and also the suggestion in #113 (this comment)
Is this by design? I thought amplify push will run codegen and pick up the latest changes, is this assumption correct?
Also, wouldn't this be a reasonable workflow? edit schema -> compile schema -> codegen -> git commit & push -> amplify push
Instead of the current one: edit schema -> amplify push -> codegen -> git commit & push