amplify codegen models does not work properly on Android

Viewed 1657

What I expect: After typing amplify codegen models, it should generate the model "classes" for my already existing backend.

What happens: Message Output:

No AppSync API configured. Please add an API.

What I did so far:

  1. Already did the Amplify Prerequisites mentioned here
  2. I added my existing API to my Android Project by amplify codegen That resulted in generated files for mutations/queries/subscriptions and the schema.json as you can see on the screenshot below.
    enter image description here
  3. I wanted to generate the models classes as mentioned here

But as said, the model classes are not generated. May someone has the solution for my situation out there. Would help me a lot :)

1 Answers

amplify codegen models uses CLI codegen to generate models to be used for the new Amplify API and Amplify DataStore categories, which is separate from the generated code used by the AppSync client.

To generate models for Amplify API, try using the following command: amplify add api, to add a new API. When prompted to edit your models, follow the instructions to edit the schema.graphql file in specified path.

If you try amplify codegen models at this point, then you will find that the models are generated.

Related