Hi!
So I am trying to reuse an existing serializer for a relation that has a different (include) name/type. For example:
defmodule AuthorView do
has_many :articles,
serializer: ArticleView,
link: :articles_url
has_one :pinned_article,
serializer: ArticleView,
link: :pinned_article_url,
type: :pinned_article
end
defmodule ArticleView do
end
But, the type: :pinned_article is ignored. Relation always gets rendered as:
"pinned-article" => %{
"data" => %{
"id" => payment.id,
"type" => "article"
}
}
And the same for included relation/object as well. The type remains article, instead of pinned-article.
The main reason for reusing is to not have to repeat the additional logic ArticleView, e.g. how it sets the self URL, some attributes etc.
Any ideas on how to solve this one?
Thank you 🙇🏼
Hi!
So I am trying to reuse an existing serializer for a relation that has a different (include) name/type. For example:
But, the
type: :pinned_articleis ignored. Relation always gets rendered as:And the same for included relation/object as well. The type remains
article, instead ofpinned-article.The main reason for reusing is to not have to repeat the additional logic
ArticleView, e.g. how it sets the self URL, some attributes etc.Any ideas on how to solve this one?
Thank you 🙇🏼