feat: support deleting comment reactions

This commit is contained in:
Wyatt Johnson
2018-09-24 12:50:30 -06:00
parent dee14709c8
commit 10748347b9
5 changed files with 141 additions and 4 deletions
@@ -2,11 +2,13 @@ import TenantContext from "talk-server/graph/tenant/context";
import {
GQLCreateCommentInput,
GQLCreateCommentReactionInput,
GQLDeleteCommentReactionInput,
GQLEditCommentInput,
} from "talk-server/graph/tenant/schema/__generated__/types";
import {
create,
createCommentReaction,
createReaction,
deleteReaction,
edit,
} from "talk-server/services/comments";
@@ -36,7 +38,11 @@ export default (ctx: TenantContext) => ({
ctx.req
),
createReaction: (input: GQLCreateCommentReactionInput) =>
createCommentReaction(ctx.mongo, ctx.tenant, ctx.user!, {
createReaction(ctx.mongo, ctx.tenant, ctx.user!, {
item_id: input.commentID,
}),
deleteReaction: (input: GQLDeleteCommentReactionInput) =>
deleteReaction(ctx.mongo, ctx.tenant, ctx.user!, {
item_id: input.commentID,
}),
});
@@ -27,6 +27,10 @@ const Mutation: GQLMutationTypeResolver<void> = {
comment: await ctx.mutators.Comment.createReaction(input),
clientMutationId: input.clientMutationId,
}),
deleteCommentReaction: async (source, { input }, ctx) => ({
comment: await ctx.mutators.Comment.deleteReaction(input),
clientMutationId: input.clientMutationId,
}),
};
export default Mutation;
@@ -1475,7 +1475,7 @@ type UpdateSettingsPayload {
}
##################
## Mutation
## createCommentReaction
##################
input CreateCommentReactionInput {
@@ -1502,6 +1502,34 @@ type CreateCommentReactionPayload {
clientMutationId: String!
}
##################
## deleteCommentReaction
##################
input DeleteCommentReactionInput {
"""
commentID is the Comment's ID that we want to delete a Reaction on.
"""
commentID: ID!
"""
clientMutationId is required for Relay support.
"""
clientMutationId: String!
}
type DeleteCommentReactionPayload {
"""
comment is the Comment that the Reaction was deleted on.
"""
comment: Comment
"""
clientMutationId is required for Relay support.
"""
clientMutationId: String!
}
##################
## Mutation
##################
@@ -1531,6 +1559,14 @@ type Mutation {
createCommentReaction(
input: CreateCommentReactionInput!
): CreateCommentReactionPayload @auth
"""
deleteCommentReaction will delete a Reaction authored by the current logged in
user on a Comment if it exists.
"""
deleteCommentReaction(
input: CreateCommentReactionInput!
): CreateCommentReactionPayload @auth
}
################################################################################