Skip to content

Delete

FastGQL auto generates delete<OBJECT_NAME> delete mutations if the #generatemutations is set. The following code will be added to the GraphQL schema.

mutation {
# createPosts allows to insert one or more Posts
deletePosts(cascade: Boolean, filter: PostFilterInput): PostsPayload
# ... more mutations
}
"""
Autogenerated Posts Filter Input
"""
input PostFilterInput {
id: IntComparator
name: StringComparator
categories: CategoryFilterInput
user: UserFilterInput
"""
Logical AND of FilterInput
"""
AND: [PostFilterInput]
"""
Logical OR of FilterInput
"""
OR: [PostFilterInput]
"""
Logical NOT of FilterInput
"""
NOT: PostFilterInput
}
"""
Autogenerated payload object
"""
type PostsPayload {
"""
rows affection by mutation
"""
rows_affected: Int!
posts: [Post]
}

The #generatemutations directive adds the above into our schema.

  • filter argument passed to deletePostsmutation allows to filter what posts we want to delete.
  • The cascade argument defines if we want to cascade our objects on deletion (postgres only)

Delete Objects

Example: Delete a post object and return the deleted posts in the response:

mutation {
deletePosts {
rows_affected
posts {
name
id
}
}
}