native subscription support for Kotlin Flow
See original GitHub issueIs your feature request related to a problem? Please describe.
As per graphql-java currently we only support subscription functions that return some Publisher
(e.g. Reactor Flux
). Since we support coroutines for queries/mutations we should also support Flow
for subscriptions.
Describe the solution you’d like
Support Kotlin Flow
type for subscriptions.
Describe alternatives you’ve considered N/A
Additional context N/A
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Subscriptions in Apollo Kotlin - Apollo GraphQL Docs
Subscriptions are long-lived GraphQL read operations that can update their response over time, enabling clients to receive updates as they occur. They're ...
Read more >Asynchronous Flow - Kotlin
Terminal operators on flows are suspending functions that start a collection of the flow. The collect operator is the most basic one, but...
Read more >Smarter Shared Kotlin Flows - Christophe Beyls - Medium
A technique that can be used to make SharedFlows integrate better with the Lifecycle when used in ViewModels of Android applications, allowing to...
Read more >Flow.Subscription - Android Developers
Causes the Subscriber to (eventually) stop receiving messages. ... A cancelled subscription need not ever receive an onComplete or onError signal.
Read more >kotlinx.coroutines 1.4.0: Introducing StateFlow and SharedFlow
The Flow API in Kotlin is designed to asynchronously handle a stream of data that executes sequentially. In essence, Flow is a sequence....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Would it make sense to have graphql-kotllin provide a class that extends
SubscriptionExecutionStrategy
to treatFlow
s similar to how it currently treatsPublisher
s? I think doing so to only supportFlow
s would be somewhat straightforward port of the class, but probably want to be able to support eitherFlow
orPublisher
from the same strategy, which may be a little less straighforward to figure out?note that due to issues like https://github.com/Kotlin/kotlinx.coroutines/issues/1825 doing
flow.asPublisher()
in the schema function and then consuming theExecutionResult
’s publisher.asFlow()
can have unexpected side effects