@@ -2,29 +2,16 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
2
2
@ moduledoc """
3
3
general mutations used for articles
4
4
5
+ can not dedefine private macros, see:
6
+ https://github.com/elixir-lang/elixir/issues/3887
7
+
5
8
e.g:
6
9
in schema/cms/mutation/post.ex
7
10
8
11
add following:
9
- article_upvote_mutation(:post)
10
-
11
- post will have two mutation endpoint:
12
-
13
- upvote_post
14
- unto_emotion_post
15
-
16
- same for the job/repo .. article thread
17
- """
18
- alias GroupherServerWeb.Middleware , as: M
19
- alias GroupherServerWeb.Resolvers , as: R
12
+ article_react_mutations(:post, [:upvote, :pin, :mark_delete, :delete, :emotion, :report, :sink, :lock_comment])
20
13
21
- @ doc """
22
- e.g:
23
-
24
- turn:
25
- article_react_mutations(:radar, [:upvote, :pin, :mark_delete, :delete, :emotion, :report, :sink, :lock_comment])
26
-
27
- into:
14
+ it will expand as
28
15
article_upvote_mutation(:radar)
29
16
article_pin_mutation(:radar)
30
17
article_mark_delete_mutation(:radar)
@@ -33,6 +20,14 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
33
20
article_report_mutation(:radar)
34
21
article_sink_mutation(:radar)
35
22
article_lock_comment_mutation(:radar)
23
+
24
+ same for the job/repo .. article thread
25
+ """
26
+ alias GroupherServerWeb.Middleware , as: M
27
+ alias GroupherServerWeb.Resolvers , as: R
28
+
29
+ @ doc """
30
+ add basic mutation reactions to article
36
31
"""
37
32
defmacro article_react_mutations ( thread , reactions ) do
38
33
reactions
@@ -51,7 +46,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
51
46
upvote_[thread]
52
47
unto_emotion_[thread]
53
48
"""
54
- defmacrop article_upvote_mutation ( thread ) do
49
+ defmacro article_upvote_mutation ( thread ) do
55
50
quote do
56
51
@ desc unquote ( "upvote to#{ thread } " )
57
52
field unquote ( :"upvote_#{ thread } " ) , :article do
@@ -81,7 +76,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
81
76
pin_[thread]
82
77
unto_pin_[thread]
83
78
"""
84
- defmacrop article_pin_mutation ( thread ) do
79
+ defmacro article_pin_mutation ( thread ) do
85
80
quote do
86
81
@ desc unquote ( "pin to#{ thread } " )
87
82
field unquote ( :"pin_#{ thread } " ) , unquote ( thread ) do
@@ -117,7 +112,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
117
112
mark_delete_[thread]
118
113
unto_mark_delete_[thread]
119
114
"""
120
- defmacrop article_mark_delete_mutation ( thread ) do
115
+ defmacro article_mark_delete_mutation ( thread ) do
121
116
quote do
122
117
@ desc unquote ( "mark delete a#{ thread } type article, aka soft-delete" )
123
118
field unquote ( :"mark_delete_#{ thread } " ) , unquote ( thread ) do
@@ -152,7 +147,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
152
147
mark_delete_[thread]
153
148
"""
154
149
# TODO: if post belongs to multi communities, unset instead delete
155
- defmacrop article_delete_mutation ( thread ) do
150
+ defmacro article_delete_mutation ( thread ) do
156
151
quote do
157
152
@ desc unquote ( "delete a#{ thread } , not delete" )
158
153
field unquote ( :"delete_#{ thread } " ) , unquote ( thread ) do
@@ -175,7 +170,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
175
170
emotion_to_[thread]
176
171
unto_emotion_to_[thread]
177
172
"""
178
- defmacrop article_emotion_mutation ( thread ) do
173
+ defmacro article_emotion_mutation ( thread ) do
179
174
quote do
180
175
@ desc unquote ( "emotion to#{ thread } " )
181
176
field unquote ( :"emotion_to_#{ thread } " ) , unquote ( thread ) do
@@ -207,7 +202,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
207
202
report_[thread]
208
203
undo_report_[thread]
209
204
"""
210
- defmacrop article_report_mutation ( thread ) do
205
+ defmacro article_report_mutation ( thread ) do
211
206
quote do
212
207
@ desc unquote ( "report a#{ thread } " )
213
208
field unquote ( :"report_#{ thread } " ) , unquote ( thread ) do
@@ -239,7 +234,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
239
234
sink_[thread]
240
235
undo_sink_[thread]
241
236
"""
242
- defmacrop article_sink_mutation ( thread ) do
237
+ defmacro article_sink_mutation ( thread ) do
243
238
quote do
244
239
@ desc unquote ( "sink a#{ thread } " )
245
240
field unquote ( :"sink_#{ thread } " ) , :article do
@@ -275,7 +270,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
275
270
lock_[thread]_comment
276
271
undo_lock_[thread]_comment
277
272
"""
278
- defmacrop article_lock_comment_mutation ( thread ) do
273
+ defmacro article_lock_comment_mutation ( thread ) do
279
274
quote do
280
275
@ desc unquote ( "lock comment of a#{ thread } " )
281
276
field unquote ( :"lock_#{ thread } _comment" ) , :article do