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

RFC: Support subscriptionExchange API in @urql/exchange-persisted-fetch #2989

Closed
kitten opened this issue Mar 1, 2023 · 0 comments · Fixed by #3057
Closed

RFC: Support subscriptionExchange API in @urql/exchange-persisted-fetch #2989

kitten opened this issue Mar 1, 2023 · 0 comments · Fixed by #3057
Labels
future 🔮 An enhancement or feature proposal that will be addressed after the next release

Comments

@kitten
Copy link
Member

kitten commented Mar 1, 2023

Summary

See #2988

Currently, it's not possible to pass a persisted payload to a subscriptionExchange. We simply terminate persisted queries using @urql/core/internal's fetch internals.

That's because we can't alter the output of operations without guaranteeing a constant shape throughout. While it could be possible to provide a separate property on Operations for a "serialised" form of what's passed to GraphQL APIs, it likely makes more sense to extend @urql/exchange-persisted-fetch with a persistedSubscriptionExchange.

That's because any transport could in theory accept what an HTTP request body does, so we can extend this to a generic interface.

Proposed Solution

Add persistedSubscriptionExchange to @urql/exchange-persisted-fetch

NOTE: This may imply that we should rename persisted-fetch to something more generic;
either simply @urql/exchange-persisted or @urql/exchange-persisted-queries.

Another aforementioned solution here is to spread out the payloads of what we're sending across multiple exchanges. This currently isn't a preferred solution, imho, since the "persisted" exchange is unique in that it may "destroy" the query property on payloads.

Requirements

  • Create a persistedSubscriptionExchange mirroring the subscriptionExchange in core
    • Expose shared utilities (see implementation of subscriptionExchange) in @urql/core/internal
  • Share logic between persistedFetchExchange and persistedSubscriptionExchange to create the payload
  • Other considerations for cleanup: Currently, the API of the exchange implies that it's supposed to be primarily used for subscription operations, which simply isn't always the case anymore.
    • Consider surface API clean ups (parameters to subscriptionExchange)
    • Optional: Consider renaming subscriptionExchange to transportExchange (?) while we're at it (we'd keep an alias of the old name)
@kitten kitten added the future 🔮 An enhancement or feature proposal that will be addressed after the next release label Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
future 🔮 An enhancement or feature proposal that will be addressed after the next release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant