1
1
import { Info , Parent , Query , ResolveField , Resolver } from '@nestjs/graphql' ;
2
2
import {
3
- AnonSession ,
4
3
Fields ,
5
4
type ID ,
6
5
IdArg ,
7
6
IsOnly ,
8
7
ListArg ,
9
8
type Resource ,
10
9
SecuredList ,
11
- type Session ,
12
10
} from '~/common' ;
13
11
import { Loader , type LoaderOf } from '~/core' ;
12
+ import { Identity } from '~/core/authentication' ;
14
13
import { CommentThreadLoader } from './comment-thread.loader' ;
15
14
import { CommentService } from './comment.service' ;
16
15
import { Commentable , CommentThreadList , CommentThreadListInput } from './dto' ;
17
16
18
17
@Resolver ( Commentable )
19
18
export class CommentableResolver {
20
- constructor ( private readonly service : CommentService ) { }
19
+ constructor (
20
+ private readonly service : CommentService ,
21
+ private readonly identity : Identity ,
22
+ ) { }
21
23
22
24
@Query ( ( ) => Commentable , {
23
25
description : 'Load a commentable resource by ID' ,
@@ -32,12 +34,11 @@ export class CommentableResolver {
32
34
async commentThreads (
33
35
@Parent ( ) parent : Commentable & Resource ,
34
36
@ListArg ( CommentThreadListInput ) input : CommentThreadListInput ,
35
- @AnonSession ( ) session : Session ,
36
37
@Loader ( CommentThreadLoader ) commentThreads : LoaderOf < CommentThreadLoader > ,
37
38
@Info ( Fields , IsOnly ( [ 'total' ] ) ) onlyTotal : boolean ,
38
39
) {
39
40
// TODO move to auth policy
40
- if ( session . anonymous ) {
41
+ if ( this . identity . isAnonymous ) {
41
42
return { parent, ...SecuredList . Redacted } ;
42
43
}
43
44
if ( onlyTotal ) {
0 commit comments