Skip to content

Instantly share code, notes, and snippets.

@Nxtra
Last active November 25, 2020 22:45
Show Gist options
  • Save Nxtra/13f7f7cadee48d95bdb1c2b6007135d6 to your computer and use it in GitHub Desktop.
Save Nxtra/13f7f7cadee48d95bdb1c2b6007135d6 to your computer and use it in GitHub Desktop.
Amplify schema with relations and custom mutation
type Blog @model {
id: ID!
name: String!
posts: [Post] @connection(keyName: "byBlog", fields: ["id"])
}
type Post @model @key(name: "byBlog", fields: ["blogID"]) {
id: ID!
title: String!
blogID: ID!
blog: Blog @connection(fields: ["blogID"])
comments: [Comment] @connection(keyName: "byPost", fields: ["id"])
}
type Comment @model @key(name: "byPost", fields: ["postID", "content"]) {
id: ID!
postID: ID!
post: Post @connection(fields: ["postID"])
content: String!
}
type Mutation {
deletePostAndComments(postId: ID!): DeletePostAndCommentsResponse
@function(name: "editPostAndComments-${env}")
}
type DeletePostAndCommentsResponse {
id: ID!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment