-
Notifications
You must be signed in to change notification settings - Fork 144
Open
Description
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
endBut, 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 🙇🏼
Metadata
Metadata
Assignees
Labels
No labels