Is it possible to disable pagination entirely for a read action?

I'm using AshGraphQL, and I have a pretty bespoke read action that through some reasonably complex logic related to some custom arguments kind of "self-paginates" - the implementation and design reasons for this are more than is worth explaining here, and yes, I wish it were different than it is and may even refactor away from this in the future, but that will take some time to do... for now, suffice to say that when generating my graphql schema, I'd really love to be able to not show the pesky limit and offset params in queries/relationship loads, since the bespoke logic of the action kind of already accomplishes what pagination is doing, so it's confusing for the front end devs that consume my API to see those pagination params that are functionally redundant. I found paginate_with and paginate_relationship_with, which seem to imply that I might be able to pass nil to disable pagination, but afaict that doesn't seem to do it. Is this something that's supported?
Solution:
You'll have to add a :none atom
Jump to solution
8 Replies
Jesse Williams
Jesse WilliamsOP4mo ago
Actually taking a closer look, it seems like this mostly applies to the relationship case, seems like paginate_with nil does what I expected, it's just the relationship case where paginate_relationship_with my_relationship: nil still winds up with a limit and offset param I'm increasingly thinking this is just a bug. ash_graphql source code -> root level query case:
defp pagination_args(query, action) do
case query_pagination_strategy(query, action) do
nil ->
[]

:keyset ->
keyset_pagination_args(action)

:offset ->
offset_pagination_args(action)
end
end
defp pagination_args(query, action) do
case query_pagination_strategy(query, action) do
nil ->
[]

:keyset ->
keyset_pagination_args(action)

:offset ->
offset_pagination_args(action)
end
end
relationship query case:
defp relationship_pagination_args(resource, relationship_name, action) do
case relationship_pagination_strategy(resource, relationship_name, action) do
nil ->
default_relationship_pagination_args()

:keyset ->
keyset_pagination_args(action)

:relay ->
# Relay has the same args as keyset
keyset_pagination_args(action)

:offset ->
offset_pagination_args(action)
end
end
defp relationship_pagination_args(resource, relationship_name, action) do
case relationship_pagination_strategy(resource, relationship_name, action) do
nil ->
default_relationship_pagination_args()

:keyset ->
keyset_pagination_args(action)

:relay ->
# Relay has the same args as keyset
keyset_pagination_args(action)

:offset ->
offset_pagination_args(action)
end
end
feels like the relationship case should also be nil -> []?
ZachDaniel
ZachDaniel4mo ago
That sounds right to me, yeah oh um... no relationships always supported limit/offset
Solution
ZachDaniel
ZachDaniel4mo ago
You'll have to add a :none atom
Jesse Williams
Jesse WilliamsOP4mo ago
Alright, can do Is this just to avoid a technically breaking change, or is there like a design reason I'm missing that relationships should default to that even if it's not specified?
ZachDaniel
ZachDaniel4mo ago
Yeah its to avoid a breaking change We didn't used to have an option here all relationships just always supported limit/offset lol
Jesse Williams
Jesse WilliamsOP4mo ago
Gotcha, yeah avoiding the breaking change makes sense
Jesse Williams
Jesse WilliamsOP4mo ago
https://github.com/ash-project/ash_graphql/pull/336 For anyone running onto this thread in the future: The above PR didn't quite cut it, I also implemented this follow up PR The first PR was released in 1.7.16, second one is pending release and will presumably be released in 1.7.17 (whenever that is). So the :none setting won't do anything until 1.7.17
ZachDaniel
ZachDaniel4mo ago
I'll release that now

Did you find this page helpful?