The ash_json_api extension is failing to generate the filter object for a two-times nested relationship. For example, given the relationship where Author has many Posts, and Post belongs to Blog, the Authors endpoint generated should include a reference to the blog-filter, but it was never generated.
To Reproduce
Define a resource where Author has many Posts.
Define that Post belongs to Blog.
Generate an API for Authors.
Observe that the blog-filter is not generated in the Authors endpoint.
This are the Resources i tried with:
Author
defmodule TestRepo.Support.Author do
use Ash.Resource,
domain: TestRepo.Support,
extensions: [AshJsonApi.Resource]
json_api do
type("author")
routes do
base "/authors"
index :read
end
end
actions do
default_accept(:*)
defaults([:create, :read, :update, :destroy])
end
attributes do
uuid_primary_key(:id, writable?: true)
attribute(:name, :string, public?: true)
end
relationships do
has_many(:posts, TestRepo.Support.Post, public?: true)
end
end
Post
defmodule TestRepo.Support.Post do
use Ash.Resource,
domain: TestRepo.Support,
extensions: [AshJsonApi.Resource]
json_api do
type("post")
end
actions do
default_accept(:*)
defaults([:create, :read, :update, :destroy])
end
attributes do
uuid_primary_key(:id, writable?: true)
attribute(:name, :string, public?: true)
end
relationships do
belongs_to :author, TestRepo.Support.Author, public?: true
belongs_to :blog, TestRepo.Support.Blog, public?: true
end
end
Blog
defmodule TestRepo.Support.Blog do
use Ash.Resource,
domain: TestRepo.Support,
extensions: [AshJsonApi.Resource]
json_api do
type("blog")
routes do
base "/blogs"
index :read
end
end
actions do
default_accept(:*)
defaults([:create, :read, :update, :destroy])
end
attributes do
uuid_primary_key(:id, writable?: true)
attribute(:name, :string, public?: true)
end
relationships do
has_many :posts, TestRepo.Support.Post, public?: true
end
end
The
ash_json_api
extension is failing to generate the filter object for a two-times nested relationship. For example, given the relationship whereAuthor
has manyPosts
, andPost
belongs toBlog
, theAuthors
endpoint generated should include a reference to theblog-filter
, but it was never generated.To Reproduce
Author
has manyPosts
.Post
belongs toBlog
.Authors
.blog-filter
is not generated in theAuthors
endpoint.This are the Resources i tried with:
Author
Post
Blog
Runtime