2020-07-09 15:24:28 +00:00
|
|
|
defmodule Mobilizon.GraphQL.Schema.Discussions.CommentType do
|
2019-01-14 16:48:08 +00:00
|
|
|
@moduledoc """
|
|
|
|
Schema representation for Comment
|
|
|
|
"""
|
2019-01-14 16:13:17 +00:00
|
|
|
use Absinthe.Schema.Notation
|
2020-01-26 19:34:25 +00:00
|
|
|
|
2019-11-15 17:36:47 +00:00
|
|
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
2019-01-14 16:13:17 +00:00
|
|
|
|
2020-07-09 15:24:28 +00:00
|
|
|
alias Mobilizon.{Actors, Discussions}
|
2020-01-26 19:34:25 +00:00
|
|
|
alias Mobilizon.GraphQL.Resolvers.Comment
|
|
|
|
|
2019-01-14 16:13:17 +00:00
|
|
|
@desc "A comment"
|
|
|
|
object :comment do
|
2019-11-15 17:36:47 +00:00
|
|
|
interfaces([:action_log_object])
|
2019-01-21 14:08:22 +00:00
|
|
|
field(:id, :id, description: "Internal ID for this comment")
|
2019-01-14 16:13:17 +00:00
|
|
|
field(:uuid, :uuid)
|
|
|
|
field(:url, :string)
|
|
|
|
field(:local, :boolean)
|
2019-01-14 16:48:08 +00:00
|
|
|
field(:visibility, :comment_visibility)
|
2019-01-14 16:13:17 +00:00
|
|
|
field(:text, :string)
|
|
|
|
field(:primaryLanguage, :string)
|
2019-11-15 17:36:47 +00:00
|
|
|
|
|
|
|
field(:replies, list_of(:comment)) do
|
2020-07-09 15:24:28 +00:00
|
|
|
resolve(dataloader(Discussions))
|
2019-11-15 17:36:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
field(:total_replies, :integer)
|
2020-07-09 15:24:28 +00:00
|
|
|
field(:in_reply_to_comment, :comment, resolve: dataloader(Discussions))
|
2019-11-15 17:36:47 +00:00
|
|
|
field(:event, :event, resolve: dataloader(Events))
|
2020-07-09 15:24:28 +00:00
|
|
|
field(:origin_comment, :comment, resolve: dataloader(Discussions))
|
2019-01-14 16:13:17 +00:00
|
|
|
field(:threadLanguages, non_null(list_of(:string)))
|
2019-11-15 17:36:47 +00:00
|
|
|
field(:actor, :person, resolve: dataloader(Actors))
|
|
|
|
field(:inserted_at, :datetime)
|
|
|
|
field(:updated_at, :datetime)
|
|
|
|
field(:deleted_at, :datetime)
|
2020-08-27 09:53:24 +00:00
|
|
|
field(:published_at, :datetime)
|
2019-01-14 16:13:17 +00:00
|
|
|
end
|
2019-01-14 16:48:08 +00:00
|
|
|
|
|
|
|
@desc "The list of visibility options for a comment"
|
|
|
|
enum :comment_visibility do
|
2019-09-16 13:11:43 +00:00
|
|
|
value(:public, description: "Publicly listed and federated. Can be shared.")
|
2019-01-14 16:48:08 +00:00
|
|
|
value(:unlisted, description: "Visible only to people with the link - or invited")
|
|
|
|
|
|
|
|
value(:private,
|
|
|
|
description: "Visible only to people members of the group or followers of the person"
|
|
|
|
)
|
|
|
|
|
|
|
|
value(:moderated, description: "Visible only after a moderator accepted")
|
|
|
|
value(:invite, description: "visible only to people invited")
|
|
|
|
end
|
2019-01-25 14:41:10 +00:00
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
object :paginated_comment_list do
|
|
|
|
field(:elements, list_of(:comment), description: "A list of comments")
|
|
|
|
field(:total, :integer, description: "The total number of comments in the list")
|
|
|
|
end
|
|
|
|
|
2019-11-15 17:36:47 +00:00
|
|
|
object :comment_queries do
|
|
|
|
@desc "Get replies for thread"
|
|
|
|
field :thread, type: list_of(:comment) do
|
|
|
|
arg(:id, :id)
|
|
|
|
resolve(&Comment.get_thread/3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-01-25 14:41:10 +00:00
|
|
|
object :comment_mutations do
|
|
|
|
@desc "Create a comment"
|
|
|
|
field :create_comment, type: :comment do
|
|
|
|
arg(:text, non_null(:string))
|
2019-11-15 17:36:47 +00:00
|
|
|
arg(:event_id, :id)
|
|
|
|
arg(:in_reply_to_comment_id, :id)
|
2019-10-25 15:43:37 +00:00
|
|
|
arg(:actor_id, non_null(:id))
|
2019-01-25 14:41:10 +00:00
|
|
|
|
|
|
|
resolve(&Comment.create_comment/3)
|
|
|
|
end
|
2019-11-15 17:36:47 +00:00
|
|
|
|
2020-02-18 07:57:00 +00:00
|
|
|
@desc "Update a comment"
|
|
|
|
field :update_comment, type: :comment do
|
|
|
|
arg(:text, non_null(:string))
|
|
|
|
arg(:comment_id, non_null(:id))
|
|
|
|
|
|
|
|
resolve(&Comment.update_comment/3)
|
|
|
|
end
|
|
|
|
|
2020-08-14 09:32:23 +00:00
|
|
|
@desc "Delete a single comment"
|
2019-11-15 17:36:47 +00:00
|
|
|
field :delete_comment, type: :comment do
|
|
|
|
arg(:comment_id, non_null(:id))
|
|
|
|
|
|
|
|
resolve(&Comment.delete_comment/3)
|
|
|
|
end
|
2019-01-25 14:41:10 +00:00
|
|
|
end
|
2019-01-14 16:13:17 +00:00
|
|
|
end
|