Skip to content

Commit

Permalink
Merge pull request #3315 from SeedCompany/comments/expose-up
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonF authored Oct 17, 2024
2 parents 4beaa9d + 9f4e4f2 commit febff99
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/comments/comment-thread.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ export class CommentThreadResolver {
return await this.resources.loadByBaseNode(thread.parent);
}

@ResolveField(() => Commentable)
async container(@Parent() thread: CommentThread) {
return await this.resources.loadByBaseNode(thread.parent);
}

@ResolveField(() => User)
async creator(
@Parent() thread: CommentThread,
Expand Down
20 changes: 20 additions & 0 deletions src/components/comments/comment.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import { ID, IdArg, LoggedInSession, Session } from '~/common';
import { Loader, LoaderOf } from '~/core';
import { UserLoader } from '../user';
import { User } from '../user/dto';
import { CommentThreadLoader as ThreadLoader } from './comment-thread.loader';
import { CommentService } from './comment.service';
import {
Comment,
Commentable,
CommentThread,
DeleteCommentOutput,
UpdateCommentInput,
UpdateCommentOutput,
Expand Down Expand Up @@ -50,4 +53,21 @@ export class CommentResolver {
): Promise<User> {
return await users.load(comment.creator);
}

@ResolveField(() => CommentThread)
async thread(
@Parent() comment: Comment,
@Loader(ThreadLoader) threads: LoaderOf<ThreadLoader>,
): Promise<CommentThread> {
return await threads.load(comment.thread);
}

@ResolveField(() => Commentable)
async container(
@Parent() comment: Comment,
@Loader(ThreadLoader) threads: LoaderOf<ThreadLoader>,
): Promise<Commentable> {
const thread = await threads.load(comment.thread);
return await this.service.loadCommentable(thread.parent);
}
}

0 comments on commit febff99

Please sign in to comment.