All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR1
Show newest version
/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.vertx.rxjava.ext.web.handler.graphql;

import rx.Observable;
import rx.Single;
import io.vertx.rx.java.RxHelper;
import io.vertx.rx.java.WriteStreamSubscriber;
import io.vertx.rx.java.SingleOnSubscribeAdapter;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;

/**
 * A handler for GraphQL requests sent over Apollo's subscriptions-transport-ws transport.
 *
 * 

* NOTE: This class has been automatically generated from the {@link io.vertx.ext.web.handler.graphql.ApolloWSHandler original} non RX-ified interface using Vert.x codegen. */ @RxGen(io.vertx.ext.web.handler.graphql.ApolloWSHandler.class) public class ApolloWSHandler implements Handler { @Override public String toString() { return delegate.toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ApolloWSHandler that = (ApolloWSHandler) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new ApolloWSHandler((io.vertx.ext.web.handler.graphql.ApolloWSHandler) obj), ApolloWSHandler::getDelegate ); private final io.vertx.ext.web.handler.graphql.ApolloWSHandler delegate; public ApolloWSHandler(io.vertx.ext.web.handler.graphql.ApolloWSHandler delegate) { this.delegate = delegate; } public ApolloWSHandler(Object delegate) { this.delegate = (io.vertx.ext.web.handler.graphql.ApolloWSHandler)delegate; } public io.vertx.ext.web.handler.graphql.ApolloWSHandler getDelegate() { return delegate; } /** * Something has happened, so handle it. * @param event the event to handle */ public void handle(io.vertx.rxjava.ext.web.RoutingContext event) { delegate.handle(event.getDelegate()); } /** * Customize the connection . * This handler will be called at the beginning of each websocket connection. * @param connectionHandler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler connectionHandler(Handler connectionHandler) { delegate.connectionHandler(new Handler() { public void handle(io.vertx.core.http.ServerWebSocket event) { connectionHandler.handle(io.vertx.rxjava.core.http.ServerWebSocket.newInstance((io.vertx.core.http.ServerWebSocket)event)); } }); return this; } /** * Customize the message . * This handler will be called for each {@link io.vertx.rxjava.ext.web.handler.graphql.ApolloWSMessage} received. * @param messageHandler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler messageHandler(Handler messageHandler) { delegate.messageHandler(new Handler() { public void handle(io.vertx.ext.web.handler.graphql.ApolloWSMessage event) { messageHandler.handle(io.vertx.rxjava.ext.web.handler.graphql.ApolloWSMessage.newInstance((io.vertx.ext.web.handler.graphql.ApolloWSMessage)event)); } }); return this; } /** * Customize the end . * This handler will be called at the end of each websocket connection. * @param endHandler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler endHandler(Handler endHandler) { delegate.endHandler(new Handler() { public void handle(io.vertx.core.http.ServerWebSocket event) { endHandler.handle(io.vertx.rxjava.core.http.ServerWebSocket.newInstance((io.vertx.core.http.ServerWebSocket)event)); } }); return this; } /** * Customize the query context object. * The provided factory method will be invoked for each incoming GraphQL request. * @param factory * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler queryContext(Function factory) { delegate.queryContext(new Function() { public java.lang.Object apply(io.vertx.ext.web.handler.graphql.ApolloWSMessage arg) { java.lang.Object ret = factory.apply(io.vertx.rxjava.ext.web.handler.graphql.ApolloWSMessage.newInstance((io.vertx.ext.web.handler.graphql.ApolloWSMessage)arg)); return ret; } }); return this; } /** * Create a new {@link io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler} that will use the provided graphQL object to execute requests. *

* The handler will be configured with the default {@link io.vertx.ext.web.handler.graphql.ApolloWSOptions}. * @param graphQL * @return */ public static io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler create(graphql.GraphQL graphQL) { io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler ret = io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler.newInstance((io.vertx.ext.web.handler.graphql.ApolloWSHandler)io.vertx.ext.web.handler.graphql.ApolloWSHandler.create(graphQL)); return ret; } /** * Create a new {@link io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler} that will use the provided graphQL object to execute requests. *

* The handler will be configured with the given options. * @param graphQL * @param options options for configuring the {@link io.vertx.ext.web.handler.graphql.ApolloWSOptions} * @return */ public static io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler create(graphql.GraphQL graphQL, io.vertx.ext.web.handler.graphql.ApolloWSOptions options) { io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler ret = io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler.newInstance((io.vertx.ext.web.handler.graphql.ApolloWSHandler)io.vertx.ext.web.handler.graphql.ApolloWSHandler.create(graphQL, options)); return ret; } /** * Customize the . * The provided factory method will be invoked for each incoming GraphQL request. * @param factory * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler dataLoaderRegistry(Function factory) { delegate.dataLoaderRegistry(new Function() { public org.dataloader.DataLoaderRegistry apply(io.vertx.ext.web.handler.graphql.ApolloWSMessage arg) { org.dataloader.DataLoaderRegistry ret = factory.apply(io.vertx.rxjava.ext.web.handler.graphql.ApolloWSMessage.newInstance((io.vertx.ext.web.handler.graphql.ApolloWSMessage)arg)); return ret; } }); return this; } /** * Customize the passed to the GraphQL execution engine. * The provided factory method will be invoked for each incoming GraphQL request. * @param factory * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.ext.web.handler.graphql.ApolloWSHandler locale(Function factory) { delegate.locale(new Function() { public java.util.Locale apply(io.vertx.ext.web.handler.graphql.ApolloWSMessage arg) { java.util.Locale ret = factory.apply(io.vertx.rxjava.ext.web.handler.graphql.ApolloWSMessage.newInstance((io.vertx.ext.web.handler.graphql.ApolloWSMessage)arg)); return ret; } }); return this; } public static ApolloWSHandler newInstance(io.vertx.ext.web.handler.graphql.ApolloWSHandler arg) { return arg != null ? new ApolloWSHandler(arg) : null; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy