37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { Args, ID, Mutation, Resolver } from '@nestjs/graphql';
|
|
import { User } from '@task-stream/api/identity/domain';
|
|
import { CurrentUser } from '@task-stream/api/identity/presenters';
|
|
import { CommentsService } from '@task-stream/api/tracker/application';
|
|
import { CommandResultGql, CommentGql } from './types';
|
|
|
|
@Resolver(() => CommentGql)
|
|
export class CommentResolver {
|
|
constructor(private readonly comments: CommentsService) {}
|
|
|
|
@Mutation(() => CommandResultGql)
|
|
addComment(
|
|
@CurrentUser() me: User,
|
|
@Args('issueId', { type: () => ID }) issueId: string,
|
|
@Args('body') body: string,
|
|
) {
|
|
return this.comments.add(me.id, issueId, body);
|
|
}
|
|
|
|
@Mutation(() => CommandResultGql)
|
|
editComment(
|
|
@CurrentUser() me: User,
|
|
@Args('commentId', { type: () => ID }) commentId: string,
|
|
@Args('body') body: string,
|
|
) {
|
|
return this.comments.edit(me.id, commentId, body);
|
|
}
|
|
|
|
@Mutation(() => CommandResultGql, { description: 'Author or project admin' })
|
|
deleteComment(
|
|
@CurrentUser() me: User,
|
|
@Args('commentId', { type: () => ID }) commentId: string,
|
|
) {
|
|
return this.comments.delete(me.id, commentId);
|
|
}
|
|
}
|