Allow tag relations + bump ecto deps

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-02-14 14:19:55 +01:00
parent 4caa998ae0
commit 256d50e855
37 changed files with 515 additions and 132 deletions

View File

@@ -8,6 +8,7 @@ defmodule MobilizonWeb.Schema.EventType do
import_types(MobilizonWeb.Schema.AddressType)
import_types(MobilizonWeb.Schema.Events.ParticipantType)
import_types(MobilizonWeb.Schema.Events.CategoryType)
import_types(MobilizonWeb.Schema.TagType)
alias MobilizonWeb.Resolvers
@desc "An event"
@@ -37,7 +38,12 @@ defmodule MobilizonWeb.Schema.EventType do
)
field(:attributed_to, :actor, description: "Who the event is attributed to (often a group)")
# field(:tags, list_of(:tag))
field(:tags, list_of(:tag),
resolve: &MobilizonWeb.Resolvers.Tag.list_tags_for_event/3,
description: "The event's tags"
)
field(:category, :category, description: "The event's category")
field(:participants, list_of(:participant),

View File

@@ -0,0 +1,30 @@
defmodule MobilizonWeb.Schema.TagType do
@moduledoc """
Schema representation for Tags
"""
use Absinthe.Schema.Notation
alias MobilizonWeb.Resolvers
@desc "A tag"
object :tag do
field(:id, :id, description: "The tag's ID")
field(:slug, :string, description: "The tags's slug")
field(:title, :string, description: "The tag's title")
field(
:related,
list_of(:tag),
resolve: &Resolvers.Tag.get_related_tags/3,
description: "Related tags to this tag"
)
end
object :tag_queries do
@desc "Get the list of tags"
field :tags, non_null(list_of(:tag)) do
arg(:page, :integer, default_value: 1)
arg(:limit, :integer, default_value: 10)
resolve(&Resolvers.Tag.list_tags/3)
end
end
end