@@ -2,29 +2,16 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
22 @ moduledoc """
33 general mutations used for articles
44
5+ can not dedefine private macros, see:
6+ https://github.com/elixir-lang/elixir/issues/3887
7+
58 e.g:
69 in schema/cms/mutation/post.ex
710
811 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])
2013
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
2815 article_upvote_mutation(:radar)
2916 article_pin_mutation(:radar)
3017 article_mark_delete_mutation(:radar)
@@ -33,6 +20,14 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
3320 article_report_mutation(:radar)
3421 article_sink_mutation(:radar)
3522 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
3631 """
3732 defmacro article_react_mutations ( thread , reactions ) do
3833 reactions
@@ -51,7 +46,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
5146 upvote_[thread]
5247 unto_emotion_[thread]
5348 """
54- defmacrop article_upvote_mutation ( thread ) do
49+ defmacro article_upvote_mutation ( thread ) do
5550 quote do
5651 @ desc unquote ( "upvote to #{ thread } " )
5752 field unquote ( :"upvote_#{ thread } " ) , :article do
@@ -81,7 +76,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
8176 pin_[thread]
8277 unto_pin_[thread]
8378 """
84- defmacrop article_pin_mutation ( thread ) do
79+ defmacro article_pin_mutation ( thread ) do
8580 quote do
8681 @ desc unquote ( "pin to #{ thread } " )
8782 field unquote ( :"pin_#{ thread } " ) , unquote ( thread ) do
@@ -117,7 +112,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
117112 mark_delete_[thread]
118113 unto_mark_delete_[thread]
119114 """
120- defmacrop article_mark_delete_mutation ( thread ) do
115+ defmacro article_mark_delete_mutation ( thread ) do
121116 quote do
122117 @ desc unquote ( "mark delete a #{ thread } type article, aka soft-delete" )
123118 field unquote ( :"mark_delete_#{ thread } " ) , unquote ( thread ) do
@@ -152,7 +147,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
152147 mark_delete_[thread]
153148 """
154149 # TODO: if post belongs to multi communities, unset instead delete
155- defmacrop article_delete_mutation ( thread ) do
150+ defmacro article_delete_mutation ( thread ) do
156151 quote do
157152 @ desc unquote ( "delete a #{ thread } , not delete" )
158153 field unquote ( :"delete_#{ thread } " ) , unquote ( thread ) do
@@ -175,7 +170,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
175170 emotion_to_[thread]
176171 unto_emotion_to_[thread]
177172 """
178- defmacrop article_emotion_mutation ( thread ) do
173+ defmacro article_emotion_mutation ( thread ) do
179174 quote do
180175 @ desc unquote ( "emotion to #{ thread } " )
181176 field unquote ( :"emotion_to_#{ thread } " ) , unquote ( thread ) do
@@ -207,7 +202,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
207202 report_[thread]
208203 undo_report_[thread]
209204 """
210- defmacrop article_report_mutation ( thread ) do
205+ defmacro article_report_mutation ( thread ) do
211206 quote do
212207 @ desc unquote ( "report a #{ thread } " )
213208 field unquote ( :"report_#{ thread } " ) , unquote ( thread ) do
@@ -239,7 +234,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
239234 sink_[thread]
240235 undo_sink_[thread]
241236 """
242- defmacrop article_sink_mutation ( thread ) do
237+ defmacro article_sink_mutation ( thread ) do
243238 quote do
244239 @ desc unquote ( "sink a #{ thread } " )
245240 field unquote ( :"sink_#{ thread } " ) , :article do
@@ -275,7 +270,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
275270 lock_[thread]_comment
276271 undo_lock_[thread]_comment
277272 """
278- defmacrop article_lock_comment_mutation ( thread ) do
273+ defmacro article_lock_comment_mutation ( thread ) do
279274 quote do
280275 @ desc unquote ( "lock comment of a #{ thread } " )
281276 field unquote ( :"lock_#{ thread } _comment" ) , :article do
0 commit comments