RxJava 3 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), you will have to adapt the Single and Maybe objects.

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

Instead of converting Single or Maybe to CompletionStage manually in every data fetcher implementation, configure GraphQL-Java with the SingleAdapter and MaybeAdapter instrumentations.

First, declare the instrumentations while configuring GraphQL-Java.

graphQLBuilder.instrumentation(new ChainedInstrumentation(SingleAdapter.create(), MaybeAdapter.create()));

Then you can return Single or Maybe directly.

DataFetcher<Single<List<Link>>> dataFetcher = environment -> {
  Single<List<Link>> single = retrieveLinksFromBackend(environment);
  return single;
};