Implement post comment mutation

This commit is contained in:
Chi Vinh Le
2018-08-30 10:23:03 +02:00
parent 60afa5518a
commit c66c5a1ade
5 changed files with 79 additions and 24 deletions
@@ -1,10 +1,16 @@
import { GQLMutationTypeResolver } from "talk-server/graph/tenant/schema/__generated__/types";
const Mutation: GQLMutationTypeResolver<void> = {
createComment: async (source, { input }, ctx) => ({
comment: await ctx.mutators.Comment.create(input),
clientMutationId: input.clientMutationId,
}),
createComment: async (source, { input }, ctx) => {
const comment = await ctx.mutators.Comment.create(input);
return {
commentEdge: {
cursor: comment.created_at,
node: comment,
},
clientMutationId: input.clientMutationId,
};
},
updateSettings: async (source, { input }, ctx) => ({
settings: await ctx.mutators.Settings.update(input.settings),
clientMutationId: input.clientMutationId,
@@ -821,9 +821,9 @@ mutation.
"""
type CreateCommentPayload {
"""
comment is the possibly created comment.
CommentEdge is the possibly created comment edge.
"""
comment: Comment
commentEdge: CommentEdge
"""
clientMutationId is required for Relay support.