Skip to content

Pagination of primary read action breaks loading relationships #336

@kik4444

Description

@kik4444

Versions

Elixir 1.18.4
OTP 27

ash 3.5.25
ash_admin 0.13.11

Operating system

darwin 24.5.0 arm64

Current Behavior

I have resources A and B with a many_to_many relationship. I edited the primary read action of B to make it require pagination with required?: true. This is because I wanted to make it so that even if someone calls my API without a limit, the default limit per page is still applied.

But now, when I go to A in the Admin UI, click on a row, then click the button to load its related Bs, nothing happens. No SQL query is executed. When I un-require the pagination, then it works. Yet, when I click the second button that only shows the IDs of the rows of the "join_through" resource, that one works.

This is resource A. Nothing special. Names of resources have been changed, though.

  actions do
    defaults [:read, :destroy, update: :*]
  end

  relationships do
    many_to_many :bs, MyApp.B do
      public? true
      through MyApp.A2B
      source_attribute_on_join_resource :a_id
      destination_attribute_on_join_resource :b_id
    end
  end

Now this is my B.

  actions do
    defaults [:destroy, update: :*]

    read :read do
      primary? true

      pagination do
        keyset? true
        # BUG breaks loading relationships in admin ui.
        required? true
        default_limit 500
        max_page_size 500
      end
    end
  end

  relationships do
    many_to_many :as, MyApp.A do
      public? true
      through MyApp.A2B
      source_attribute_on_join_resource :b_id
      destination_attribute_on_join_resource :a_id
      could_be_related_at_creation? true
    end

Now everything works as expected in terms of pagination with the ash_json_api extension. But, when I go to my admin ui, on the A resource, click on a row, then nothing happens if I click the top button in my screenshot. The bottom button works though.

Image

Reproduction

No response

Expected Behavior

I expected all the relationships to be loaded normally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions