Generation of models / domain objects with amplify codegen
Is your feature request related to a problem? Please describe. In our Angular Project, we use Typescript classes for our Models / Domain Objects. These classes are written manually.
For Example this schema:
type Blog @model {
id: ID!
name: String!
posts: [Post] @connection(name: "BlogPosts")
}
type Post @model {
id: ID!
title: String!
blog: Blog @connection(name: "BlogPosts")
}
Could be transformed too:
export class Blog {
id: string;
name: string;
posts: Post[] = [];
}
export class Post {
id: string;
title: string;
blog: Blog;
}
Describe the solution you'd like
amplify codegen could generate these classes.
Or does the functionality already exist and I have overlooked it?
Recently we added support for generation of Angular services. You can find more about that at our docs.
Hey @yuth, related to your response above, we have an ionic (Angular) project where we don't use @model annotations or amplify push, but we instead created a Graphql schema in the appsync console (and generated a DDB data model from there).
When we run amplify codegen we only get the following:
➜ raptor-appsync-chat git:(master) ✗ amplify codegen
✔ Downloaded the schema
✔ Generated GraphQL operations successfully and saved at src/graphql
✔ Code generated successfully and saved in file src/API.ts
The introspection schema is downloaded and mutation, subscription and query types are generated, but no super-useful Angular src/app/API.service.ts is generated, nor types similar to the ones described above which seem to only be generated using amplify push
export class Blog {
id: string;
name: string;
posts: Post[] = [];
}
Is there a way for us to generate the Angular service and the types without using amplify push?
Thanks for all the hard work on this awesome product.
cc. @HannaSanford
This feature would be very much needed
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.