Allow to register custom categories
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -4,6 +4,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Config do
|
||||
"""
|
||||
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Events.Categories
|
||||
|
||||
@doc """
|
||||
Gets config.
|
||||
@@ -57,6 +58,17 @@ defmodule Mobilizon.GraphQL.Resolvers.Config do
|
||||
{:ok, %{body_html: body_html, type: type, url: url}}
|
||||
end
|
||||
|
||||
@spec event_categories(any(), map(), Absinthe.Resolution.t()) :: {:ok, [map()]}
|
||||
def event_categories(_parent, _args, _resolution) do
|
||||
categories =
|
||||
Categories.list()
|
||||
|> Enum.map(fn %{id: id, label: label} ->
|
||||
%{id: id |> to_string |> String.upcase(), label: label}
|
||||
end)
|
||||
|
||||
{:ok, categories}
|
||||
end
|
||||
|
||||
@spec config_cache :: map()
|
||||
defp config_cache do
|
||||
case Cachex.fetch(:config, "full_config", fn _key ->
|
||||
|
||||
Reference in New Issue
Block a user