2020-02-18 07:57:00 +00:00
|
|
|
defmodule Mobilizon.GraphQL.Schema.Todos.TodoListType do
|
|
|
|
@moduledoc """
|
|
|
|
Schema representation for Todo Lists
|
|
|
|
"""
|
|
|
|
use Absinthe.Schema.Notation
|
|
|
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
|
|
|
alias Mobilizon.Actors
|
|
|
|
alias Mobilizon.GraphQL.Resolvers.Todos
|
|
|
|
|
|
|
|
@desc "A todo list"
|
|
|
|
object :todo_list do
|
2023-03-17 17:10:59 +00:00
|
|
|
meta(:authorize, :user)
|
2020-02-18 07:57:00 +00:00
|
|
|
field(:id, :id, description: "The todo list's ID")
|
|
|
|
field(:title, :string, description: "The todo list's title")
|
|
|
|
|
|
|
|
field(:actor, :actor,
|
|
|
|
resolve: dataloader(Actors),
|
|
|
|
description: "The actor that owns this todo list"
|
|
|
|
)
|
|
|
|
|
2021-10-05 13:29:06 +00:00
|
|
|
field :todos, :paginated_todo_list do
|
|
|
|
arg(:page, :integer,
|
|
|
|
default_value: 1,
|
|
|
|
description: "The page in the paginated todos list"
|
|
|
|
)
|
|
|
|
|
|
|
|
arg(:limit, :integer,
|
|
|
|
default_value: 10,
|
|
|
|
description: "The limit of todos per page"
|
|
|
|
)
|
|
|
|
|
|
|
|
resolve(&Todos.find_todos_for_todo_list/3)
|
|
|
|
description("The todo-list's todos")
|
|
|
|
end
|
2020-02-18 07:57:00 +00:00
|
|
|
end
|
|
|
|
|
2020-11-19 16:06:28 +00:00
|
|
|
@desc """
|
|
|
|
A paginated list of todo-lists
|
|
|
|
"""
|
2020-02-18 07:57:00 +00:00
|
|
|
object :paginated_todo_list_list do
|
2023-03-17 17:10:59 +00:00
|
|
|
meta(:authorize, :user)
|
2020-02-18 07:57:00 +00:00
|
|
|
field(:elements, list_of(:todo_list), description: "A list of todo lists")
|
|
|
|
field(:total, :integer, description: "The total number of todo lists in the list")
|
|
|
|
end
|
|
|
|
|
|
|
|
object :todo_list_queries do
|
|
|
|
@desc "Get a todo list"
|
|
|
|
field :todo_list, :todo_list do
|
2020-11-19 16:06:28 +00:00
|
|
|
arg(:id, non_null(:id), description: "The todo-list ID")
|
2023-03-17 17:10:59 +00:00
|
|
|
middleware(Rajska.QueryAuthorization, permit: :user, scope: false)
|
2020-02-18 07:57:00 +00:00
|
|
|
resolve(&Todos.get_todo_list/3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
object :todo_list_mutations do
|
|
|
|
@desc "Create a todo list"
|
|
|
|
field :create_todo_list, :todo_list do
|
2020-11-19 16:06:28 +00:00
|
|
|
arg(:title, non_null(:string), description: "The todo list title")
|
|
|
|
arg(:group_id, non_null(:id), description: "The group ID")
|
2023-03-17 17:10:59 +00:00
|
|
|
middleware(Rajska.QueryAuthorization, permit: :user, scope: false)
|
2020-02-18 07:57:00 +00:00
|
|
|
resolve(&Todos.create_todo_list/3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|