## These are examples from https://docs.amplify.aws/cli/graphql-transformer/connection # 1 - Project has a single optional Team type Project1 @model { id: ID! name: String team: Team1 @connection } type Team1 @model { id: ID! name: String! } # 2 - Project with explicit field for team’s id type Project2 @model { id: ID! name: String teamID: ID! team: Team2 @connection(fields: ["teamID"]) } type Team2 @model { id: ID! name: String! } # 3 - Post Comment - keyName reference key directive type Post3 @model { id: ID! title: String! comments: [Comment3] @connection(keyName: "byPost3", fields: ["id"]) } type Comment3 @model @key(name: "byPost3", fields: ["postID", "content"]) { id: ID! postID: ID! content: String! } # 4 - Post Comment bi-directional belongs to type Post4 @model { id: ID! title: String! comments: [Comment4] @connection(keyName: "byPost4", fields: ["id"]) } type Comment4 @model @key(name: "byPost4", fields: ["postID", "content"]) { id: ID! postID: ID! content: String! post: Post4 @connection(fields: ["postID"]) } # 5 Many to Many type Post5 @model { id: ID! title: String! editors: [PostEditor5] @connection(keyName: "byPost5", fields: ["id"]) } # Create a join model type PostEditor5 @model @key(name: "byPost5", fields: ["postID", "editorID"]) @key(name: "byEditor5", fields: ["editorID", "postID"]) { id: ID! postID: ID! editorID: ID! post: Post5! @connection(fields: ["postID"]) editor: User5! @connection(fields: ["editorID"]) } type User5 @model { id: ID! username: String! posts: [PostEditor5] @connection(keyName: "byEditor5", fields: ["id"]) } # This is one of the default schemas provided when you run `amplify add api` # > Do you have an annotated GraphQL schema? `No` # > Choose a schema template: `One-to-many relationship (e.g., “Blogs” with “Posts” and “Comments”)` # 6 - Blog Post Comment type Blog6 @model { id: ID! name: String! posts: [Post6] @connection(keyName: "byBlog", fields: ["id"]) } type Post6 @model @key(name: "byBlog", fields: ["blogID"]) { id: ID! title: String! blogID: ID! blog: Blog6 @connection(fields: ["blogID"]) comments: [Comment6] @connection(keyName: "byPost", fields: ["id"]) } type Comment6 @model @key(name: "byPost", fields: ["postID", "content"]) { id: ID! postID: ID! post: Post6 @connection(fields: ["postID"]) content: String! }