Fix posts and rework graphql errors

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-10-01 15:07:15 +02:00
parent 92367a5f33
commit aced4d039b
69 changed files with 1795 additions and 999 deletions

View File

@@ -89,9 +89,12 @@ defmodule Mobilizon.Posts do
"""
@spec create_post(map) :: {:ok, Post.t()} | {:error, Ecto.Changeset.t()}
def create_post(attrs \\ %{}) do
%Post{}
|> Post.changeset(attrs)
|> Repo.insert()
with {:ok, %Post{} = post} <-
%Post{}
|> Post.changeset(attrs)
|> Repo.insert() do
{:ok, Repo.preload(post, @post_preloads)}
end
end
@doc """