Allow to register custom categories

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2022-03-28 20:02:43 +02:00
parent f5bdedf789
commit 368911b58e
40 changed files with 4587 additions and 725 deletions

View File

@@ -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 ->