Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amplify codegen should auto compile schema before generating statements #579

Open
2 tasks done
chrisbonifacio opened this issue Apr 14, 2023 · 3 comments
Open
2 tasks done
Labels
feature-request New feature or request p3

Comments

@chrisbonifacio
Copy link
Member

chrisbonifacio commented Apr 14, 2023

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

  1. yarn global add @aws-amplify/cli@11.0.5
  2. amplify init
  3. amplify add api-> GraphQL
  4. Edit local schema and add a new model
  5. amplify codegen add
  6. amplify codegen

Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@chrisbonifacio chrisbonifacio added the pending-triage Issues that need further discussion to determine label Apr 14, 2023
@chrisbonifacio
Copy link
Member Author

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.

@chrisbonifacio chrisbonifacio added the feature-request New feature or request label Apr 14, 2023
@chrisbonifacio
Copy link
Member Author

chrisbonifacio commented Apr 14, 2023

Converting this to a feature request. Would be a nice quality of life change to not have to run two commands to regenerate statements

@chrisbonifacio chrisbonifacio changed the title amplify codegen is not generating new statements amplify codegen should auto compile schema before generating statements Apr 14, 2023
@AnilMaktala AnilMaktala added p4 p3 and removed pending-triage Issues that need further discussion to determine p4 labels Apr 14, 2023
@AnilMaktala AnilMaktala transferred this issue from aws-amplify/amplify-category-api Apr 21, 2023
@wpyoga
Copy link

wpyoga commented Jul 16, 2023

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.

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. After amplify push is done, I have to run amplify codegen in order to get the latest changes.
  • I can also do an amplify api gql-compile then amplify codegen in order to get the latest changes without pushing first. This is based on this issue, and also the suggestion in [request?] amplify codegen does not reflect updated schema from local copy #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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request p3
Projects
None yet
Development

No branches or pull requests

3 participants