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

@@ -5,7 +5,6 @@ defmodule Mobilizon.GraphQL.Schema.Actors.PersonType do
use Absinthe.Schema.Notation
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
import Mobilizon.GraphQL.Helpers.Error
alias Mobilizon.Events
alias Mobilizon.GraphQL.Resolvers.Person
@@ -136,7 +135,7 @@ defmodule Mobilizon.GraphQL.Schema.Actors.PersonType do
"The banner for the profile, either as an object or directly the ID of an existing Picture"
)
resolve(handle_errors(&Person.create_person/3))
resolve(&Person.create_person/3)
end
@desc "Update an identity"
@@ -157,14 +156,14 @@ defmodule Mobilizon.GraphQL.Schema.Actors.PersonType do
"The banner for the profile, either as an object or directly the ID of an existing Picture"
)
resolve(handle_errors(&Person.update_person/3))
resolve(&Person.update_person/3)
end
@desc "Delete an identity"
field :delete_person, :person do
arg(:id, non_null(:id))
resolve(handle_errors(&Person.delete_person/3))
resolve(&Person.delete_person/3)
end
@desc "Register a first profile on registration"
@@ -186,7 +185,7 @@ defmodule Mobilizon.GraphQL.Schema.Actors.PersonType do
"The banner for the profile, either as an object or directly the ID of an existing Picture"
)
resolve(handle_errors(&Person.register_person/3))
resolve(&Person.register_person/3)
end
end

View File

@@ -6,7 +6,6 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
use Absinthe.Schema.Notation
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
import Mobilizon.GraphQL.Helpers.Error
alias Mobilizon.{Actors, Addresses, Discussions}
alias Mobilizon.GraphQL.Resolvers.{Event, Picture, Tag}
@@ -311,7 +310,7 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
arg(:draft, :boolean, default_value: false)
arg(:contacts, list_of(:contact), default_value: [])
resolve(handle_errors(&Event.create_event/3))
resolve(&Event.create_event/3)
end
@desc "Update an event"
@@ -343,7 +342,7 @@ defmodule Mobilizon.GraphQL.Schema.EventType do
arg(:draft, :boolean)
arg(:contacts, list_of(:contact), default_value: [])
resolve(handle_errors(&Event.update_event/3))
resolve(&Event.update_event/3)
end
@desc "Delete an event"

View File

@@ -3,7 +3,7 @@ defmodule Mobilizon.GraphQL.Schema.PostType do
Schema representation for Posts
"""
use Absinthe.Schema.Notation
alias Mobilizon.GraphQL.Resolvers.{Post, Tag}
alias Mobilizon.GraphQL.Resolvers.{Picture, Post, Tag}
@desc "A post"
object :post do
@@ -24,6 +24,11 @@ defmodule Mobilizon.GraphQL.Schema.PostType do
resolve: &Tag.list_tags_for_post/3,
description: "The post's tags"
)
field(:picture, :picture,
description: "The event's picture",
resolve: &Picture.picture/3
)
end
object :paginated_post_list do
@@ -55,7 +60,7 @@ defmodule Mobilizon.GraphQL.Schema.PostType do
field :create_post, :post do
arg(:attributed_to_id, non_null(:id))
arg(:title, non_null(:string))
arg(:body, :string)
arg(:body, non_null(:string))
arg(:draft, :boolean, default_value: false)
arg(:visibility, :post_visibility)
arg(:publish_at, :datetime)
@@ -65,6 +70,11 @@ defmodule Mobilizon.GraphQL.Schema.PostType do
description: "The list of tags associated to the post"
)
arg(:picture, :picture_input,
description:
"The banner for the post, either as an object or directly the ID of an existing Picture"
)
resolve(&Post.create_post/3)
end
@@ -79,6 +89,11 @@ defmodule Mobilizon.GraphQL.Schema.PostType do
arg(:publish_at, :datetime)
arg(:tags, list_of(:string), description: "The list of tags associated to the post")
arg(:picture, :picture_input,
description:
"The banner for the post, either as an object or directly the ID of an existing Picture"
)
resolve(&Post.update_post/3)
end

View File

@@ -5,7 +5,6 @@ defmodule Mobilizon.GraphQL.Schema.UserType do
use Absinthe.Schema.Notation
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
import Mobilizon.GraphQL.Helpers.Error
alias Mobilizon.Events
alias Mobilizon.GraphQL.Resolvers.User
@@ -177,7 +176,7 @@ defmodule Mobilizon.GraphQL.Schema.UserType do
arg(:password, non_null(:string))
arg(:locale, :string)
resolve(handle_errors(&User.create_user/3))
resolve(&User.create_user/3)
end
@desc "Validate an user after registration"