@@ -5,34 +5,6 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
5
5
alias GroupherServerWeb.Middleware , as: M
6
6
alias GroupherServerWeb.Resolvers , as: R
7
7
8
- defmacro article_sink_mutation ( thread ) do
9
- quote do
10
- @ desc unquote ( "sink a#{ thread } " )
11
- field unquote ( :"sink_#{ thread } " ) , :article do
12
- arg ( :id , non_null ( :id ) )
13
- arg ( :community_id , non_null ( :id ) )
14
- arg ( :thread , unquote ( :"#{ thread } _thread" ) , default_value: unquote ( thread ) )
15
-
16
- middleware ( M.Authorize , :login )
17
- middleware ( M.PassportLoader , source: :community )
18
- middleware ( M.Passport , claim: unquote ( "cms->c?->#{ to_string ( thread ) } .sink" ) )
19
- resolve ( & R.CMS . sink_article / 3 )
20
- end
21
-
22
- @ desc unquote ( "undo sink to#{ thread } " )
23
- field unquote ( :"undo_sink_#{ thread } " ) , :article do
24
- arg ( :id , non_null ( :id ) )
25
- arg ( :community_id , non_null ( :id ) )
26
- arg ( :thread , unquote ( :"#{ thread } _thread" ) , default_value: unquote ( thread ) )
27
-
28
- middleware ( M.Authorize , :login )
29
- middleware ( M.PassportLoader , source: :community )
30
- middleware ( M.Passport , claim: unquote ( "cms->c?->#{ to_string ( thread ) } .undo_sink" ) )
31
- resolve ( & R.CMS . undo_sink_article / 3 )
32
- end
33
- end
34
- end
35
-
36
8
defmacro article_upvote_mutation ( thread ) do
37
9
quote do
38
10
@ desc unquote ( "upvote to#{ thread } " )
@@ -172,4 +144,60 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
172
144
end
173
145
end
174
146
end
147
+
148
+ defmacro article_sink_mutation ( thread ) do
149
+ quote do
150
+ @ desc unquote ( "sink a#{ thread } " )
151
+ field unquote ( :"sink_#{ thread } " ) , :article do
152
+ arg ( :id , non_null ( :id ) )
153
+ arg ( :community_id , non_null ( :id ) )
154
+ arg ( :thread , unquote ( :"#{ thread } _thread" ) , default_value: unquote ( thread ) )
155
+
156
+ middleware ( M.Authorize , :login )
157
+ middleware ( M.PassportLoader , source: :community )
158
+ middleware ( M.Passport , claim: unquote ( "cms->c?->#{ to_string ( thread ) } .sink" ) )
159
+ resolve ( & R.CMS . sink_article / 3 )
160
+ end
161
+
162
+ @ desc unquote ( "undo sink to#{ thread } " )
163
+ field unquote ( :"undo_sink_#{ thread } " ) , :article do
164
+ arg ( :id , non_null ( :id ) )
165
+ arg ( :community_id , non_null ( :id ) )
166
+ arg ( :thread , unquote ( :"#{ thread } _thread" ) , default_value: unquote ( thread ) )
167
+
168
+ middleware ( M.Authorize , :login )
169
+ middleware ( M.PassportLoader , source: :community )
170
+ middleware ( M.Passport , claim: unquote ( "cms->c?->#{ to_string ( thread ) } .undo_sink" ) )
171
+ resolve ( & R.CMS . undo_sink_article / 3 )
172
+ end
173
+ end
174
+ end
175
+
176
+ defmacro article_lock_comment_mutation ( thread ) do
177
+ quote do
178
+ @ desc unquote ( "lock comment to a#{ thread } " )
179
+ field unquote ( :"lock_#{ thread } _comment" ) , :article do
180
+ arg ( :id , non_null ( :id ) )
181
+ arg ( :community_id , non_null ( :id ) )
182
+ arg ( :thread , unquote ( :"#{ thread } _thread" ) , default_value: unquote ( thread ) )
183
+
184
+ middleware ( M.Authorize , :login )
185
+ middleware ( M.PassportLoader , source: :community )
186
+ middleware ( M.Passport , claim: unquote ( "cms->c?->#{ to_string ( thread ) } .lock_comment" ) )
187
+ resolve ( & R.CMS . lock_article_comment / 3 )
188
+ end
189
+
190
+ @ desc unquote ( "undo lock to a#{ thread } " )
191
+ field unquote ( :"undo_lock_#{ thread } _comment" ) , :article do
192
+ arg ( :id , non_null ( :id ) )
193
+ arg ( :community_id , non_null ( :id ) )
194
+ arg ( :thread , unquote ( :"#{ thread } _thread" ) , default_value: unquote ( thread ) )
195
+
196
+ middleware ( M.Authorize , :login )
197
+ middleware ( M.PassportLoader , source: :community )
198
+ middleware ( M.Passport , claim: unquote ( "cms->c?->#{ to_string ( thread ) } .undo_lock_comment" ) )
199
+ resolve ( & R.CMS . undo_lock_article_comment / 3 )
200
+ end
201
+ end
202
+ end
175
203
end