mirror of
https://github.com/wassname/talk.git
synced 2026-07-31 12:50:48 +08:00
[next] Comment Reply Revisions (#2072)
* feat: added revision id support for replies * feat: use createCommentReply
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
GQLCreateCommentFlagInput,
|
||||
GQLCreateCommentInput,
|
||||
GQLCreateCommentReactionInput,
|
||||
GQLCreateCommentReplyInput,
|
||||
GQLEditCommentInput,
|
||||
GQLRemoveCommentDontAgreeInput,
|
||||
GQLRemoveCommentFlagInput,
|
||||
@@ -20,12 +21,15 @@ import {
|
||||
} from "talk-server/services/comments/actions";
|
||||
|
||||
export const Comment = (ctx: TenantContext) => ({
|
||||
create: ({ storyID, body, parentID }: GQLCreateCommentInput) =>
|
||||
create: ({
|
||||
clientMutationId,
|
||||
...comment
|
||||
}: GQLCreateCommentInput | GQLCreateCommentReplyInput) =>
|
||||
create(
|
||||
ctx.mongo,
|
||||
ctx.tenant,
|
||||
ctx.user!,
|
||||
{ authorID: ctx.user!.id, storyID, body, parentID },
|
||||
{ authorID: ctx.user!.id, ...comment },
|
||||
ctx.req
|
||||
),
|
||||
edit: ({ commentID, body }: GQLEditCommentInput) =>
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
import { GQLMutationTypeResolver } from "talk-server/graph/tenant/schema/__generated__/types";
|
||||
|
||||
export const Mutation: GQLMutationTypeResolver<void> = {
|
||||
export const Mutation: Required<GQLMutationTypeResolver<void>> = {
|
||||
editComment: async (source, { input }, ctx) => ({
|
||||
comment: await ctx.mutators.Comment.edit(input),
|
||||
clientMutationId: input.clientMutationId,
|
||||
}),
|
||||
createComment: async (source, { input }, ctx) => {
|
||||
const comment = await ctx.mutators.Comment.create(input);
|
||||
return {
|
||||
edge: {
|
||||
// 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,
|
||||
},
|
||||
clientMutationId: input.clientMutationId,
|
||||
};
|
||||
},
|
||||
createComment: async (source, { input }, ctx) => ({
|
||||
edge: {
|
||||
// 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: await ctx.mutators.Comment.create(input),
|
||||
},
|
||||
clientMutationId: input.clientMutationId,
|
||||
}),
|
||||
createCommentReply: async (source, { input }, ctx) => ({
|
||||
edge: {
|
||||
// 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: await ctx.mutators.Comment.create(input),
|
||||
},
|
||||
clientMutationId: input.clientMutationId,
|
||||
}),
|
||||
updateSettings: async (source, { input }, ctx) => ({
|
||||
settings: await ctx.mutators.Settings.update(input.settings),
|
||||
clientMutationId: input.clientMutationId,
|
||||
|
||||
@@ -1529,11 +1529,6 @@ input CreateCommentInput {
|
||||
"""
|
||||
storyID: ID!
|
||||
|
||||
"""
|
||||
parentID is the optional ID of the Comment that we are replying to.
|
||||
"""
|
||||
parentID: ID
|
||||
|
||||
"""
|
||||
body is the Comment body, the content of the Comment.
|
||||
"""
|
||||
@@ -1561,6 +1556,56 @@ type CreateCommentPayload {
|
||||
clientMutationId: String!
|
||||
}
|
||||
|
||||
##################
|
||||
## createCommentReply
|
||||
##################
|
||||
|
||||
"""
|
||||
CreateCommentReplyInput provides the input for the createCommentReply Mutation.
|
||||
"""
|
||||
input CreateCommentReplyInput {
|
||||
"""
|
||||
storyID is the ID of the Story where we are creating a comment on.
|
||||
"""
|
||||
storyID: ID!
|
||||
|
||||
"""
|
||||
parentID is the ID of the Comment that we are replying to.
|
||||
"""
|
||||
parentID: ID!
|
||||
|
||||
"""
|
||||
parentRevisionID is the ID of the CommentRevision that we are replying to.
|
||||
"""
|
||||
parentRevisionID: ID!
|
||||
|
||||
"""
|
||||
body is the Comment body, the content of the Comment.
|
||||
"""
|
||||
body: String!
|
||||
|
||||
"""
|
||||
clientMutationId is required for Relay support.
|
||||
"""
|
||||
clientMutationId: String!
|
||||
}
|
||||
|
||||
"""
|
||||
CreateCommentReplyPayload contains the created Comment after the createCommentReply
|
||||
mutation.
|
||||
"""
|
||||
type CreateCommentReplyPayload {
|
||||
"""
|
||||
edge is the possibly created comment edge.
|
||||
"""
|
||||
edge: CommentEdge
|
||||
|
||||
"""
|
||||
clientMutationId is required for Relay support.
|
||||
"""
|
||||
clientMutationId: String!
|
||||
}
|
||||
|
||||
##################
|
||||
## editComment
|
||||
##################
|
||||
@@ -2805,6 +2850,12 @@ type Mutation {
|
||||
"""
|
||||
createComment(input: CreateCommentInput!): CreateCommentPayload
|
||||
|
||||
"""
|
||||
createCommentReply will create a Comment as the current logged in User that is
|
||||
in reply to another Comment.
|
||||
"""
|
||||
createCommentReply(input: CreateCommentReplyInput!): CreateCommentReplyPayload
|
||||
|
||||
"""
|
||||
editComment will allow the author of a comment to change the body within the
|
||||
time allotment.
|
||||
|
||||
Reference in New Issue
Block a user