Improve GraphQL documentation and cleanup API

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-11-19 17:06:28 +01:00
parent e8a3b6aa94
commit 3eacbb2ca3
87 changed files with 6542 additions and 6314 deletions

View File

@@ -22,18 +22,21 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
field(:inserted_at, :datetime, description: "The time when the action was performed")
end
@desc """
The different types of action log actions
"""
enum :action_log_action do
value(:report_update_closed)
value(:report_update_opened)
value(:report_update_resolved)
value(:note_creation)
value(:note_deletion)
value(:event_deletion)
value(:comment_deletion)
value(:event_update)
value(:actor_suspension)
value(:actor_unsuspension)
value(:user_deletion)
value(:report_update_closed, description: "The report was closed")
value(:report_update_opened, description: "The report was opened")
value(:report_update_resolved, description: "The report was resolved")
value(:note_creation, description: "A note was created on a report")
value(:note_deletion, description: "A note was deleted on a report")
value(:event_deletion, description: "An event was deleted")
value(:comment_deletion, description: "A comment was deleted")
value(:event_update, description: "An event was updated")
value(:actor_suspension, description: "An actor was suspended")
value(:actor_unsuspension, description: "An actor was unsuspended")
value(:user_deletion, description: "An user was deleted")
end
@desc "The objects that can be in an action log"
@@ -64,11 +67,17 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
end)
end
@desc """
Language information
"""
object :language do
field(:code, :string, description: "The iso-639-3 language code")
field(:name, :string, description: "The language name")
end
@desc """
Dashboard information
"""
object :dashboard do
field(:last_public_event_published, :event, description: "Last public event published")
field(:last_group_created, :group, description: "Last public group created")
@@ -85,33 +94,52 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
)
end
@desc """
Admin settings
"""
object :admin_settings do
field(:instance_name, :string)
field(:instance_description, :string)
field(:instance_long_description, :string)
field(:instance_slogan, :string)
field(:contact, :string)
field(:instance_terms, :string)
field(:instance_terms_type, :instance_terms_type)
field(:instance_terms_url, :string)
field(:instance_privacy_policy, :string)
field(:instance_privacy_policy_type, :instance_privacy_type)
field(:instance_privacy_policy_url, :string)
field(:instance_rules, :string)
field(:registrations_open, :boolean)
field(:instance_languages, list_of(:string))
field(:instance_name, :string, description: "The instance's name")
field(:instance_description, :string, description: "The instance's description")
field(:instance_long_description, :string, description: "The instance's long description")
field(:instance_slogan, :string, description: "The instance's slogan")
field(:contact, :string, description: "The instance's contact details")
field(:instance_terms, :string, description: "The instance's terms body text")
field(:instance_terms_type, :instance_terms_type, description: "The instance's terms type")
field(:instance_terms_url, :string, description: "The instance's terms URL")
field(:instance_privacy_policy, :string,
description: "The instance's privacy policy body text"
)
field(:instance_privacy_policy_type, :instance_privacy_type,
description: "The instance's privacy policy type"
)
field(:instance_privacy_policy_url, :string, description: "The instance's privacy policy URL")
field(:instance_rules, :string, description: "The instance's rules")
field(:registrations_open, :boolean, description: "Whether the registrations are opened")
field(:instance_languages, list_of(:string), description: "The instance's languages")
end
@desc "The acceptable values for the instance's terms type"
enum :instance_terms_type do
value(:url, as: "URL")
value(:default, as: "DEFAULT")
value(:custom, as: "CUSTOM")
value(:url, as: "URL", description: "An URL. Users will be redirected to this URL.")
value(:default, as: "DEFAULT", description: "Terms will be set to Mobilizon's default terms")
value(:custom, as: "CUSTOM", description: "Custom terms text")
end
@desc """
The acceptable values for the instance privacy policy type
"""
enum :instance_privacy_type do
value(:url, as: "URL")
value(:default, as: "DEFAULT")
value(:custom, as: "CUSTOM")
value(:url, as: "URL", description: "An URL. Users will be redirected to this URL.")
value(:default,
as: "DEFAULT",
description: "Privacy policy will be set to Mobilizon's default privacy policy"
)
value(:custom, as: "CUSTOM", description: "Custom privacy policy text")
end
object :admin_queries do
@@ -122,30 +150,69 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
resolve(&Admin.list_action_logs/3)
end
@desc """
List the instance's supported languages
"""
field :languages, type: list_of(:language) do
arg(:codes, list_of(:string))
arg(:codes, list_of(:string),
description:
"The user's locale. The list of languages will be translated with this locale"
)
resolve(&Admin.get_list_of_languages/3)
end
@desc """
Get dashboard information
"""
field :dashboard, type: :dashboard do
resolve(&Admin.get_dashboard/3)
end
@desc """
Get admin settings
"""
field :admin_settings, type: :admin_settings do
resolve(&Admin.get_settings/3)
end
@desc """
List the relay followers
"""
field :relay_followers, type: :paginated_follower_list do
arg(:page, :integer, default_value: 1)
arg(:limit, :integer, default_value: 10)
arg(:page, :integer,
default_value: 1,
description: "The page in the paginated relay followers list"
)
arg(:limit, :integer,
default_value: 10,
description: "The limit of relay followers per page"
)
resolve(&Admin.list_relay_followers/3)
end
@desc """
List the relay followings
"""
field :relay_followings, type: :paginated_follower_list do
arg(:page, :integer, default_value: 1)
arg(:limit, :integer, default_value: 10)
arg(:order_by, :string, default_value: :updated_at)
arg(:direction, :string, default_value: :desc)
arg(:page, :integer,
default_value: 1,
description: "The page in the paginated relay followings list"
)
arg(:limit, :integer,
default_value: 10,
description: "The limit of relay followings per page"
)
arg(:order_by, :string,
default_value: :updated_at,
description: "The field to order by the list"
)
arg(:direction, :string, default_value: :desc, description: "The sorting direction")
resolve(&Admin.list_relay_followings/3)
end
end
@@ -153,47 +220,57 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
object :admin_mutations do
@desc "Add a relay subscription"
field :add_relay, type: :follower do
arg(:address, non_null(:string))
arg(:address, non_null(:string), description: "The relay hostname to add")
resolve(&Admin.create_relay/3)
end
@desc "Delete a relay subscription"
field :remove_relay, type: :follower do
arg(:address, non_null(:string))
arg(:address, non_null(:string), description: "The relay hostname to delete")
resolve(&Admin.remove_relay/3)
end
@desc "Accept a relay subscription"
field :accept_relay, type: :follower do
arg(:address, non_null(:string))
arg(:address, non_null(:string), description: "The accepted relay hostname")
resolve(&Admin.accept_subscription/3)
end
@desc "Reject a relay subscription"
field :reject_relay, type: :follower do
arg(:address, non_null(:string))
arg(:address, non_null(:string), description: "The rejected relay hostname")
resolve(&Admin.reject_subscription/3)
end
@desc """
Save admin settings
"""
field :save_admin_settings, type: :admin_settings do
arg(:instance_name, :string)
arg(:instance_description, :string)
arg(:instance_long_description, :string)
arg(:instance_slogan, :string)
arg(:contact, :string)
arg(:instance_terms, :string)
arg(:instance_terms_type, :instance_terms_type)
arg(:instance_terms_url, :string)
arg(:instance_privacy_policy, :string)
arg(:instance_privacy_policy_type, :instance_privacy_type)
arg(:instance_privacy_policy_url, :string)
arg(:instance_rules, :string)
arg(:registrations_open, :boolean)
arg(:instance_languages, list_of(:string))
arg(:instance_name, :string, description: "The instance's name")
arg(:instance_description, :string, description: "The instance's description")
arg(:instance_long_description, :string, description: "The instance's long description")
arg(:instance_slogan, :string, description: "The instance's slogan")
arg(:contact, :string, description: "The instance's contact details")
arg(:instance_terms, :string, description: "The instance's terms body text")
arg(:instance_terms_type, :instance_terms_type, description: "The instance's terms type")
arg(:instance_terms_url, :string, description: "The instance's terms URL")
arg(:instance_privacy_policy, :string,
description: "The instance's privacy policy body text"
)
arg(:instance_privacy_policy_type, :instance_privacy_type,
description: "The instance's privacy policy type"
)
arg(:instance_privacy_policy_url, :string, description: "The instance's privacy policy URL")
arg(:instance_rules, :string, description: "The instance's rules")
arg(:registrations_open, :boolean, description: "Whether the registrations are opened")
arg(:instance_languages, list_of(:string), description: "The instance's languages")
resolve(&Admin.save_settings/3)
end