2019-01-14 17:13:17 +01:00
|
|
|
defmodule MobilizonWeb.Schema.Actors.MemberType do
|
2019-01-14 17:48:08 +01:00
|
|
|
@moduledoc """
|
|
|
|
Schema representation for Member
|
|
|
|
"""
|
2019-01-14 17:13:17 +01:00
|
|
|
use Absinthe.Schema.Notation
|
|
|
|
|
2019-03-01 17:11:28 +01:00
|
|
|
alias MobilizonWeb.Resolvers
|
|
|
|
|
2019-01-14 17:13:17 +01:00
|
|
|
@desc """
|
|
|
|
Represents a member of a group
|
|
|
|
"""
|
|
|
|
object :member do
|
|
|
|
field(:parent, :group, description: "Of which the profile is member")
|
2019-04-03 17:29:03 +02:00
|
|
|
field(:actor, :person, description: "Which profile is member of")
|
2019-01-14 17:13:17 +01:00
|
|
|
field(:role, :integer, description: "The role of this membership")
|
2019-03-01 17:11:28 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Represents a deleted member"
|
|
|
|
object :deleted_member do
|
|
|
|
field(:parent, :deleted_object)
|
2019-04-03 17:29:03 +02:00
|
|
|
field(:actor, :deleted_object)
|
2019-03-01 17:11:28 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
object :member_mutations do
|
|
|
|
@desc "Join a group"
|
|
|
|
field :join_group, :member do
|
2019-09-09 09:31:08 +02:00
|
|
|
arg(:group_id, non_null(:id))
|
|
|
|
arg(:actor_id, non_null(:id))
|
2019-03-01 17:11:28 +01:00
|
|
|
|
|
|
|
resolve(&Resolvers.Group.join_group/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Leave an event"
|
|
|
|
field :leave_group, :deleted_member do
|
2019-09-09 09:31:08 +02:00
|
|
|
arg(:group_id, non_null(:id))
|
|
|
|
arg(:actor_id, non_null(:id))
|
2019-03-01 17:11:28 +01:00
|
|
|
|
|
|
|
resolve(&Resolvers.Group.leave_group/3)
|
|
|
|
end
|
2019-01-14 17:13:17 +01:00
|
|
|
end
|
|
|
|
end
|