Open saculNiot opened 1 year ago
Hi @saculNiot thanks for opening this issue. Sorry for the confusion - first of all, I don't think amplify add codegen
works with Amplify platform libraries, it's used with the AWS AppSync SDKs. Second, amplify codegen models
command requires adding API
category to your Amplify App (which creates the API folder in amplify/backend you saw in the error message).
For your use case - using existing AppSync resource with Amplify platform libraries, you should follow this documentation. With this, you can start communicating with your API by manually composing GraphQL document string.
I haven't been able to generate native models directly using the CLI. If you'd like to leverage the native model helper, you probably need extra manual steps. Here's what I tried as a workaround
amplify add api
following the steps <your-project-root>/amplify/backend/api/<your-api-name>/schema.graphql
amplify codegen models
, you should get the native models under lib/models
as well as the ModelProvider
Please note if you run amplify push
it will create a new AppSync API, so before you push, you many want to do amplify remove api
.
I will dig around to see if there is a simple way to do this. Will update.
Thanks for your reply. Sure, I will go and try it out as well. Waiting for your good news. I think this feature is quite essential XD as I think most web developers who are familiar with Appsync in their web projects will need this as well in mobile development. Anyway, appreciate your help.
It seems amplify add codegen
works correctly with amplify-swift
. There may be a feature gap here in CLI not supporting amplify-flutter in this use case.
I have the same issue the workaround works but is not ideal. An update to the CLI to support the codegen with an existing endpoint also in flutter would be perfect
Could we have an update on support an equivalent of amplify codegen models for non-amplify appsync apis for flutter please ?
Hello everyone, we are investigating supporting this. We do not have a timeline yet, but we will provide updates when we have next steps identified.
Thats great.
Can we then also fix the problem that codegen requires @model
annotations which is then not supported by AppSync in the same code?
Description
I have an existing AppSync API that I need to use in a new flutter app. After initializing amplify in my project, i run the command "amplify add codegen --apiId xxxxxxxxxxxxxxxxx"
This results in a message saying "Successfully added API xxxx to your amplify project" but then says "Flutter Only supports the command $amplify codegen models."
When I run amplify codegen models, it says No Appsync API configured. Please add an API. When I run amplify status, it shows the API ,but with no provider plugin. If I update the backend-config.json in amplify/backend directory with the awscloudformation provider plugin, and run either amplify push or amplify codegen models it tells me there is no API folder in amplify/backend
Has anyone had success getting codegen to work for an existing appsync api with Flutter? I have tried everything.
Categories
Steps to Reproduce
No response
Screenshots
No response
Platforms
Android Device/Emulator API Level
No response
Environment
Dependencies
Device
IPhone 14
OS
IOS 14
Deployment Method
Amplify CLI
CLI Version
No response
Additional Context
No response
Amplify Config
const amplifyconfig = ''' { "UserAgent": "aws-amplify-cli/2.0", "Version": "1.0", "auth": { "plugins": { "awsCognitoAuthPlugin": { "UserAgent": "aws-amplify-cli/0.1.0", "Version": "0.1.0", "IdentityManager": { "Default": {} }, "CognitoUserPool": { "Default": { "PoolId": "", "AppClientId": "", "Region": "" } }, "Auth": { "Default": { "OAuth": { "WebDomain": "", "AppClientId": "", "SignInRedirectURI": "http://localhost:3000/", "SignOutRedirectURI": "http://localhost:3000/signout", "Scopes": [ "email", "openid", "profile" ] }, "authenticationFlowType": "USER_SRP_AUTH", "socialProviders": [], "usernameAttributes": [ "EMAIL" ], "signupAttributes": [], "passwordProtectionSettings": { "passwordPolicyMinLength": 8, "passwordPolicyCharacters": [ "REQUIRES_LOWERCASE", "REQUIRES_UPPERCASE" ] }, "mfaConfiguration": "OFF", "mfaTypes": [], "verificationMechanisms": [ "EMAIL" ] } } } } } }''';