Open felixeriksson opened 3 months ago
Hi @felixeriksson - Thanks for opening the issue. The code generation will not work without @model
annotations, which are not present in the schema. You may need to edit the schema manually for codgen to work properly. I have reached out to our CLI team to ask if this is expected. I will let you when I have an update.
Are you trying to use Amplify DataStore or Amplify GraphQL API?
Hi Jordan, thanks for the reply!
I'm trying to configure Amplify with an existing GraphQL API (defined in CF in another repo), so I guess that would be Amplify GraphQL API. I've consulted the documentation here, and used amplify codegen models
.
Hi Jordan, thanks for the reply! I'm trying to configure Amplify with an existing GraphQL API (defined in CF in another repo), so I guess that would be Amplify GraphQL API. I've consulted the documentation here, and used
amplify codegen models
.
...thinking more closely about it, I don't believe the changes I did in amplifyconfiguration.json
, according to the docs linked above, had any influence on the output when I ran
aws appsync get-introspection-schema --api-id <API-ID> --region <REGION> --format SDL schema.graphql
amplify codegen models --model-schema schema.graphql --target flutter --output-dir ./api-models
I haven't fully understood what you're supposed to be able to achieve by editing amplifyconfiguration.json
as per the instructions. What I'm looking for is
@felixeriksson thanks for the info. I suspect the following commands are either not correct or do not include a proper call out that manual modifications to the schema may be required, but I am still trying to confirm this with our AppSync and codgen teams. I will let you know when I have more info.
aws appsync get-introspection-schema --api-id <API-ID> --region <REGION> --format SDL schema.graphql
amplify codegen models --model-schema schema.graphql --target flutter --output-dir ./api-models
Description
Hello! I have an existing AppSync API that I want to generate models for in a Flutter app, for use with the Amplify AppSync client. The schema of the API is attached.
It seems that if the schema does not contain any
@model
directive on any type (which is the situation I'm in, as all the backend resources for my API are defined outside of the Flutter app project), the generatedModelProvider.dart
is invalid, as it has no implementation ofgetModelTypeByModelName
.I have a fresh installation of
@aws-amplify/cli@12.12.4
Output ofnpm list -g --depth=1
:A similar issue can be found here: https://github.com/aws-amplify/amplify-flutter/issues/1455
Categories
Steps to Reproduce
For an existing AppSync API, run (using
aws-cli/2.1.22
):aws appsync get-introspection-schema --api-id <API-ID> --region <REGION> --format SDL schema.graphql
Thenamplify codegen models --model-schema schema.graphql --target flutter --output-dir ./api-models
Screenshots
Platforms
Flutter Version
3.22.2
Amplify Flutter Version
2.3.0 (amplify_flutter, amplify_api and amplify_auth_cognito)
Deployment Method
Amplify CLI
Schema