Improve GraphQL documentation and cleanup API
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -13,27 +13,43 @@ defmodule Mobilizon.GraphQL.Schema.Discussions.CommentType do
|
||||
object :comment do
|
||||
interfaces([:action_log_object])
|
||||
field(:id, :id, description: "Internal ID for this comment")
|
||||
field(:uuid, :uuid)
|
||||
field(:url, :string)
|
||||
field(:local, :boolean)
|
||||
field(:visibility, :comment_visibility)
|
||||
field(:text, :string)
|
||||
field(:primaryLanguage, :string)
|
||||
field(:uuid, :uuid, description: "An UUID for this comment")
|
||||
field(:url, :string, description: "Comment URL")
|
||||
field(:local, :boolean, description: "Whether this comment is local or not")
|
||||
field(:visibility, :comment_visibility, description: "The visibility for the comment")
|
||||
field(:text, :string, description: "The comment body")
|
||||
field(:primaryLanguage, :string, description: "The comment's primary language")
|
||||
|
||||
field(:replies, list_of(:comment)) do
|
||||
description("A list of replies to the comment")
|
||||
resolve(dataloader(Discussions))
|
||||
end
|
||||
|
||||
field(:total_replies, :integer)
|
||||
field(:in_reply_to_comment, :comment, resolve: dataloader(Discussions))
|
||||
field(:event, :event, resolve: dataloader(Events))
|
||||
field(:origin_comment, :comment, resolve: dataloader(Discussions))
|
||||
field(:threadLanguages, non_null(list_of(:string)))
|
||||
field(:actor, :person, resolve: dataloader(Actors))
|
||||
field(:inserted_at, :datetime)
|
||||
field(:updated_at, :datetime)
|
||||
field(:deleted_at, :datetime)
|
||||
field(:published_at, :datetime)
|
||||
field(:total_replies, :integer,
|
||||
description: "The number of total known replies to this comment"
|
||||
)
|
||||
|
||||
field(:in_reply_to_comment, :comment,
|
||||
resolve: dataloader(Discussions),
|
||||
description: "The comment this comment directly replies to"
|
||||
)
|
||||
|
||||
field(:event, :event,
|
||||
resolve: dataloader(Events),
|
||||
description: "The eventual event this comment is under"
|
||||
)
|
||||
|
||||
field(:origin_comment, :comment,
|
||||
resolve: dataloader(Discussions),
|
||||
description: "The original comment that started the thread this comment is in"
|
||||
)
|
||||
|
||||
field(:threadLanguages, non_null(list_of(:string)), description: "The thread languages")
|
||||
field(:actor, :person, resolve: dataloader(Actors), description: "The comment's author")
|
||||
field(:inserted_at, :datetime, description: "When was the comment inserted in database")
|
||||
field(:updated_at, :datetime, description: "When was the comment updated")
|
||||
field(:deleted_at, :datetime, description: "When was the comment deleted")
|
||||
field(:published_at, :datetime, description: "When was the comment published")
|
||||
end
|
||||
|
||||
@desc "The list of visibility options for a comment"
|
||||
@@ -49,6 +65,7 @@ defmodule Mobilizon.GraphQL.Schema.Discussions.CommentType do
|
||||
value(:invite, description: "visible only to people invited")
|
||||
end
|
||||
|
||||
@desc "A paginated list of comments"
|
||||
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")
|
||||
@@ -57,7 +74,7 @@ defmodule Mobilizon.GraphQL.Schema.Discussions.CommentType do
|
||||
object :comment_queries do
|
||||
@desc "Get replies for thread"
|
||||
field :thread, type: list_of(:comment) do
|
||||
arg(:id, :id)
|
||||
arg(:id, non_null(:id), description: "The comment ID")
|
||||
resolve(&Comment.get_thread/3)
|
||||
end
|
||||
end
|
||||
@@ -65,25 +82,24 @@ defmodule Mobilizon.GraphQL.Schema.Discussions.CommentType do
|
||||
object :comment_mutations do
|
||||
@desc "Create a comment"
|
||||
field :create_comment, type: :comment do
|
||||
arg(:text, non_null(:string))
|
||||
arg(:event_id, non_null(:id))
|
||||
arg(:in_reply_to_comment_id, :id)
|
||||
arg(:actor_id, non_null(:id))
|
||||
arg(:text, non_null(:string), description: "The comment's body")
|
||||
arg(:event_id, non_null(:id), description: "The event under which this comment is")
|
||||
arg(:in_reply_to_comment_id, :id, description: "The comment ID this one replies to")
|
||||
|
||||
resolve(&Comment.create_comment/3)
|
||||
end
|
||||
|
||||
@desc "Update a comment"
|
||||
field :update_comment, type: :comment do
|
||||
arg(:text, non_null(:string))
|
||||
arg(:comment_id, non_null(:id))
|
||||
arg(:text, non_null(:string), description: "The comment updated body")
|
||||
arg(:comment_id, non_null(:id), description: "The comment ID")
|
||||
|
||||
resolve(&Comment.update_comment/3)
|
||||
end
|
||||
|
||||
@desc "Delete a single comment"
|
||||
field :delete_comment, type: :comment do
|
||||
arg(:comment_id, non_null(:id))
|
||||
arg(:comment_id, non_null(:id), description: "The comment ID")
|
||||
|
||||
resolve(&Comment.delete_comment/3)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user