fix(graphql): set default value for resource type parameter
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
94bf2e53bf
commit
09f41328ab
|
@ -207,9 +207,9 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Resources do
|
||||||
{:ok, Resources.get_resource(old_parent_id), Resources.get_resource(new_parent_id)}
|
{:ok, Resources.get_resource(old_parent_id), Resources.get_resource(new_parent_id)}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp prepare_args(%{type: type} = args) do
|
defp prepare_args(args) do
|
||||||
args =
|
args =
|
||||||
case type do
|
case Map.get(args, :type, :link) do
|
||||||
:folder ->
|
:folder ->
|
||||||
args
|
args
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,12 @@ defmodule Mobilizon.GraphQL.Schema.ResourceType do
|
||||||
field(:inserted_at, :naive_datetime, description: "The resource's creation date")
|
field(:inserted_at, :naive_datetime, description: "The resource's creation date")
|
||||||
field(:updated_at, :naive_datetime, description: "The resource's last update date")
|
field(:updated_at, :naive_datetime, description: "The resource's last update date")
|
||||||
field(:published_at, :naive_datetime, description: "The resource's publication date")
|
field(:published_at, :naive_datetime, description: "The resource's publication date")
|
||||||
field(:type, :string, description: "The resource's type (if it's a folder)")
|
|
||||||
|
field(:type, :string,
|
||||||
|
default_value: "link",
|
||||||
|
description: "The resource's type (if it's a folder)"
|
||||||
|
)
|
||||||
|
|
||||||
field(:path, :string, description: "The resource's path")
|
field(:path, :string, description: "The resource's path")
|
||||||
|
|
||||||
field(:parent, :resource,
|
field(:parent, :resource,
|
||||||
|
|
|
@ -18,7 +18,7 @@ defmodule Mobilizon.Resources.Resource do
|
||||||
summary: String.t(),
|
summary: String.t(),
|
||||||
url: String.t(),
|
url: String.t(),
|
||||||
resource_url: String.t(),
|
resource_url: String.t(),
|
||||||
type: atom(),
|
type: TypeEnum.t(),
|
||||||
metadata: Metadata.t(),
|
metadata: Metadata.t(),
|
||||||
children: list(__MODULE__),
|
children: list(__MODULE__),
|
||||||
parent: __MODULE__,
|
parent: __MODULE__,
|
||||||
|
|
|
@ -283,7 +283,7 @@ defmodule Mobilizon.GraphQL.Resolvers.ResourceTest do
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert is_nil(res["errors"])
|
assert res["errors"] == nil
|
||||||
|
|
||||||
assert res["data"]["resource"]["path"] == "/"
|
assert res["data"]["resource"]["path"] == "/"
|
||||||
assert String.starts_with?(res["data"]["resource"]["id"], "root_")
|
assert String.starts_with?(res["data"]["resource"]["id"], "root_")
|
||||||
|
|
Loading…
Reference in a new issue