2020-01-26 20:34:25 +01:00
|
|
|
defmodule Mobilizon.GraphQL.Schema.PictureType do
|
2019-05-22 14:12:11 +02:00
|
|
|
@moduledoc """
|
|
|
|
Schema representation for Pictures
|
|
|
|
"""
|
|
|
|
use Absinthe.Schema.Notation
|
2020-01-26 20:34:25 +01:00
|
|
|
|
|
|
|
alias Mobilizon.GraphQL.Resolvers.Picture
|
2019-05-22 14:12:11 +02: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 17:13:47 +02:00
|
|
|
field(:content_type, :string, description: "The picture's detected content type")
|
|
|
|
field(:size, :integer, description: "The picture's size")
|
2019-05-22 14:12:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "An attached picture or a link to a picture"
|
|
|
|
input_object :picture_input do
|
|
|
|
# Either a full picture object
|
2020-11-19 17:06:28 +01:00
|
|
|
field(:picture, :picture_input_object, description: "A full picture attached")
|
2019-05-22 14:12:11 +02:00
|
|
|
# Or directly the ID of an existing picture
|
2020-11-19 17:06:28 +01:00
|
|
|
field(:picture_id, :id, description: "The ID of an existing picture")
|
2019-05-22 14:12:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
@desc "An attached picture"
|
|
|
|
input_object :picture_input_object do
|
2020-11-19 17:06:28 +01:00
|
|
|
field(:name, non_null(:string), description: "The picture's name")
|
|
|
|
field(:alt, :string, description: "The picture's alternative text")
|
|
|
|
field(:file, non_null(:upload), description: "The picture file")
|
|
|
|
field(:actor_id, :id, description: "The picture owner")
|
2019-05-22 14:12:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
object :picture_queries do
|
|
|
|
@desc "Get a picture"
|
|
|
|
field :picture, :picture do
|
2020-11-20 16:35:48 +01:00
|
|
|
arg(:id, non_null(:id), description: "The picture ID")
|
2019-05-22 14:12:11 +02:00
|
|
|
resolve(&Picture.picture/3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
object :picture_mutations do
|
|
|
|
@desc "Upload a picture"
|
|
|
|
field :upload_picture, :picture do
|
2020-11-19 17:06:28 +01:00
|
|
|
arg(:name, non_null(:string), description: "The picture's name")
|
|
|
|
arg(:alt, :string, description: "The picture's alternative text")
|
|
|
|
arg(:file, non_null(:upload), description: "The picture file")
|
2019-05-22 14:12:11 +02:00
|
|
|
resolve(&Picture.upload_picture/3)
|
|
|
|
end
|
2020-11-20 16:35:48 +01:00
|
|
|
|
|
|
|
@desc """
|
|
|
|
Remove a picture
|
|
|
|
"""
|
|
|
|
field :remove_picture, :deleted_object do
|
|
|
|
arg(:id, non_null(:id), description: "The picture's ID")
|
|
|
|
resolve(&Picture.remove_picture/3)
|
|
|
|
end
|
2019-05-22 14:12:11 +02:00
|
|
|
end
|
|
|
|
end
|