Skip to content

fix(duct-tape): align pagination/refetch callback with Relay onComplete#650

Merged
alloy merged 3 commits intomicrosoft:mainfrom
vikasnishal:user/vikaskumar/loadNextAPIAlignmentWithRelay
Mar 19, 2026
Merged

fix(duct-tape): align pagination/refetch callback with Relay onComplete#650
alloy merged 3 commits intomicrosoft:mainfrom
vikasnishal:user/vikaskumar/loadNextAPIAlignmentWithRelay

Conversation

@vikasnishal
Copy link
Copy Markdown
Contributor

Summary

This PR aligns duct-tape’s pagination/refetch callback option naming with Relay.

Relay uses onComplete for loadNext/refetch completion callbacks, while duct-tape only supported onCompleted. That mismatch caused Relay-style options to be ignored at runtime unless users passed both keys manually.

Changes

  • Added onComplete?: (error: Error | null) => void to RefetchOptions.
  • Kept onCompleted as a backward-compatible alias and marked it deprecated in type docs.
  • Updated runtime callback resolution to:
    • Prefer onComplete
    • Fallback to onCompleted
  • Applied this behavior in both:
    • Refetch flow
    • Pagination loadNext/loadPrevious flow

Backward Compatibility

  • Existing consumers using onCompleted continue to work.
  • New/Relay-aligned consumers can use onComplete.
  • No breaking API removal in this change.

Tests

  • Updated compiledHooks tests to cover:
    • onComplete invocation on success/error
    • deprecated onCompleted alias invocation on success/error
  • Manually validated integration in TMP repo by locally symlinking @graphitation/apollo-react-relay-duct-tape from this branch and verifying callback behavior from the consumer side.

Why

This removes a compatibility trap where Relay-style onComplete was not invoked under duct-tape runtime behavior.

Copy link
Copy Markdown
Member

@alloy alloy left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@vikasnishal
Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Microsoft"

@vikasnishal vikasnishal reopened this Mar 19, 2026
@alloy alloy merged commit a76ea9b into microsoft:main Mar 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants