I have two resources. The two are related to each other.
Article resource
defmodule Accounts.Blog.Article do
use Ash.Resource,
domain: Account.Domain,
data_layer: AshPostgres.DataLayer,
extensions: [AshJsonApi.Resource]
...
actions do
read :read do
pagination countable: true, offset?: true, required?: true, default_limit: 10
end
end
relationships do
has_many :comments, Comment
end
end
Comments resource
defmodule Accounts.Blog.Comment do
use Ash.Resource,
domain: Account.Domain,
data_layer: AshPostgres.DataLayer,
extensions: [AshJsonApi.Resource]
...
actions do
read :read do
pagination countable: true, offset?: true, required?: true, default_limit: 10
end
end
relationships do
belongs_to, :article, Article
end
end
Domain
defmodule Account.Domain do
use Ash.Domain, extensions: [AshJsonApi.Domain]
alias Accounts.Blog.{Article, Comment}
json_api do
routes do
base_route "/articles", Article do
get :read
related :comments, :read
end
end
end
end
When I try to get the related comments for Accounts.Blog.Article
using the endpoint articles/:article_id/comments
, the records are not paginated as expected. However, if I make a GET request to /articles
, the articles are paginated as expected. Fetching the resource directly works, but pagination does not work for the related resource.