Fix lasts events published order on the homepage

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-03-16 19:08:00 +01:00
parent c8e39313ef
commit 4ff00e92b6
5 changed files with 42 additions and 5 deletions

View File

@@ -297,11 +297,29 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
field(:id, :string, description: "The Contact Actor ID")
end
@desc "Available event sort fields"
enum :event_order_by do
value(:begins_on, description: "Sort by the date the event starts")
value(:inserted_at, description: "Sort by the date the event was created")
value(:updated_at, description: "Sort by the date the event was updated")
end
object :event_queries do
@desc "Get all events"
field :events, :paginated_event_list do
arg(:page, :integer, default_value: 1, description: "The page in the paginated event list")
arg(:limit, :integer, default_value: 10, description: "The limit of events per page")
arg(:order_by, :event_order_by,
default_value: :begins_on,
description: "Order the list of events by field"
)
arg(:direction, :sort_direction,
default_value: :asc,
description: "Direction for the sort"
)
resolve(&Event.list_events/3)
end