Skip to content
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

feat(core): Wrap ExchangeIO in share calls in composeExchanges (QOL) #3082

Merged
merged 7 commits into from
Mar 20, 2023

Conversation

kitten
Copy link
Member

@kitten kitten commented Mar 19, 2023

Summary

This is a small quality of life improvement for the composeExchanges helper in @urql/core that should make it easier for users to write and understand Exchanges.
It simply removes the need for share to be called manually on Exchanges by wrapping the ExchangeIO function in share calls automatically.

This shortens our docs on "Authoring Exchanges" by a whole large section, simplifies some exchanges, and shouldn't have any negative consequences, except for mocked ExchangeIO in tests requiring a share call now.

Set of changes

  • Wrap forward's argument and return value in share in composeExchanges
  • Add invariant in development that enforces exchanges to call forward just once
  • Update all exchanges to remove redundant share calls

@kitten kitten merged commit 77ec476 into main Mar 20, 2023
@kitten kitten deleted the feat/qol-exchange-forward branch March 20, 2023 07:12
@github-actions github-actions bot mentioned this pull request Mar 20, 2023
@github-actions github-actions bot mentioned this pull request Mar 27, 2023
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