RxJava 2 API

Setting up with an Rxified router

To handle GraphQL requests on a Rxified Route, make sure to import the GraphQLHandler class.

Working with Vert.x Rxified APIs

GraphQL-Java expects CompletionStage for asynchronous results in data fetchers and batch loaders.

Therefore, if you work with the Vert.x Rxified APIs (e.g. the Web Client or the Cassandra Client), you will have to adapt the Single and Maybe objects.

The RxJava2Jdk8Interop library provides the tooling to do just that. Add the following to the dependencies section of your Maven build file:

<dependency>
 <groupId>com.github.akarnokd</groupId>
 <artifactId>rxjava2-jdk8-interop</artifactId>
 <version>0.3.5</version>
</dependency>

Or if you use Gradle:

compile 'com.github.akarnokd:rxjava2-jdk8-interop:0.3.5'

Then you can create a data fetcher from a Single result:

Single<String> data = loadDataFromBackend();
DataFetcher<CompletionStage<String>> fetcher = environment -> {
 return data.to(SingleInterop.get());
};

For Maybe results, use MaybeInterop.