mirror of
https://github.com/wassname/talk.git
synced 2026-08-05 13:30:26 +08:00
feat: added reaction adding mutation
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
import TenantContext from "talk-server/graph/tenant/context";
|
||||
import {
|
||||
GQLCreateCommentInput,
|
||||
GQLCreateCommentReactionInput,
|
||||
GQLEditCommentInput,
|
||||
} from "talk-server/graph/tenant/schema/__generated__/types";
|
||||
import { create, edit } from "talk-server/services/comments";
|
||||
import {
|
||||
create,
|
||||
createCommentReaction,
|
||||
edit,
|
||||
} from "talk-server/services/comments";
|
||||
|
||||
export default (ctx: TenantContext) => ({
|
||||
create: (input: GQLCreateCommentInput) =>
|
||||
@@ -30,4 +35,8 @@ export default (ctx: TenantContext) => ({
|
||||
},
|
||||
ctx.req
|
||||
),
|
||||
createReaction: (input: GQLCreateCommentReactionInput) =>
|
||||
createCommentReaction(ctx.mongo, ctx.tenant, ctx.user!, {
|
||||
item_id: input.commentID,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -9,10 +9,10 @@ const Mutation: GQLMutationTypeResolver<void> = {
|
||||
const comment = await ctx.mutators.Comment.create(input);
|
||||
return {
|
||||
edge: {
|
||||
// (cvle)
|
||||
// Depending on the sort we can't determine the accurate cursor
|
||||
// in a performant way, so we return null instead.
|
||||
// It seems that Relay does not directly use this value...
|
||||
// NOTE: (cvle)
|
||||
// Depending on the sort we can't determine the accurate cursor in a
|
||||
// performant way, so we return null instead. It seems that Relay does
|
||||
// not directly use this value.
|
||||
cursor: null,
|
||||
node: comment,
|
||||
},
|
||||
@@ -23,6 +23,10 @@ const Mutation: GQLMutationTypeResolver<void> = {
|
||||
settings: await ctx.mutators.Settings.update(input.settings),
|
||||
clientMutationId: input.clientMutationId,
|
||||
}),
|
||||
createCommentReaction: async (source, { input }, ctx) => ({
|
||||
comment: await ctx.mutators.Comment.createReaction(input),
|
||||
clientMutationId: input.clientMutationId,
|
||||
}),
|
||||
};
|
||||
|
||||
export default Mutation;
|
||||
|
||||
@@ -1478,6 +1478,34 @@ type UpdateSettingsPayload {
|
||||
## Mutation
|
||||
##################
|
||||
|
||||
input CreateCommentReactionInput {
|
||||
"""
|
||||
commentID is the Comment's ID that we want to create a Reaction on.
|
||||
"""
|
||||
commentID: ID!
|
||||
|
||||
"""
|
||||
clientMutationId is required for Relay support.
|
||||
"""
|
||||
clientMutationId: String!
|
||||
}
|
||||
|
||||
type CreateCommentReactionPayload {
|
||||
"""
|
||||
comment is the Comment that the Reaction was created on.
|
||||
"""
|
||||
comment: Comment
|
||||
|
||||
"""
|
||||
clientMutationId is required for Relay support.
|
||||
"""
|
||||
clientMutationId: String!
|
||||
}
|
||||
|
||||
##################
|
||||
## Mutation
|
||||
##################
|
||||
|
||||
type Mutation {
|
||||
"""
|
||||
createComment will create a Comment as the current logged in User.
|
||||
@@ -1495,6 +1523,14 @@ type Mutation {
|
||||
"""
|
||||
updateSettings(input: UpdateSettingsInput!): UpdateSettingsPayload
|
||||
@auth(roles: [ADMIN, MODERATOR])
|
||||
|
||||
"""
|
||||
createCommentReaction will create a Reaction authored by the current logged in
|
||||
user on a Comment.
|
||||
"""
|
||||
createCommentReaction(
|
||||
input: CreateCommentReactionInput!
|
||||
): CreateCommentReactionPayload @auth
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
||||
Reference in New Issue
Block a user