|
| 1 | +defmodule GroupherServerWeb.Schema.CMS.Mutations.Guide do |
| 2 | + @moduledoc """ |
| 3 | + CMS mutations for guide |
| 4 | + """ |
| 5 | + use Helper.GqlSchemaSuite |
| 6 | + import GroupherServerWeb.Schema.Helper.Mutations |
| 7 | + |
| 8 | + object :cms_guide_mutations do |
| 9 | + @desc "create a guide" |
| 10 | + field :create_guide, :guide 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(:thread, :thread, default_value: :guide) |
| 16 | + arg(:article_tags, list_of(:id)) |
| 17 | + |
| 18 | + middleware(M.Authorize, :login) |
| 19 | + middleware(M.PublishThrottle) |
| 20 | + resolve(&R.CMS.create_article/3) |
| 21 | + middleware(M.Statistics.MakeContribute, for: [:user, :community]) |
| 22 | + end |
| 23 | + |
| 24 | + @desc "update a cms/guide" |
| 25 | + field :update_guide, :guide do |
| 26 | + arg(:id, non_null(:id)) |
| 27 | + arg(:title, :string) |
| 28 | + arg(:body, :string) |
| 29 | + arg(:digest, :string) |
| 30 | + |
| 31 | + arg(:article_tags, list_of(:id)) |
| 32 | + # ... |
| 33 | + |
| 34 | + middleware(M.Authorize, :login) |
| 35 | + middleware(M.PassportLoader, source: :guide) |
| 36 | + middleware(M.Passport, claim: "owner;cms->c?->guide.edit") |
| 37 | + |
| 38 | + resolve(&R.CMS.update_article/3) |
| 39 | + end |
| 40 | + |
| 41 | + article_react_mutations(:guide, [ |
| 42 | + :upvote, |
| 43 | + :pin, |
| 44 | + :mark_delete, |
| 45 | + :delete, |
| 46 | + :emotion, |
| 47 | + :report, |
| 48 | + :sink, |
| 49 | + :lock_comment |
| 50 | + ]) |
| 51 | + end |
| 52 | +end |
0 commit comments