Is It Possible to Have a Recursive View?

I have a nested datastructure where the children are the same type as the parents. I was wondering if it is possible to do a nested serialization like so:

defmodule ApiWeb.ItemView do
  use ApiWeb, :view
  use JaSerializer.PhoenixView

attributes([])

has_many(
    :children,
    serializer: ApiWeb.ItemView,
    include: true
)
end

This does not seem to work as my frontend answer with this error:

ERROR InternalError: too much recursion. And this happens although the most elevated depth level is 3.

Any help would be highly appreciated.

That’s a Javascript error; it’s going to be exceptionally difficult to debug it without details about what that code does, or the payload that it’s being sent.