Skip to content

feat: add cursor and limit support to relationship read - #683

Merged
tstirrat15 merged 4 commits into
authzed:mainfrom
kbrwn:read-rel-cursoring
Apr 30, 2026
Merged

feat: add cursor and limit support to relationship read#683
tstirrat15 merged 4 commits into
authzed:mainfrom
kbrwn:read-rel-cursoring

Conversation

@kbrwn

@kbrwn kbrwn commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Adds --cursor and --show-cursor flags to zed relationship read so users can resume pagination from a prior cursor token and surface the trailing cursor for follow-up calls.

@codecov-commenter

codecov-commenter commented Apr 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.46512% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.93%. Comparing base (5899606) to head (7e5ad57).

Files with missing lines Patch % Lines
internal/commands/relationship.go 60.46% 14 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #683      +/-   ##
==========================================
+ Coverage   43.21%   43.93%   +0.71%     
==========================================
  Files          38       38              
  Lines        6090     6109      +19     
==========================================
+ Hits         2632     2684      +52     
+ Misses       3190     3148      -42     
- Partials      268      277       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tstirrat15 tstirrat15 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

Comment thread internal/commands/relationship.go
Comment on lines +287 to +290
var lastCursor *v1.Cursor
if cursorStr := cobrautil.MustGetString(cmd, "cursor"); cursorStr != "" {
lastCursor = &v1.Cursor{Token: cursorStr}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the input of the page

Comment thread internal/commands/relationship.go
Comment thread internal/commands/relationship.go
Comment thread internal/commands/relationship_test.go
Comment on lines +840 to +847
func makeTestCallback() (func(_ *cobra.Command, responses []*v1.ReadRelationshipsResponse) error, *[][]*v1.ReadRelationshipsResponse) {
var pages [][]*v1.ReadRelationshipsResponse
callback := func(_ *cobra.Command, responses []*v1.ReadRelationshipsResponse) error {
pages = append(pages, responses)
return nil
}
return callback, &pages
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is both a little awkward and maybe a little cute. The big thing is that it needs to return a pointer to the slice rather than the slice itself in order for the callback to correctly modify it, but then you have to deref it where it's used.

It's not used in that many places so I can inline if desired.

@tstirrat15
tstirrat15 force-pushed the read-rel-cursoring branch 3 times, most recently from d3629bd to e87a374 Compare April 29, 2026 20:50
Comment thread internal/commands/relationship.go Outdated
Comment thread internal/commands/relationship.go
Comment thread internal/commands/relationship.go Outdated
Comment on lines +335 to +337
// If we set an explicit limit or if we find a page smaller than the page limit,
// we stop.
if limitSet || relCount < pageSize {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic changed - we stop iterating if we've explicitly set a limit, or else if the relCount is smaller than the limit.

@miparnisari miparnisari changed the title feat: add cursor support to relationship read feat: add cursor and limit support to relationship read Apr 30, 2026
Comment thread internal/commands/relationship.go Outdated
miparnisari
miparnisari previously approved these changes Apr 30, 2026
alecmerdler
alecmerdler previously approved these changes Apr 30, 2026
Co-authored-by: Maria Ines Parnisari <maineparnisari@gmail.com>
@tstirrat15
tstirrat15 enabled auto-merge (squash) April 30, 2026 14:34
@tstirrat15
tstirrat15 merged commit 3432bf7 into authzed:main Apr 30, 2026
13 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants