-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure backwards and descending pagination work with id-only optimiza…
…tion. In #205, I implemented an optimization, where we avoid a datastore query when the client is only requesting ids which we already have. As part of that, I implemented sorting and pagination support so that the expected page and ordering of ids are returned. However, I only implemented the simplest case: foward ascending pagination. After merging that, I realized that my implementation wouldn't work for the three other pagination cases: * Forward descending pagination (e.g. `first: N, after: cursor, orderBy: [id_DESC]`) * Backwards ascending pagination (e.g. `last: N, before: cursor, orderBy: [id_ASC]`) * Backwards descending pagination (e.g. `last: N, before: cursor, orderBy: [id_DESC]`) To fix those three cases, I had to change two things in the implementation: * Get the `sort` from the `pagination` datastore body rather than directly from `query`. `query.sort` contains the sort order requested in the GraphQL query, but for some of the above cases we wind up reversing the sort direction we send in the datastore query. * Apply the pagination cursor correctly when results are sorted descending. Previously, we filtered using `id > search_after` for all cases, but we need to use `id < search_after` when we are sorting desecnding.
- Loading branch information
1 parent
a58151d
commit 36dd8e3
Showing
2 changed files
with
104 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters