graphql.execution.reactive.SubscriptionPublisher Maven / Gradle / Ivy
package graphql.execution.reactive;
import graphql.ExecutionResult;
import graphql.Internal;
import graphql.PublicApi;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import java.util.concurrent.CompletionStage;
import java.util.function.Function;
/**
* Subscription queries return an instance of this class in the {@link ExecutionResult} data element
* for the subscribed field.
*
* {@code
* ExecutionResult er = graphQL.execute("subscription s { onEntityChanged(id : "1") { selection1, selection2 }}")
* SubscriptionPublisher eventPublisher = er.getData("onEntityChanged")
* }
*
*/
@SuppressWarnings("ReactiveStreamsPublisherImplementation")
@PublicApi
public class SubscriptionPublisher implements Publisher {
private final CompletionStageMappingPublisher mappingPublisher;
/**
* Subscription consuming code is not expected to create instances of this class
*
* @param upstreamPublisher the original publisher of objects that then have a graphql selection set applied to them
* @param mapper a mapper that turns object into promises to execution results which are then published on this stream
* @param keepOrdered this indicates that the order of results should be kep in the same order as the source events arrive
*/
@Internal
public SubscriptionPublisher(Publisher