From 843e709faee6ef2ba9271f54e3f87a407d735567 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Sun, 21 Jan 2018 11:52:24 +0800 Subject: [PATCH] Provide GraphQL jetty servlet do post method. --- .../ui/graphql/UIGraphQLProtocolTestCase.java | 57 ------------------- .../ui/jetty/handler/GraphQLHandler.java | 3 +- 2 files changed, 2 insertions(+), 58 deletions(-) delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/UIGraphQLProtocolTestCase.java diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/UIGraphQLProtocolTestCase.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/UIGraphQLProtocolTestCase.java deleted file mode 100644 index fc0853694..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/UIGraphQLProtocolTestCase.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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 org.apache.skywalking.apm.collector.ui.graphql; - -import com.coxautodev.graphql.tools.SchemaParser; -import org.apache.skywalking.apm.collector.ui.graphql.alarm.AlarmQuery; -import org.apache.skywalking.apm.collector.ui.graphql.application.ApplicationQuery; -import org.apache.skywalking.apm.collector.ui.graphql.application.ConjecturalNode; -import org.apache.skywalking.apm.collector.ui.graphql.common.VisualUserNode; -import org.apache.skywalking.apm.collector.ui.graphql.config.ConfigMutation; -import org.apache.skywalking.apm.collector.ui.graphql.config.ConfigQuery; -import org.apache.skywalking.apm.collector.ui.graphql.overview.OverViewLayerQuery; -import org.apache.skywalking.apm.collector.ui.graphql.server.ServerQuery; -import org.apache.skywalking.apm.collector.ui.graphql.service.ServiceQuery; -import org.apache.skywalking.apm.collector.ui.graphql.trace.TraceQuery; -import org.junit.Test; - -/** - * @author peng-yongsheng - */ -public class UIGraphQLProtocolTestCase { - - @Test - public void test() { - SchemaParser.newParser() - .file("ui-graphql/alarm.graphqls") - .file("ui-graphql/application-layer.graphqls") - .file("ui-graphql/common.graphqls") - .file("ui-graphql/config.graphqls") - .file("ui-graphql/overview-layer.graphqls") - .file("ui-graphql/server-layer.graphqls") - .file("ui-graphql/service-layer.graphqls") - .file("ui-graphql/trace.graphqls") - .resolvers(new VersionQuery(), new VersionMutation(), new AlarmQuery(), new ApplicationQuery()) - .resolvers(new OverViewLayerQuery(), new ServerQuery(), new ServiceQuery(), new TraceQuery()) - .resolvers(new ConfigQuery(), new ConfigMutation()) - .dictionary(ConjecturalNode.class, VisualUserNode.class) - .build() - .makeExecutableSchema(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java index 8e51a36fe..d5e38df4f 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java @@ -68,7 +68,8 @@ public class GraphQLHandler extends JettyHandler { request += line; } - return execute(request); + JsonObject requestJson = gson.fromJson(request, JsonObject.class); + return execute(requestJson.get(QUERY).getAsString()); } private JsonObject execute(String request) {