Introduce registerPerson mutation

To register a profile from an unactivated user

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

👤 Fix Person interface use

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Change host function for data property

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-01-29 11:02:32 +01:00
parent c55ae19f84
commit 681653e035
13 changed files with 519 additions and 172 deletions

View File

@@ -6,6 +6,7 @@ defmodule MobilizonWeb.Schema.Actors.PersonType do
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
alias Mobilizon.Events
alias MobilizonWeb.Resolvers
import MobilizonWeb.Schema.Utils
@desc """
Represents a person identity
@@ -69,11 +70,24 @@ defmodule MobilizonWeb.Schema.Actors.PersonType do
@desc "Create a new person for user"
field :create_person, :person do
arg(:preferred_username, non_null(:string))
arg(:name, :string, description: "The displayed name for the new profile")
arg(:description, :string, description: "The summary for the new profile", default_value: "")
arg(:name, :string, description: "The displayed name for the new profile", default_value: "")
resolve(&Resolvers.Person.create_person/3)
arg(:summary, :string, description: "The summary for the new profile", default_value: "")
resolve(handle_errors(&Resolvers.Person.create_person/3))
end
@desc "Register a first profile on registration"
field :register_person, :person do
arg(:preferred_username, non_null(:string))
arg(:name, :string, description: "The displayed name for the new profile", default_value: "")
arg(:summary, :string, description: "The summary for the new profile", default_value: "")
arg(:email, non_null(:string), description: "The email from the user previously created")
resolve(handle_errors(&Resolvers.Person.register_person/3))
end
end
end

View File

@@ -12,8 +12,8 @@ defmodule MobilizonWeb.Schema.Utils do
# {:error, [email: {"has already been taken", []}]}
errors =
changeset.errors
|> Enum.map(fn {_key, {value, context}} ->
[message: "#{value}", details: context]
|> Enum.map(fn {key, {value, _context}} ->
[message: "#{value}", details: key]
end)
{:error, errors}