mobilizon/lib/graphql/schema/collections/resource.ex

51 lines
1.5 KiB
Elixir

defmodule Mobilizon.GraphQL.Schema.Collections.ResourceType do
@moduledoc """
Schema representation for Resources
"""
use Absinthe.Schema.Notation
alias Mobilizon.GraphQL.Resolvers.Collections
@desc "A resource"
object :resource do
field(:id, :id, description: "The resource's ID")
field(:title, :string, description: "The resource's title")
field(:summary, :string, description: "The resource's summary")
field(:url, :string, description: "The resource's URL")
end
object :paginated_resource_list do
field(:elements, list_of(:resource), description: "A list of resources")
field(:total, :integer, description: "The total number of resources in the list")
end
object :resource_mutations do
@desc "Create a resource"
field :create_resource, :resource do
arg(:collection_id, non_null(:id))
arg(:actor_id, non_null(:id))
arg(:title, non_null(:string))
arg(:summary, non_null(:string))
arg(:url, non_null(:string))
resolve(&Collections.create_resource/3)
end
@desc "Update a resource"
field :update_resource, :resource do
arg(:id, non_null(:id))
arg(:actor_id, non_null(:id))
arg(:title, non_null(:string))
arg(:summary, non_null(:string))
arg(:url, non_null(:string))
resolve(&Collections.update_resource/3)
end
@desc "Delete a resource"
field :delete_resource, :deleted_object do
arg(:id, non_null(:id))
resolve(&Collections.delete_resource/3)
end
end
end