2018-11-06 09:30:27 +00:00
|
|
|
defmodule MobilizonWeb.Schema do
|
2019-01-03 13:59:59 +00:00
|
|
|
@moduledoc """
|
|
|
|
GraphQL schema representation
|
|
|
|
"""
|
2018-11-06 09:30:27 +00:00
|
|
|
use Absinthe.Schema
|
|
|
|
|
|
|
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
|
|
|
alias Mobilizon.{Actors, Events}
|
2018-11-23 14:03:53 +00:00
|
|
|
alias Mobilizon.Actors.{Actor, Follower, Member}
|
|
|
|
alias Mobilizon.Events.{Event, Comment, Participant}
|
2018-11-06 09:30:27 +00:00
|
|
|
|
|
|
|
import_types(MobilizonWeb.Schema.Custom.UUID)
|
|
|
|
import_types(Absinthe.Type.Custom)
|
|
|
|
import_types(Absinthe.Plug.Types)
|
|
|
|
|
|
|
|
alias MobilizonWeb.Resolvers
|
|
|
|
|
2018-11-23 14:03:53 +00:00
|
|
|
@desc """
|
|
|
|
Represents a person identity
|
|
|
|
"""
|
|
|
|
object :person do
|
|
|
|
interfaces([:actor])
|
|
|
|
field(:user, :user, description: "The user this actor is associated to")
|
|
|
|
|
|
|
|
field(:member_of, list_of(:member), description: "The list of groups this person is member of")
|
|
|
|
|
|
|
|
field(:url, :string, description: "The ActivityPub actor's URL")
|
|
|
|
field(:type, :actor_type, description: "The type of Actor (Person, Group,…)")
|
|
|
|
field(:name, :string, description: "The actor's displayed name")
|
|
|
|
field(:domain, :string, description: "The actor's domain if (null if it's this instance)")
|
|
|
|
field(:local, :boolean, description: "If the actor is from this instance")
|
|
|
|
field(:summary, :string, description: "The actor's summary")
|
|
|
|
field(:preferred_username, :string, description: "The actor's preferred username")
|
|
|
|
field(:keys, :string, description: "The actors RSA Keys")
|
|
|
|
|
|
|
|
field(:manually_approves_followers, :boolean,
|
|
|
|
description: "Whether the actors manually approves followers"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:suspended, :boolean, description: "If the actor is suspended")
|
|
|
|
field(:avatar_url, :string, description: "The actor's avatar url")
|
|
|
|
field(:banner_url, :string, description: "The actor's banner url")
|
|
|
|
|
|
|
|
# These one should have a privacy setting
|
|
|
|
field(:following, list_of(:follower), description: "List of followings")
|
|
|
|
field(:followers, list_of(:follower), description: "List of followers")
|
|
|
|
field(:followersCount, :integer, description: "Number of followers for this actor")
|
|
|
|
field(:followingCount, :integer, description: "Number of actors following this actor")
|
|
|
|
|
|
|
|
# This one should have a privacy setting
|
|
|
|
field(:organized_events, list_of(:event),
|
|
|
|
resolve: dataloader(Events),
|
|
|
|
description: "A list of the events this actor has organized"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc """
|
|
|
|
Represents a group of actors
|
|
|
|
"""
|
|
|
|
object :group do
|
|
|
|
interfaces([:actor])
|
|
|
|
|
|
|
|
field(:url, :string, description: "The ActivityPub actor's URL")
|
|
|
|
field(:type, :actor_type, description: "The type of Actor (Person, Group,…)")
|
|
|
|
field(:name, :string, description: "The actor's displayed name")
|
|
|
|
field(:domain, :string, description: "The actor's domain if (null if it's this instance)")
|
|
|
|
field(:local, :boolean, description: "If the actor is from this instance")
|
|
|
|
field(:summary, :string, description: "The actor's summary")
|
|
|
|
field(:preferred_username, :string, description: "The actor's preferred username")
|
|
|
|
field(:keys, :string, description: "The actors RSA Keys")
|
|
|
|
|
|
|
|
field(:manually_approves_followers, :boolean,
|
|
|
|
description: "Whether the actors manually approves followers"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:suspended, :boolean, description: "If the actor is suspended")
|
|
|
|
field(:avatar_url, :string, description: "The actor's avatar url")
|
|
|
|
field(:banner_url, :string, description: "The actor's banner url")
|
|
|
|
|
|
|
|
# These one should have a privacy setting
|
|
|
|
field(:following, list_of(:follower), description: "List of followings")
|
|
|
|
field(:followers, list_of(:follower), description: "List of followers")
|
|
|
|
field(:followersCount, :integer, description: "Number of followers for this actor")
|
|
|
|
field(:followingCount, :integer, description: "Number of actors following this actor")
|
|
|
|
|
|
|
|
# This one should have a privacy setting
|
|
|
|
field(:organized_events, list_of(:event),
|
|
|
|
resolve: dataloader(Events),
|
|
|
|
description: "A list of the events this actor has organized"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:types, :group_type, description: "The type of group : Group, Community,…")
|
|
|
|
|
|
|
|
field(:openness, :openness,
|
|
|
|
description: "Whether the group is opened to all or has restricted access"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:members, non_null(list_of(:member)), description: "List of group members")
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc """
|
|
|
|
Describes how an actor is opened to follows
|
|
|
|
"""
|
|
|
|
enum :openness do
|
|
|
|
value(:invite_only, description: "The actor can only be followed by invitation")
|
|
|
|
|
|
|
|
value(:moderated, description: "The actor needs to accept the following before it's effective")
|
|
|
|
|
|
|
|
value(:open, description: "The actor is open to followings")
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc """
|
|
|
|
The types of Group that exist
|
|
|
|
"""
|
|
|
|
enum :group_type do
|
|
|
|
value(:group, description: "A private group of persons")
|
|
|
|
value(:community, description: "A public group of many actors")
|
|
|
|
end
|
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
@desc "An ActivityPub actor"
|
2018-11-23 14:03:53 +00:00
|
|
|
interface :actor do
|
2018-11-14 15:51:47 +00:00
|
|
|
field(:url, :string, description: "The ActivityPub actor's URL")
|
|
|
|
field(:type, :actor_type, description: "The type of Actor (Person, Group,…)")
|
|
|
|
field(:name, :string, description: "The actor's displayed name")
|
|
|
|
field(:domain, :string, description: "The actor's domain if (null if it's this instance)")
|
2018-11-23 14:03:53 +00:00
|
|
|
field(:local, :boolean, description: "If the actor is from this instance")
|
2018-11-14 15:51:47 +00:00
|
|
|
field(:summary, :string, description: "The actor's summary")
|
|
|
|
field(:preferred_username, :string, description: "The actor's preferred username")
|
|
|
|
field(:keys, :string, description: "The actors RSA Keys")
|
2018-11-15 16:35:47 +00:00
|
|
|
|
|
|
|
field(:manually_approves_followers, :boolean,
|
|
|
|
description: "Whether the actors manually approves followers"
|
|
|
|
)
|
|
|
|
|
2018-11-14 15:51:47 +00:00
|
|
|
field(:suspended, :boolean, description: "If the actor is suspended")
|
|
|
|
field(:avatar_url, :string, description: "The actor's avatar url")
|
|
|
|
field(:banner_url, :string, description: "The actor's banner url")
|
2018-11-23 14:03:53 +00:00
|
|
|
|
|
|
|
# These one should have a privacy setting
|
|
|
|
field(:following, list_of(:follower), description: "List of followings")
|
|
|
|
field(:followers, list_of(:follower), description: "List of followers")
|
|
|
|
field(:followersCount, :integer, description: "Number of followers for this actor")
|
|
|
|
field(:followingCount, :integer, description: "Number of actors following this actor")
|
|
|
|
|
|
|
|
# This one should have a privacy setting
|
2018-11-15 16:35:47 +00:00
|
|
|
field(:organized_events, list_of(:event),
|
|
|
|
resolve: dataloader(Events),
|
|
|
|
description: "A list of the events this actor has organized"
|
|
|
|
)
|
2018-11-06 09:30:27 +00:00
|
|
|
|
2018-11-23 14:03:53 +00:00
|
|
|
# This one is for the person itself **only**
|
|
|
|
# field(:feed, list_of(:event), description: "List of events the actor sees in his or her feed")
|
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
# field(:memberships, list_of(:member))
|
2018-11-23 14:03:53 +00:00
|
|
|
|
|
|
|
resolve_type(fn
|
|
|
|
%Actor{type: :Person}, _ ->
|
|
|
|
:person
|
|
|
|
|
|
|
|
%Actor{type: :Group}, _ ->
|
|
|
|
:group
|
|
|
|
end)
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
|
2018-11-14 15:51:47 +00:00
|
|
|
@desc "The list of types an actor can be"
|
2018-11-06 09:30:27 +00:00
|
|
|
enum :actor_type do
|
2018-11-14 15:51:47 +00:00
|
|
|
value(:Person, description: "An ActivityPub Person")
|
|
|
|
value(:Application, description: "An ActivityPub Application")
|
|
|
|
value(:Group, description: "An ActivityPub Group")
|
|
|
|
value(:Organization, description: "An ActivityPub Organization")
|
|
|
|
value(:Service, description: "An ActivityPub Service")
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "A local user of Mobilizon"
|
|
|
|
object :user do
|
2018-11-14 15:51:47 +00:00
|
|
|
field(:id, non_null(:id), description: "The user's ID")
|
|
|
|
field(:email, non_null(:string), description: "The user's email")
|
2018-11-23 14:03:53 +00:00
|
|
|
|
|
|
|
field(:profiles, non_null(list_of(:person)),
|
|
|
|
description: "The user's list of profiles (identities)"
|
2018-11-15 16:35:47 +00:00
|
|
|
)
|
|
|
|
|
2018-11-28 16:16:23 +00:00
|
|
|
field(:default_actor, non_null(:person), description: "The user's default actor")
|
2018-11-15 16:35:47 +00:00
|
|
|
|
|
|
|
field(:confirmed_at, :datetime,
|
|
|
|
description: "The datetime when the user was confirmed/activated"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:confirmation_sent_at, :datetime,
|
|
|
|
description: "The datetime the last activation/confirmation token was sent"
|
|
|
|
)
|
|
|
|
|
2018-11-14 15:51:47 +00:00
|
|
|
field(:confirmation_token, :string, description: "The account activation/confirmation token")
|
2018-11-15 16:35:47 +00:00
|
|
|
|
|
|
|
field(:reset_password_sent_at, :datetime,
|
|
|
|
description: "The datetime last reset password email was sent"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:reset_password_token, :string,
|
|
|
|
description: "The token sent when requesting password token"
|
|
|
|
)
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "A JWT and the associated user ID"
|
|
|
|
object :login do
|
2018-11-23 14:03:53 +00:00
|
|
|
field(:token, non_null(:string), description: "A JWT Token for this session")
|
|
|
|
field(:user, non_null(:user), description: "The user associated to this session")
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "An event"
|
|
|
|
object :event do
|
2018-11-23 14:03:53 +00:00
|
|
|
field(:uuid, :uuid, description: "The Event UUID")
|
|
|
|
field(:url, :string, description: "The ActivityPub Event URL")
|
|
|
|
field(:local, :boolean, description: "Whether the event is local or not")
|
|
|
|
field(:title, :string, description: "The event's title")
|
|
|
|
field(:description, :string, description: "The event's description")
|
|
|
|
field(:begins_on, :datetime, description: "Datetime for when the event begins")
|
|
|
|
field(:ends_on, :datetime, description: "Datetime for when the event ends")
|
|
|
|
field(:state, :integer, description: "State of the event")
|
|
|
|
field(:status, :integer, description: "Status of the event")
|
|
|
|
field(:public, :boolean, description: "Whether the event is public or not")
|
|
|
|
# TODO replace me with picture object
|
|
|
|
field(:thumbnail, :string, description: "A thumbnail picture for the event")
|
|
|
|
# TODO replace me with banner
|
|
|
|
field(:large_image, :string, description: "A large picture for the event")
|
|
|
|
field(:publish_at, :datetime, description: "When the event was published")
|
|
|
|
field(:address_type, :address_type, description: "The type of the event's address")
|
|
|
|
# TODO implement these properly with an interface
|
|
|
|
# field(:online_address, :string, description: "???")
|
|
|
|
# field(:phone, :string, description: "")
|
|
|
|
|
|
|
|
field(:organizer_actor, :person,
|
|
|
|
resolve: dataloader(Actors),
|
|
|
|
description: "The event's organizer (as a person)"
|
|
|
|
)
|
2018-11-06 09:30:27 +00:00
|
|
|
|
2018-11-23 14:03:53 +00:00
|
|
|
field(:attributed_to, :actor, description: "Who the event is attributed to (often a group)")
|
2018-11-06 09:30:27 +00:00
|
|
|
# field(:tags, list_of(:tag))
|
2018-11-23 14:03:53 +00:00
|
|
|
field(:category, :category, description: "The event's category")
|
2018-11-06 09:30:27 +00:00
|
|
|
|
|
|
|
field(:participants, list_of(:participant),
|
2018-11-23 14:03:53 +00:00
|
|
|
resolve: &Resolvers.Event.list_participants_for_event/3,
|
|
|
|
description: "The event's participants"
|
2018-11-06 09:30:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# field(:tracks, list_of(:track))
|
|
|
|
# field(:sessions, list_of(:session))
|
|
|
|
# field(:physical_address, :address)
|
|
|
|
|
2018-11-23 14:03:53 +00:00
|
|
|
field(:updated_at, :datetime, description: "When the event was last updated")
|
|
|
|
field(:created_at, :datetime, description: "When the event was created")
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "A comment"
|
|
|
|
object :comment do
|
|
|
|
field(:uuid, :uuid)
|
|
|
|
field(:url, :string)
|
|
|
|
field(:local, :boolean)
|
2018-12-14 16:41:55 +00:00
|
|
|
field(:text, :string)
|
2018-11-23 14:03:53 +00:00
|
|
|
field(:primaryLanguage, :string)
|
|
|
|
field(:replies, list_of(:comment))
|
|
|
|
field(:threadLanguages, non_null(list_of(:string)))
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Represents a participant to an event"
|
|
|
|
object :participant do
|
2018-11-23 14:03:53 +00:00
|
|
|
field(:event, :event,
|
|
|
|
resolve: dataloader(Events),
|
|
|
|
description: "The event which the actor participates in"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:actor, :actor, description: "The actor that participates to the event")
|
|
|
|
field(:role, :integer, description: "The role of this actor at this event")
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
|
2018-11-14 15:51:47 +00:00
|
|
|
@desc "The list of types an address can be"
|
2018-11-06 09:30:27 +00:00
|
|
|
enum :address_type do
|
2018-11-23 14:03:53 +00:00
|
|
|
value(:physical, description: "The address is physical, like a postal address")
|
|
|
|
value(:url, description: "The address is on the Web, like an URL")
|
|
|
|
value(:phone, description: "The address is a phone number for a conference")
|
|
|
|
value(:other, description: "The address is something else")
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "A category"
|
|
|
|
object :category do
|
2018-11-23 14:03:53 +00:00
|
|
|
field(:id, :id, description: "The category's ID")
|
|
|
|
field(:description, :string, description: "The category's description")
|
|
|
|
field(:picture, :picture, description: "The category's picture")
|
|
|
|
field(:title, :string, description: "The category's title")
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "A picture"
|
|
|
|
object :picture do
|
2018-11-23 14:03:53 +00:00
|
|
|
field(:url, :string, description: "The URL for this picture")
|
|
|
|
field(:url_thumbnail, :string, description: "The URL for this picture's thumbnail")
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc """
|
|
|
|
Represents a notification for an user
|
|
|
|
"""
|
|
|
|
object :notification do
|
|
|
|
field(:id, :integer, description: "The notification ID")
|
|
|
|
field(:user, :user, description: "The user to transmit the notification to")
|
|
|
|
field(:actor, :actor, description: "The notification target profile")
|
|
|
|
|
|
|
|
field(:activity_type, :integer,
|
|
|
|
description:
|
|
|
|
"Whether the notification is about a follow, group join, event change or comment"
|
|
|
|
)
|
|
|
|
|
|
|
|
field(:target_object, :object, description: "The object responsible for the notification")
|
|
|
|
field(:summary, :string, description: "Text inside the notification")
|
|
|
|
field(:seen, :boolean, description: "Whether or not the notification was seen by the user")
|
|
|
|
field(:published, :datetime, description: "Datetime when the notification was published")
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc """
|
|
|
|
Represents a member of a group
|
|
|
|
"""
|
|
|
|
object :member do
|
|
|
|
field(:parent, :group, description: "Of which the profile is member")
|
|
|
|
field(:person, :person, description: "Which profile is member of")
|
|
|
|
field(:role, :integer, description: "The role of this membership")
|
|
|
|
field(:approved, :boolean, description: "Whether this membership has been approved")
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc """
|
2018-12-14 10:23:36 +00:00
|
|
|
Represents an actor's follower
|
2018-11-23 14:03:53 +00:00
|
|
|
"""
|
|
|
|
object :follower do
|
|
|
|
field(:target_actor, :actor, description: "What or who the profile follows")
|
|
|
|
field(:actor, :actor, description: "Which profile follows")
|
|
|
|
|
|
|
|
field(:approved, :boolean,
|
|
|
|
description: "Whether the follow has been approved by the target actor"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
union :object do
|
|
|
|
types([:event, :person, :group, :comment, :follower, :member, :participant])
|
|
|
|
|
|
|
|
resolve_type(fn
|
|
|
|
%Actor{type: :Person}, _ ->
|
|
|
|
:person
|
|
|
|
|
|
|
|
%Actor{type: :Group}, _ ->
|
|
|
|
:group
|
|
|
|
|
|
|
|
%Event{}, _ ->
|
|
|
|
:event
|
|
|
|
|
|
|
|
%Comment{}, _ ->
|
|
|
|
:comment
|
|
|
|
|
|
|
|
%Follower{}, _ ->
|
|
|
|
:follower
|
|
|
|
|
|
|
|
%Member{}, _ ->
|
|
|
|
:member
|
|
|
|
|
|
|
|
%Participant{}, _ ->
|
|
|
|
:participant
|
|
|
|
end)
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "A search result"
|
|
|
|
union :search_result do
|
2018-11-23 14:03:53 +00:00
|
|
|
types([:event, :person, :group])
|
2018-11-06 09:30:27 +00:00
|
|
|
|
|
|
|
resolve_type(fn
|
2018-11-23 14:03:53 +00:00
|
|
|
%Actor{type: :Person}, _ ->
|
|
|
|
:person
|
|
|
|
|
|
|
|
%Actor{type: :Group}, _ ->
|
|
|
|
:group
|
2018-11-06 09:30:27 +00:00
|
|
|
|
|
|
|
%Event{}, _ ->
|
|
|
|
:event
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
def context(ctx) do
|
|
|
|
loader =
|
|
|
|
Dataloader.new()
|
|
|
|
|> Dataloader.add_source(Actors, Actors.data())
|
|
|
|
|> Dataloader.add_source(Events, Events.data())
|
|
|
|
|
|
|
|
Map.put(ctx, :loader, loader)
|
|
|
|
end
|
|
|
|
|
|
|
|
def plugins do
|
|
|
|
[Absinthe.Middleware.Dataloader | Absinthe.Plugin.defaults()]
|
|
|
|
end
|
|
|
|
|
2018-11-23 14:03:53 +00:00
|
|
|
@desc """
|
|
|
|
Root Query
|
|
|
|
"""
|
2018-11-06 09:30:27 +00:00
|
|
|
query do
|
|
|
|
@desc "Get all events"
|
|
|
|
field :events, list_of(:event) do
|
2018-12-14 10:23:36 +00:00
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
2018-11-06 09:30:27 +00:00
|
|
|
resolve(&Resolvers.Event.list_events/3)
|
|
|
|
end
|
|
|
|
|
2018-12-03 10:58:57 +00:00
|
|
|
@desc "Get all groups"
|
|
|
|
field :groups, list_of(:group) do
|
2018-12-14 10:23:36 +00:00
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
2018-12-03 10:58:57 +00:00
|
|
|
resolve(&Resolvers.Group.list_groups/3)
|
|
|
|
end
|
|
|
|
|
2018-11-23 14:03:53 +00:00
|
|
|
@desc "Search through events, persons and groups"
|
2018-11-06 09:30:27 +00:00
|
|
|
field :search, list_of(:search_result) do
|
|
|
|
arg(:search, non_null(:string))
|
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
|
|
|
resolve(&Resolvers.Event.search_events_and_actors/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Get an event by uuid"
|
|
|
|
field :event, :event do
|
|
|
|
arg(:uuid, non_null(:uuid))
|
|
|
|
resolve(&Resolvers.Event.find_event/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Get all participants for an event uuid"
|
|
|
|
field :participants, list_of(:participant) do
|
|
|
|
arg(:uuid, non_null(:uuid))
|
2018-12-14 10:23:36 +00:00
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
2018-11-06 09:30:27 +00:00
|
|
|
resolve(&Resolvers.Event.list_participants_for_event/3)
|
|
|
|
end
|
|
|
|
|
2018-12-03 10:58:57 +00:00
|
|
|
@desc "Get a group by it's preferred username"
|
|
|
|
field :group, :group do
|
|
|
|
arg(:preferred_username, non_null(:string))
|
|
|
|
resolve(&Resolvers.Group.find_group/3)
|
|
|
|
end
|
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
@desc "Get an user"
|
|
|
|
field :user, :user do
|
|
|
|
arg(:id, non_null(:id))
|
|
|
|
resolve(&Resolvers.User.find_user/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Get the current user"
|
|
|
|
field :logged_user, :user do
|
|
|
|
resolve(&Resolvers.User.get_current_user/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Get the current actor for the logged-in user"
|
2018-11-23 14:03:53 +00:00
|
|
|
field :logged_person, :person do
|
2018-12-03 10:58:57 +00:00
|
|
|
resolve(&Resolvers.Person.get_current_person/3)
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
|
2018-12-03 10:58:57 +00:00
|
|
|
@desc "Get a person by it's preferred username"
|
2018-11-23 14:03:53 +00:00
|
|
|
field :person, :person do
|
2018-11-06 09:30:27 +00:00
|
|
|
arg(:preferred_username, non_null(:string))
|
2018-12-03 10:58:57 +00:00
|
|
|
resolve(&Resolvers.Person.find_person/3)
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
|
2018-11-14 15:51:47 +00:00
|
|
|
@desc "Get the list of categories"
|
2018-11-23 14:03:53 +00:00
|
|
|
field :categories, non_null(list_of(:category)) do
|
2018-12-14 10:23:36 +00:00
|
|
|
arg(:page, :integer, default_value: 1)
|
|
|
|
arg(:limit, :integer, default_value: 10)
|
2018-11-06 09:30:27 +00:00
|
|
|
resolve(&Resolvers.Category.list_categories/3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-23 14:03:53 +00:00
|
|
|
@desc """
|
|
|
|
Root Mutation
|
|
|
|
"""
|
2018-11-06 09:30:27 +00:00
|
|
|
mutation do
|
|
|
|
@desc "Create an event"
|
|
|
|
field :create_event, type: :event do
|
|
|
|
arg(:title, non_null(:string))
|
|
|
|
arg(:description, non_null(:string))
|
|
|
|
arg(:begins_on, non_null(:datetime))
|
|
|
|
arg(:ends_on, :datetime)
|
|
|
|
arg(:state, :integer)
|
|
|
|
arg(:status, :integer)
|
|
|
|
arg(:public, :boolean)
|
|
|
|
arg(:thumbnail, :string)
|
|
|
|
arg(:large_image, :string)
|
|
|
|
arg(:publish_at, :datetime)
|
|
|
|
arg(:address_type, non_null(:address_type))
|
|
|
|
arg(:online_address, :string)
|
|
|
|
arg(:phone, :string)
|
2018-12-14 16:41:55 +00:00
|
|
|
arg(:organizer_actor_username, non_null(:string))
|
|
|
|
arg(:category, non_null(:string))
|
2018-11-06 09:30:27 +00:00
|
|
|
|
|
|
|
resolve(&Resolvers.Event.create_event/3)
|
|
|
|
end
|
|
|
|
|
2018-12-14 16:41:55 +00:00
|
|
|
@desc "Create a comment"
|
|
|
|
field :create_comment, type: :comment do
|
|
|
|
arg(:text, non_null(:string))
|
|
|
|
arg(:actor_username, non_null(:string))
|
|
|
|
|
|
|
|
resolve(&Resolvers.Comment.create_comment/3)
|
|
|
|
end
|
|
|
|
|
2018-11-14 15:51:47 +00:00
|
|
|
@desc "Create a category with a title, description and picture"
|
2018-11-06 09:30:27 +00:00
|
|
|
field :create_category, type: :category do
|
|
|
|
arg(:title, non_null(:string))
|
|
|
|
arg(:description, non_null(:string))
|
|
|
|
arg(:picture, non_null(:upload))
|
|
|
|
resolve(&Resolvers.Category.create_category/3)
|
|
|
|
end
|
|
|
|
|
2018-11-29 16:43:22 +00:00
|
|
|
@desc "Create an user"
|
|
|
|
field :create_user, type: :user do
|
2018-11-06 09:30:27 +00:00
|
|
|
arg(:email, non_null(:string))
|
|
|
|
arg(:password, non_null(:string))
|
|
|
|
arg(:username, non_null(:string))
|
|
|
|
|
|
|
|
resolve(&Resolvers.User.create_user_actor/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Validate an user after registration"
|
|
|
|
field :validate_user, type: :login do
|
|
|
|
arg(:token, non_null(:string))
|
|
|
|
resolve(&Resolvers.User.validate_user/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Resend registration confirmation token"
|
|
|
|
field :resend_confirmation_email, type: :string do
|
|
|
|
arg(:email, non_null(:string))
|
|
|
|
arg(:locale, :string, default_value: "en")
|
|
|
|
resolve(&Resolvers.User.resend_confirmation_email/3)
|
|
|
|
end
|
|
|
|
|
2018-11-14 15:51:47 +00:00
|
|
|
@desc "Send a link through email to reset user password"
|
2018-11-06 09:30:27 +00:00
|
|
|
field :send_reset_password, type: :string do
|
|
|
|
arg(:email, non_null(:string))
|
|
|
|
arg(:locale, :string, default_value: "en")
|
|
|
|
resolve(&Resolvers.User.send_reset_password/3)
|
|
|
|
end
|
|
|
|
|
2018-11-14 15:51:47 +00:00
|
|
|
@desc "Reset user password"
|
2018-11-06 09:30:27 +00:00
|
|
|
field :reset_password, type: :login do
|
|
|
|
arg(:token, non_null(:string))
|
|
|
|
arg(:password, non_null(:string))
|
|
|
|
arg(:locale, :string, default_value: "en")
|
|
|
|
resolve(&Resolvers.User.reset_password/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Login an user"
|
|
|
|
field :login, :login do
|
|
|
|
arg(:email, non_null(:string))
|
|
|
|
arg(:password, non_null(:string))
|
|
|
|
resolve(&Resolvers.User.login_user/3)
|
|
|
|
end
|
|
|
|
|
|
|
|
@desc "Change default actor for user"
|
|
|
|
field :change_default_actor, :user do
|
|
|
|
arg(:preferred_username, non_null(:string))
|
|
|
|
resolve(&Resolvers.User.change_default_actor/3)
|
|
|
|
end
|
|
|
|
|
2018-12-03 10:58:57 +00:00
|
|
|
@desc "Create a group"
|
|
|
|
field :create_group, :group do
|
|
|
|
arg(:preferred_username, non_null(:string), description: "The name for the group")
|
|
|
|
arg(:name, :string, description: "The displayed name for the group")
|
2018-12-14 16:41:55 +00:00
|
|
|
arg(:description, :string, description: "The summary for the group", default_value: "")
|
2018-12-03 10:58:57 +00:00
|
|
|
|
2018-12-14 16:41:55 +00:00
|
|
|
arg(:admin_actor_username, :string,
|
2018-12-03 10:58:57 +00:00
|
|
|
description: "The actor's username which will be the admin (otherwise user's default one)"
|
|
|
|
)
|
2018-12-03 11:08:18 +00:00
|
|
|
|
2018-12-03 10:58:57 +00:00
|
|
|
resolve(&Resolvers.Group.create_group/3)
|
|
|
|
end
|
|
|
|
|
2018-11-12 17:17:53 +00:00
|
|
|
# @desc "Upload a picture"
|
|
|
|
# field :upload_picture, :picture do
|
|
|
|
# arg(:file, non_null(:upload))
|
|
|
|
# resolve(&Resolvers.Upload.upload_picture/3)
|
|
|
|
# end
|
2018-11-06 09:30:27 +00:00
|
|
|
end
|
|
|
|
end
|