Search code examples
aws-appsyncaws-amplify

How to generate graphql statements from aws schema.graphql using amplify


So I created schema.graphql using amplify add api command, but I said No when it offered me to generate queries, mutations and subscriptions.

Now I am wondering, how can I generate them after the fact? Or do I have to go through whole amplify add api process again?


Solution

  • There is an additional command that you can use to initiate the code generation.

    You can run amplify configure codegen to configure it (accepting the defaults is probably fine). Anytime after you have made schema changes, you can then run amplify codegen types to re-generate your types (make sure to run an amplify push before you do so).

    More info here: https://aws-amplify.github.io/docs/cli/codegen