-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
Optimizer window pagination #613
Comments
Hey @Kitefiko , Hrm, I'm not really I understood the issue. When and why does |
Hi @bellini666 We've run into these issue as well, particularly with strawberry-django/strawberry_django/relay.py Line 195 in d6051db
Just so its clear, the has_next_page = (
result[-1]._strawberry_row_number < result[-1]._strawberry_total_count
if result
else False
) |
@bellini666 FYI #622 only fixes 1 of the 4 problems raised in this issue, so it may be worth keeping this open? |
@SupImDos good point, going to reopen this |
@bellini666 Yes, we've specifically run into the "Usage of last returns everything and bypasses max_results" issue, so I should be able to put together an MRE for that soon. |
@bellini666
In short, doing: query {
milestoneConn(last: 3) {
edges {
node {
id
}
}
}
} Results in: SELECT "projects_milestone"."name",
"projects_milestone"."id",
"projects_milestone"."due_date",
"projects_milestone"."project_id"
FROM "projects_milestone" LIMIT 9223372036854775807 # <- This is ``sys.maxsize`` |
Hi @SupImDos , Thanks for the MRE! 😊 Here is what is happening: The relay limit/offset algorithm on strawberry is implemented using slices, and those are calculated here: https://github.com/strawberry-graphql/strawberry/blob/main/strawberry/relay/utils.py#L126 If you take a look at this line, you will see that if you only ask for A good workaround would be to make this do I think the only options we have to solve this specific case (we only have last and nothing else) would be:
In theory, this would work the same, but then we would need to re-reverse the results after.
This one would not require re-reversing, but is somewhat more complicated to implement, as it would require changing the strawberry API to allow hooking into it. What do you think? Anything that I'm missing here? |
Describe the Bug
I believe I have found multiple issues with window pagination implementation.
AttributeError
is always thrown inListConnectionWithTotalCount.resolve_connection_from_cache
AttributeError
prevents paginationlast
returns everything and bypassesmax_results
System Information
Additional Context
ListConnectionWithTotalCount.resolve_connection_from_cache
AttributeError
is always thrown here:strawberry-django/strawberry_django/relay.py
Line 195 in d6051db
I think there should be something like this?
Backup solution in case of
AttributeError
prevents paginationThis might be intended behavior, but:
In case of
AttributeError
pagination falls back toresolve_connection
but (probably due to unavailable overfetch?)pageInfo
'shasNextPage
is wrongly reporting asfalse
Order and thus pagination itself is non-deterministic when explicit order is not used
This is probably the biggest issue. Maybe fixable via
pk
ordering in case of emptyorder_by
inapply_window_pagination
?Usage of
last
returns everything and bypassesmax_results
When
last
is used on it's own and execution ends up here:strawberry-django/strawberry_django/optimizer.py
Lines 561 to 573 in d6051db
slice_metadata.start
is evaluated to 0slice_metadata.end
becomessys.maxsize
and queryset ends up filtering out nothing
Upvote & Fund
The text was updated successfully, but these errors were encountered: