Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit d6157ad

Browse files
committed
chore(works): missing schema
1 parent 59e6f8b commit d6157ad

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

lib/groupher_server_web/schema/Helper/queries.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,7 @@ defmodule GroupherServerWeb.Schema.Helper.Queries do
8181
end
8282
end
8383
end
84+
85+
def thread_plural(:works), do: :works
86+
def thread_plural(thread), do: :"#{thread}s"
8487
end

lib/groupher_server_web/schema/cms/mutations/blog.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Blog do
3232
arg(:length, :integer)
3333
arg(:link_addr, :string)
3434

35-
arg(:company, :string)
36-
arg(:company_link, :string)
3735
arg(:article_tags, list_of(:id))
3836

3937
# ...
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
defmodule GroupherServerWeb.Schema.CMS.Mutations.Works do
2+
@moduledoc """
3+
CMS mutations for works
4+
"""
5+
use Helper.GqlSchemaSuite
6+
import GroupherServerWeb.Schema.Helper.Mutations
7+
8+
object :cms_works_mutations do
9+
@desc "create a works"
10+
field :create_works, :works do
11+
arg(:title, non_null(:string))
12+
arg(:body, non_null(:string))
13+
arg(:digest, non_null(:string))
14+
arg(:community_id, non_null(:id))
15+
arg(:link_addr, :string)
16+
arg(:thread, :thread, default_value: :works)
17+
arg(:article_tags, list_of(:id))
18+
19+
middleware(M.Authorize, :login)
20+
middleware(M.PublishThrottle)
21+
resolve(&R.CMS.create_article/3)
22+
middleware(M.Statistics.MakeContribute, for: [:user, :community])
23+
end
24+
25+
@desc "update a cms/works"
26+
field :update_works, :works do
27+
arg(:id, non_null(:id))
28+
arg(:title, :string)
29+
arg(:body, :string)
30+
arg(:digest, :string)
31+
32+
arg(:article_tags, list_of(:id))
33+
# ...
34+
35+
middleware(M.Authorize, :login)
36+
middleware(M.PassportLoader, source: :works)
37+
middleware(M.Passport, claim: "owner;cms->c?->works.edit")
38+
39+
resolve(&R.CMS.update_article/3)
40+
end
41+
42+
#############
43+
article_upvote_mutation(:works)
44+
article_pin_mutation(:works)
45+
article_mark_delete_mutation(:works)
46+
article_delete_mutation(:works)
47+
article_emotion_mutation(:works)
48+
article_report_mutation(:works)
49+
article_sink_mutation(:works)
50+
article_lock_comment_mutation(:works)
51+
#############
52+
end
53+
end

lib/helper/utils/utils.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ defmodule Helper.Utils do
4949
end
5050
end
5151

52+
@doc """
53+
get plural version of a thread
54+
"""
55+
def thread_plural(:works), do: :works
56+
def thread_plural(thread), do: :"#{thread}s"
57+
5258
@doc """
5359
like || in javascript
5460
"""

0 commit comments

Comments
 (0)