Implemented comment thread target picker with new dropdown components (#295)

* First draft of new relation picker and usage in comments
---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Lucas Bordeau
2023-06-14 18:48:26 +02:00
committed by GitHub
parent 2a1804c153
commit fdfb6f10e2
22 changed files with 421 additions and 47 deletions

View File

@ -65,15 +65,6 @@ export class CommentThreadResolver {
}
return createdCommentThread;
// return this.prismaService.commentThread.create({
// data: {
// ...args.data,
// ...{ commentThreadTargets: undefined },
// ...{ comments: { createMany: { data: newCommentData } } },
// ...{ workspace: { connect: { id: workspace.id } } },
// },
// });
}
@Query(() => [CommentThread])
@ -86,6 +77,7 @@ export class CommentThreadResolver {
args,
workspace,
);
const result = await this.prismaService.commentThread.findMany(
preparedArgs,
);

View File

@ -1,4 +1,5 @@
import * as TypeGraphQL from '@nestjs/graphql';
import { CommentThreadTarget } from 'src/api/@generated/comment-thread-target/comment-thread-target.model';
import { CommentThread } from 'src/api/@generated/comment-thread/comment-thread.model';
import { Comment } from 'src/api/@generated/comment/comment.model';
import { PrismaService } from 'src/database/prisma.service';
@ -23,4 +24,21 @@ export class CommentThreadRelationsResolver {
},
});
}
@TypeGraphQL.ResolveField(() => [CommentThreadTarget], {
nullable: true,
})
async commentThreadTargets(
@TypeGraphQL.Root() commentThread: CommentThread,
): Promise<CommentThreadTarget[]> {
return this.prismaService.commentThreadTarget.findMany({
where: {
commentThreadId: commentThread.id,
},
orderBy: {
// TODO: find a way to pass it in the query
createdAt: 'desc',
},
});
}
}