mobilizon.chapril.org-mobil.../lib/graphql/schema/events/participant.ex

77 lines
1.8 KiB
Elixir
Raw Normal View History

2020-01-26 20:34:25 +01:00
defmodule Mobilizon.GraphQL.Schema.Events.ParticipantType do
@moduledoc """
2019-09-22 16:26:23 +02:00
Schema representation for Participant.
"""
2019-09-22 16:26:23 +02:00
use Absinthe.Schema.Notation
2019-09-22 16:26:23 +02:00
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
2019-09-22 16:26:23 +02:00
alias Mobilizon.{Actors, Events}
2020-01-26 20:34:25 +01:00
alias Mobilizon.GraphQL.Resolvers.Event
@desc "Represents a participant to an event"
object :participant do
field(:id, :id, description: "The participation ID")
2019-02-01 15:38:35 +01:00
field(
:event,
:event,
resolve: dataloader(Events),
description: "The event which the actor participates in"
)
2019-02-01 15:38:35 +01:00
field(
:actor,
:actor,
resolve: dataloader(Actors),
description: "The actor that participates to the event"
)
field(:role, :participant_role_enum, description: "The role of this actor at this event")
end
enum :participant_role_enum do
value(:not_approved)
value(:participant)
value(:moderator)
value(:administrator)
value(:creator)
value(:rejected)
end
2019-02-01 15:38:35 +01:00
@desc "Represents a deleted participant"
object :deleted_participant do
field(:id, :id)
2019-02-01 15:38:35 +01:00
field(:event, :deleted_object)
field(:actor, :deleted_object)
end
object :participant_mutations do
@desc "Join an event"
field :join_event, :participant do
arg(:event_id, non_null(:id))
arg(:actor_id, non_null(:id))
2019-02-01 15:38:35 +01:00
2020-01-26 20:34:25 +01:00
resolve(&Event.actor_join_event/3)
2019-02-01 15:38:35 +01:00
end
@desc "Leave an event"
field :leave_event, :deleted_participant do
arg(:event_id, non_null(:id))
arg(:actor_id, non_null(:id))
2019-02-01 15:38:35 +01:00
2020-01-26 20:34:25 +01:00
resolve(&Event.actor_leave_event/3)
2019-02-01 15:38:35 +01:00
end
@desc "Accept a participation"
field :update_participation, :participant do
arg(:id, non_null(:id))
arg(:role, non_null(:participant_role_enum))
arg(:moderator_actor_id, non_null(:id))
2020-01-26 20:34:25 +01:00
resolve(&Event.update_participation/3)
end
2019-02-01 15:38:35 +01:00
end
end