Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nested relationship pagination #1035

Open
rbino opened this issue Apr 19, 2024 · 1 comment
Open

Allow nested relationship pagination #1035

rbino opened this issue Apr 19, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@rbino
Copy link
Contributor

rbino commented Apr 19, 2024

Is your feature request related to a problem? Please describe.
This is a presequisite for ash-project/ash_graphql#131, opening it here to focus the discussion on the core part

Describe the solution you'd like
It should be possible to paginate a relationship by passing an appropriate Query. This would allow to have pagination for nested relationships for extensions that support this (like, potentially, AshGraphql).

Express the feature either with a change to resource syntax, or with a change to the resource interface

Right now the only place where pagination can be configured is in action options, i.e. passing page: [offset: 3, limit: 10] to Ash.read or similar functions. To be able to setup pagination in nested loads, we will probably have to add some function and/or option on Query (and Changeset, since those have loads too). This should be similar to what is already done with, e.g., tenant, which can be set both on the Query and as an action option.

Potential syntax:

comment =
  Comment
  |> Query.set_page(after: comment_keyset, first: 10)

Post
|> Ash.Query.load(comment: comment)
|> Ash.read!()
@rbino rbino added enhancement New feature or request needs review labels Apr 19, 2024
@zachdaniel
Copy link
Contributor

This would be a welcome feature. I attempted to add this a long time ago, but the codebase wasn't in a good place for that. In its current state, I think it is much more doable. There may be some finicky bits since what must currently be a list could now be a page, but we can work those things out without too much hassle I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants