2020-01-26 20:34:25 +01:00
|
|
|
defmodule Mobilizon.GraphQL.Schema.Actors.FollowerType do
|
2019-01-14 17:48:08 +01:00
|
|
|
@moduledoc """
|
|
|
|
Schema representation for Follower
|
|
|
|
"""
|
2019-01-14 17:13:17 +01:00
|
|
|
use Absinthe.Schema.Notation
|
2021-01-20 18:16:44 +01:00
|
|
|
alias Mobilizon.GraphQL.Resolvers.Followers
|
2019-01-14 17:13:17 +01:00
|
|
|
|
|
|
|
@desc """
|
|
|
|
Represents an actor's follower
|
|
|
|
"""
|
|
|
|
object :follower do
|
2023-03-17 18:10:59 +01:00
|
|
|
meta(:authorize, :user)
|
2021-01-20 18:16:44 +01:00
|
|
|
field(:id, :id, description: "The follow ID")
|
2019-01-14 17:13:17 +01:00
|
|
|
field(:target_actor, :actor, description: "What or who the profile follows")
|
|
|
|
field(:actor, :actor, description: "Which profile follows")
|
|
|
|
|
|
|
|
field(:approved, :boolean,
|
|
|
|
description: "Whether the follow has been approved by the target actor"
|
|
|
|
)
|
2019-12-03 11:29:51 +01:00
|
|
|
|
2021-10-22 11:40:47 +02:00
|
|
|
field(:notify, :boolean,
|
|
|
|
description:
|
|
|
|
"Whether the follower will be notified by the target actor's activity or not (applicable for profile/group follows)"
|
|
|
|
)
|
|
|
|
|
2019-12-03 11:29:51 +01:00
|
|
|
field(:inserted_at, :datetime, description: "When the follow was created")
|
|
|
|
field(:updated_at, :datetime, description: "When the follow was updated")
|
|
|
|
end
|
|
|
|
|
2020-11-19 17:06:28 +01:00
|
|
|
@desc """
|
|
|
|
A paginated list of follower objects
|
|
|
|
"""
|
2019-12-03 11:29:51 +01:00
|
|
|
object :paginated_follower_list do
|
2023-03-17 18:10:59 +01:00
|
|
|
meta(:authorize, :user)
|
2019-12-03 11:29:51 +01:00
|
|
|
field(:elements, list_of(:follower), description: "A list of followers")
|
|
|
|
field(:total, :integer, description: "The total number of elements in the list")
|
2019-01-14 17:13:17 +01:00
|
|
|
end
|
2021-01-20 18:16:44 +01:00
|
|
|
|
|
|
|
object :follower_mutations do
|
|
|
|
@desc "Update follower"
|
|
|
|
field :update_follower, :follower do
|
|
|
|
arg(:id, non_null(:id), description: "The follower ID")
|
|
|
|
|
|
|
|
arg(:approved, non_null(:boolean),
|
|
|
|
description: "Whether the follower has been approved by the target actor or not"
|
|
|
|
)
|
|
|
|
|
2023-03-17 18:10:59 +01:00
|
|
|
middleware(Rajska.QueryAuthorization, permit: :user, scope: false)
|
|
|
|
|
2021-01-20 18:16:44 +01:00
|
|
|
resolve(&Followers.update_follower/3)
|
|
|
|
end
|
|
|
|
end
|
2019-01-14 17:13:17 +01:00
|
|
|
end
|