Skip to content

Commit a8548a8

Browse files
committed
Add Comment { thread, container }
1 parent 4beaa9d commit a8548a8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/components/comments/comment.resolver.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ import { ID, IdArg, LoggedInSession, Session } from '~/common';
99
import { Loader, LoaderOf } from '~/core';
1010
import { UserLoader } from '../user';
1111
import { User } from '../user/dto';
12+
import { CommentThreadLoader as ThreadLoader } from './comment-thread.loader';
1213
import { CommentService } from './comment.service';
1314
import {
1415
Comment,
16+
Commentable,
17+
CommentThread,
1518
DeleteCommentOutput,
1619
UpdateCommentInput,
1720
UpdateCommentOutput,
@@ -50,4 +53,21 @@ export class CommentResolver {
5053
): Promise<User> {
5154
return await users.load(comment.creator);
5255
}
56+
57+
@ResolveField(() => CommentThread)
58+
async thread(
59+
@Parent() comment: Comment,
60+
@Loader(ThreadLoader) threads: LoaderOf<ThreadLoader>,
61+
): Promise<CommentThread> {
62+
return await threads.load(comment.thread);
63+
}
64+
65+
@ResolveField(() => Commentable)
66+
async container(
67+
@Parent() comment: Comment,
68+
@Loader(ThreadLoader) threads: LoaderOf<ThreadLoader>,
69+
): Promise<Commentable> {
70+
const thread = await threads.load(comment.thread);
71+
return await this.service.loadCommentable(thread.parent);
72+
}
5373
}

0 commit comments

Comments
 (0)