I have a GraphQL API on AWS AppSync pushed by another person and want to connect to it and fetch data in my Android application. According to AWS documentation, to integrate the API with my app I should execute 3 following commands:
npm install -g @aws-amplify/cli
amplify init
amplify add codegen --apiId xxxxxx
After that, I need to generate Java classes based on the graphql schema. I execute amplify codegen models
but get an error "No AppSync API configured. Please add an API". If execute amplify add api
, I get "You already have an AppSync API in your project. Use the "amplify update api" command to update your existing AppSync API."
Why can't I generate classes?
aws-amplify/cli v4.18.1
You should use Amplify Mobile SDK instead of Amplify Libraries to generate classes for an API created in the AWS Console. It really confuses that you have to use different approaches for generation. In addition, on AWS in the API overview there is a wrong link which refers you not to the mobile sdk, but to the libraries.
Generation process for API created in the console is described in Code Generation / AppSync APIs Created in the Console https://docs.amplify.aws/sdk/api/graphql/q/platform/android#code-generation