Skip to content

Instantly share code, notes, and snippets.

@Nxtra
Last active Nov 25, 2020
Embed
What would you like to do?
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