2020-01-26 19:34:25 +00:00
|
|
|
defmodule Mobilizon.GraphQL.Schema.PictureType do
|
2019-05-22 12:12:11 +00:00
|
|
|
@moduledoc """
|
|
|
|
Schema representation for Pictures
|
|
|
|
"""
|
|
|
|
use Absinthe.Schema.Notation
|
2020-01-26 19:34:25 +00:00
|
|
|
|
|
|
|
alias Mobilizon.GraphQL.Resolvers.Picture
|
2019-05-22 12:12:11 +00:00
|
|
|
|
|
|
|
@desc "A picture"
|
|
|
|
object :picture do
|
|
|
|
field(:id, :id, description: "The picture's ID")
|
|
|
|
field(:alt, :string, description: "The picture's alternative text")
|
|
|
|
field(:name, :string, description: "The picture's name")
|
|
|
|
field(:url, :string, description: "The picture's full URL")
|
2019-06-03 15:13:47 +00:00
|
|
|
field(:content_type, :string, description: "The picture's detected content type")
|
|
|
|
field(:size, :integer, description: "The picture's size")
|
2019-05-22 12:12:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "An attached picture or a link to a picture"
|
|
|
|
input_object :picture_input do
|
|
|
|
# Either a full picture object
|
|
|
|
field(:picture, :picture_input_object)
|
|
|
|
# Or directly the ID of an existing picture
|
2019-10-14 09:41:57 +00:00
|
|
|
field(:picture_id, :id)
|
2019-05-22 12:12:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "An attached picture"
|
|
|
|
input_object :picture_input_object do
|
|
|
|
field(:name, non_null(:string))
|
|
|
|
field(:alt, :string)
|
|
|
|
field(:file, non_null(:upload))
|
2019-05-31 15:58:03 +00:00
|
|
|
field(:actor_id, :id)
|
2019-05-22 12:12:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
object :picture_queries do
|
|
|
|
@desc "Get a picture"
|
|
|
|
field :picture, :picture do
|
|
|
|
arg(:id, non_null(:string))
|
|
|
|
resolve(&Picture.picture/3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
object :picture_mutations do
|
|
|
|
@desc "Upload a picture"
|
|
|
|
field :upload_picture, :picture do
|
|
|
|
arg(:name, non_null(:string))
|
|
|
|
arg(:alt, :string)
|
|
|
|
arg(:file, non_null(:upload))
|
2019-05-31 15:58:03 +00:00
|
|
|
arg(:actor_id, non_null(:id))
|
2019-05-22 12:12:11 +00:00
|
|
|
resolve(&Picture.upload_picture/3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|