-
Notifications
You must be signed in to change notification settings - Fork 11.5k
graphql-alt: Object version pagination #22086
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces pagination support for object versions in the GraphQL API, including new schema definitions, resolver functions, and pagination logic.
- Adds pagination fields (objectVersionsAfter, objectVersionsBefore) to the GraphQL schema and updates related API types.
- Implements and tests new pagination logic in the pagination module and integrates it into object and package queries.
- Adds helper functions for filter intersection to support version-bound queries.
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
crates/sui-indexer-alt-schema/src/objects.rs | Updated Diesel model attributes for StoredObjVersion. |
crates/sui-indexer-alt-graphql/staging.graphql, snapshots, schema.graphql | Added pagination fields and updated descriptions for object/package versions. |
crates/sui-indexer-alt-graphql/src/pagination.rs | Added a new paginate_results method with tests for various paging scenarios. |
crates/sui-indexer-alt-graphql/src/api/types/object.rs | Implemented new resolver functions for object_versions_after/object_versions_before and integrated filter intersection logic. |
crates/sui-indexer-alt-graphql/src/intersect.rs | Introduced helper methods for merging filter boundaries. |
crates/sui-indexer-alt-e2e-tests/tests/graphql/objects/object_versions.move | Added end-to-end tests for object versions pagination. |
Comments suppressed due to low confidence (1)
crates/sui-indexer-alt-graphql/src/pagination.rs:271
- [nitpick] The logic for trimming prefix and suffix using nth and nth_back is complex; consider refactoring or adding explanatory comments to clarify how the edge trimming guarantees correct behavior.
if prefix > 0 { edges.nth(prefix - 1); }
let last = edges.last().map(|(c, _)| c.clone()); | ||
|
||
let (prev, next, prefix, suffix) = | ||
match (self.after(), first, last, self.before(), self.end) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see, so this represents the result, where we have self.after(), then the first, last from fetched results, self.before()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this is lifted almost verbatim from OG GraphQL. The main difference is it doesn't include scan limit stuff.
Paginate all versions of this package treated as an object, after this one. | ||
""" | ||
objectVersionsAfter(first: Int, after: String, last: Int, before: String, filter: VersionFilter): ObjectConnection! | ||
""" | ||
Paginate all versions of this package treated as an object, before this one. | ||
""" | ||
objectVersionsBefore(first: Int, after: String, last: Int, before: String, filter: VersionFilter): ObjectConnection! | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats the rationale for having two methods here, instead of a single objectVersions
connection where you could paginate through all versions before or after the current package through the existing first, after, last, before
params?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just offering an objectVersions
API is less expressive because there is no way to use that to phrase a "before" or "after" query, whereas the opposite is not true (you can phrase an objectVersions
query as a combination of a before, after, and self query).
Description
Adding infrastructure for pagination, filters and filter intersection, and using it to implement pagination for object versions, exposed in the following fields:
Query.objectVersions
Object.objectVersionsBefore
Object.objectVersionsAfter
Test plan
New unit tests for pagination logic:
New E2E tests for new object pagination methods:
Stack
Release notes
Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.
For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.