@@ -4,8 +4,16 @@ import { PubSub } from 'graphql-subscriptions';
4
4
import { MyUserId } from 'src/auth/myContext' ;
5
5
import { StatAuthGuard } from 'src/auth/statAuthGuard' ;
6
6
import { HttpExceptionFilter } from 'src/http-exception.filter' ;
7
+ import {
8
+ FollowListPaginatedArgs ,
9
+ FollowSortOrder ,
10
+ } from './dto/follow.dto.getFollowList' ;
7
11
import { FollowService } from './follow.service' ;
8
- import { FollowListWithCount , FollowResult } from './model/follow.model' ;
12
+ import {
13
+ FollowListPaginated ,
14
+ FollowListWithCount ,
15
+ FollowResult ,
16
+ } from './model/follow.model' ;
9
17
10
18
const pubSub = new PubSub ( ) ;
11
19
@@ -24,17 +32,6 @@ export class FollowResolver {
24
32
return pubSub . asyncIterator ( 'followUpdated' ) ;
25
33
}
26
34
27
- @Mutation ( ( _returns ) => FollowResult , {
28
- description : 'ํ๋ก ํธ ํ
์คํธ์ฉ ์์ ํจ์' ,
29
- } )
30
- async MakeFollow (
31
- @Args ( 'to' ) to : string ,
32
- @Args ( 'from' ) from : string ,
33
- @Args ( 'type' ) type : 'follow' | 'unfollow' ,
34
- ) : Promise < typeof FollowResult > {
35
- return await this . followService . MakeFollowUser ( to , from , type ) ;
36
- }
37
-
38
35
@UseGuards ( StatAuthGuard )
39
36
@Mutation ( ( _returns ) => FollowResult )
40
37
async followUser (
@@ -71,37 +68,65 @@ export class FollowResolver {
71
68
@MyUserId ( ) userId : number ,
72
69
@Args ( 'target' ) target : string ,
73
70
@Args ( 'limit' , { defaultValue : 3 } ) limit : number ,
71
+ @Args ( 'sortOrder' , { type : ( ) => FollowSortOrder } )
72
+ sortOrder : FollowSortOrder ,
74
73
) : Promise < FollowListWithCount > {
75
- const followerList = await this . followService . getFollowerList (
74
+ const targetId = await this . followService . userIdByLogin ( target ) ;
75
+ const count = await this . followService . followerCount ( targetId ) ;
76
+
77
+ const followerList = await this . followService . followerList (
76
78
userId ,
77
79
target ,
78
80
limit ,
81
+ sortOrder ,
79
82
) ;
80
- const count = await this . followService . getFollowerCount ( target ) ;
81
83
82
84
return {
83
85
count,
84
86
followList : followerList ,
85
87
} ;
86
88
}
87
89
90
+ @UseGuards ( StatAuthGuard )
91
+ @Query ( ( _returns ) => FollowListPaginated )
92
+ async getFollowerPaginated (
93
+ @MyUserId ( ) userId : number ,
94
+ @Args ( ) args : FollowListPaginatedArgs ,
95
+ ) : Promise < FollowListPaginated > {
96
+ return await this . followService . followerPaginated ( userId , args ) ;
97
+ }
98
+
88
99
@UseGuards ( StatAuthGuard )
89
100
@Query ( ( _returns ) => FollowListWithCount )
90
101
async getFollowingList (
91
102
@MyUserId ( ) userId : number ,
92
103
@Args ( 'target' ) target : string ,
93
104
@Args ( 'limit' , { defaultValue : 3 } ) limit : number ,
105
+ @Args ( 'sortOrder' , { type : ( ) => FollowSortOrder } )
106
+ sortOrder : FollowSortOrder ,
94
107
) : Promise < FollowListWithCount > {
95
- const followingList = await this . followService . getFollowingList (
108
+ const targetId = await this . followService . userIdByLogin ( target ) ;
109
+ const count = await this . followService . followingCount ( targetId ) ;
110
+
111
+ const followingList = await this . followService . followingList (
96
112
userId ,
97
113
target ,
98
114
limit ,
115
+ sortOrder ,
99
116
) ;
100
- const count = await this . followService . getFollowingCount ( target ) ;
101
117
102
118
return {
103
119
count,
104
120
followList : followingList ,
105
121
} ;
106
122
}
123
+
124
+ @UseGuards ( StatAuthGuard )
125
+ @Query ( ( _returns ) => FollowListPaginated )
126
+ async getFollowingPaginated (
127
+ @MyUserId ( ) userId : number ,
128
+ @Args ( ) args : FollowListPaginatedArgs ,
129
+ ) : Promise < FollowListPaginated > {
130
+ return await this . followService . followingPaginated ( userId , args ) ;
131
+ }
107
132
}
0 commit comments