feat: added flag creation and deletion mutations

This commit is contained in:
Wyatt Johnson
2018-09-24 13:46:13 -06:00
parent a19ac4e2cc
commit 3cdaa284ed
5 changed files with 173 additions and 4 deletions
@@ -1,13 +1,17 @@
import TenantContext from "talk-server/graph/tenant/context";
import {
GQLCreateCommentFlagInput,
GQLCreateCommentInput,
GQLCreateCommentReactionInput,
GQLDeleteCommentFlagInput,
GQLDeleteCommentReactionInput,
GQLEditCommentInput,
} from "talk-server/graph/tenant/schema/__generated__/types";
import {
create,
createFlag,
createReaction,
deleteFlag,
deleteReaction,
edit,
} from "talk-server/services/comments";
@@ -45,4 +49,13 @@ export default (ctx: TenantContext) => ({
deleteReaction(ctx.mongo, ctx.tenant, ctx.user!, {
item_id: input.commentID,
}),
createFlag: (input: GQLCreateCommentFlagInput) =>
createFlag(ctx.mongo, ctx.tenant, ctx.user!, {
item_id: input.commentID,
reason: input.reason,
}),
deleteFlag: (input: GQLDeleteCommentFlagInput) =>
deleteFlag(ctx.mongo, ctx.tenant, ctx.user!, {
item_id: input.commentID,
}),
});
@@ -31,6 +31,14 @@ const Mutation: GQLMutationTypeResolver<void> = {
comment: await ctx.mutators.Comment.deleteReaction(input),
clientMutationId: input.clientMutationId,
}),
createCommentFlag: async (source, { input }, ctx) => ({
comment: await ctx.mutators.Comment.createFlag(input),
clientMutationId: input.clientMutationId,
}),
deleteCommentFlag: async (source, { input }, ctx) => ({
comment: await ctx.mutators.Comment.deleteFlag(input),
clientMutationId: input.clientMutationId,
}),
};
export default Mutation;
@@ -1530,6 +1530,67 @@ type DeleteCommentReactionPayload {
clientMutationId: String!
}
##################
## createCommentFlag
##################
input CreateCommentFlagInput {
"""
commentID is the Comment's ID that we want to create a Flag on.
"""
commentID: ID!
"""
reason is the selected reason why the Flag is being created.
"""
reason: COMMENT_FLAG_REPORTED_REASON!
"""
clientMutationId is required for Relay support.
"""
clientMutationId: String!
}
type CreateCommentFlagPayload {
"""
comment is the Comment that the Flag was created on.
"""
comment: Comment
"""
clientMutationId is required for Relay support.
"""
clientMutationId: String!
}
##################
## deleteCommentFlag
##################
input DeleteCommentFlagInput {
"""
commentID is the Comment's ID that we want to delete a Flag on.
"""
commentID: ID!
"""
clientMutationId is required for Relay support.
"""
clientMutationId: String!
}
type DeleteCommentFlagPayload {
"""
comment is the Comment that the Flag was deleted on.
"""
comment: Comment
"""
clientMutationId is required for Relay support.
"""
clientMutationId: String!
}
##################
## Mutation
##################
@@ -1554,7 +1615,7 @@ type Mutation {
"""
createCommentReaction will create a Reaction authored by the current logged in
user on a Comment.
User on a Comment.
"""
createCommentReaction(
input: CreateCommentReactionInput!
@@ -1562,11 +1623,25 @@ type Mutation {
"""
deleteCommentReaction will delete a Reaction authored by the current logged in
user on a Comment if it exists.
User on a Comment if it exists.
"""
deleteCommentReaction(
input: CreateCommentReactionInput!
): CreateCommentReactionPayload @auth
"""
createCommentFlag will create a Flag authored by the current logged in User on
a given Comment.
"""
createCommentFlag(input: CreateCommentFlagInput!): CreateCommentFlagPayload
@auth
"""
deleteCommentFlag will create a Flag authored by the current logged in User on
a given Comment.
"""
deleteCommentFlag(input: DeleteCommentFlagInput!): DeleteCommentFlagPayload
@auth
}
################################################################################