use of io.smallrye.graphql.client.impl.typesafe.HeaderBuilder in project smallrye-graphql by smallrye.
the class VertxTypesafeGraphQLClientProxy method invoke.
Object invoke(MethodInvocation method) {
if (method.isDeclaredInObject()) {
return method.invoke(this);
}
MultiMap headers = HeadersMultiMap.headers().addAll(new HeaderBuilder(api, method, additionalHeaders).build());
JsonObject request = request(method);
if (method.getReturnType().isUni()) {
if (executeSingleOperationsOverWebsocket) {
return executeSingleResultOperationOverWebsocket(method, request);
} else {
return executeSingleResultOperationOverHttpAsync(method, request, headers);
}
} else if (method.getReturnType().isMulti()) {
return executeSubscriptionOverWebsocket(method, request);
} else {
if (executeSingleOperationsOverWebsocket) {
return executeSingleResultOperationOverWebsocket(method, request).await().indefinitely();
} else {
return executeSingleResultOperationOverHttpSync(method, request, headers);
}
}
}
use of io.smallrye.graphql.client.impl.typesafe.HeaderBuilder in project smallrye-graphql by smallrye.
the class VertxTypesafeGraphQLClientProxy method webSocketHandler.
private Uni<WebSocketSubprotocolHandler> webSocketHandler() {
return webSocketHandler.updateAndGet(currentValue -> {
if (currentValue == null) {
return Uni.createFrom().<WebSocketSubprotocolHandler>emitter(handlerEmitter -> {
List<String> subprotocolIds = subprotocols.stream().map(i -> i.getProtocolId()).collect(toList());
MultiMap headers = HeadersMultiMap.headers().addAll(new HeaderBuilder(api, null, additionalHeaders).build());
httpClient.webSocketAbs(websocketUrl, headers, WebsocketVersion.V13, subprotocolIds, result -> {
if (result.succeeded()) {
WebSocket webSocket = result.result();
WebSocketSubprotocolHandler handler = BuiltinWebsocketSubprotocolHandlers.createHandlerFor(webSocket.subProtocol(), webSocket, subscriptionInitializationTimeout, () -> {
webSocketHandler.set(null);
});
handlerEmitter.complete(handler);
log.debug("Using websocket subprotocol handler: " + handler);
} else {
handlerEmitter.fail(result.cause());
}
});
}).memoize().indefinitely();
} else {
return currentValue;
}
});
}
Aggregations