dgs-framework icon indicating copy to clipboard operation
dgs-framework copied to clipboard

feature: Support Flow as Subscription return type

Open hantsy opened this issue 3 years ago • 1 comments

Currently, the subscription only supports ReactiveStream Pulisher as return type, if possible to add Kotlin Flow support, it make my codes look more consistent when I am using Kotlin Coroutines.

val flow = MutableSharedFlow<Event>()

fun emitEvent() {
   flow.emit(event)
   ...
}

fun eventAdded()=flow //the subscription function.

Internally Dgs can bridge it to a Publisher as required by graphql-java .

hantsy avatar May 26 '22 15:05 hantsy

I think that is a good idea, thanks @hantsy for the suggestion.

berngp avatar May 27 '22 00:05 berngp

Support for flow was added in c48492a.

kilink avatar Jan 24 '24 00:01 kilink

@kilink It seems the commit provides Flow as return type of Data Fetching, how about Flow support for subscription/event modeling?

hantsy avatar Jan 24 '24 01:01 hantsy

You're right. I've added support for it in #1800

kilink avatar Jan 24 '24 02:01 kilink