amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

Generation of models / domain objects with amplify codegen

Open ChrisWun opened this issue 8 years ago • 4 comments

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?

ChrisWun avatar Nov 09 '18 11:11 ChrisWun

Recently we added support for generation of Angular services. You can find more about that at our docs.

yuth avatar Nov 13 '18 05:11 yuth

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

snaptom avatar Dec 02 '18 19:12 snaptom

This feature would be very much needed

ryanleecode avatar Dec 14 '18 00:12 ryanleecode

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.

github-actions[bot] avatar May 27 '21 17:05 github-actions[bot]