Remove spring dependency
This commit is contained in:
parent
84caf87f36
commit
e771350812
|
|
@ -1,6 +0,0 @@
|
|||
## Using graphiql
|
||||
|
||||
Graphiql */ˈɡrafək(ə)l/* is interactive in-browser GraphQL IDE which can be used by following steps.
|
||||
|
||||
1. Run `org.apache.skywalking.apm.ui.protocol.GraphQLInitializer#main`
|
||||
1. Access [http://localhost:8080/graphiql](http://localhost:8080/graphiql)
|
||||
|
|
@ -30,37 +30,10 @@
|
|||
<artifactId>apm-ui-protocol</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>1.5.9.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<version>1.5.9.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<version>1.5.9.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<version>1.5.9.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<!-- to embed GraphiQL tool -->
|
||||
<dependency>
|
||||
<groupId>com.graphql-java</groupId>
|
||||
<artifactId>graphql-spring-boot-starter</artifactId>
|
||||
<version>3.9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.graphql-java</groupId>
|
||||
<artifactId>graphiql-spring-boot-starter</artifactId>
|
||||
<version>3.9.2</version>
|
||||
<artifactId>graphql-java</artifactId>
|
||||
<version>6.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -1,75 +0,0 @@
|
|||
package org.apache.skywalking.apm.ui.protocol;
|
||||
|
||||
import graphql.schema.GraphQLObjectType;
|
||||
import graphql.schema.GraphQLSchema;
|
||||
import graphql.schema.TypeResolver;
|
||||
import graphql.schema.idl.FieldWiringEnvironment;
|
||||
import graphql.schema.idl.InterfaceWiringEnvironment;
|
||||
import graphql.schema.idl.RuntimeWiring;
|
||||
import graphql.schema.idl.SchemaGenerator;
|
||||
import graphql.schema.idl.SchemaParser;
|
||||
import graphql.schema.idl.TypeDefinitionRegistry;
|
||||
import graphql.schema.idl.WiringFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.support.SpringBootServletInitializer;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* GraphQL server initializer.
|
||||
*
|
||||
* @author gaohongtao
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class GraphQLInitializer extends SpringBootServletInitializer {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(GraphQLInitializer.class);
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ApplicationContext applicationContext = SpringApplication.run(GraphQLInitializer.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
GraphQLSchema schema() {
|
||||
SchemaParser schemaParser = new SchemaParser();
|
||||
SchemaGenerator schemaGenerator = new SchemaGenerator();
|
||||
|
||||
TypeDefinitionRegistry typeRegistry = new TypeDefinitionRegistry();
|
||||
typeRegistry.merge(schemaParser.parse(loadSchema("common.graphqls")));
|
||||
typeRegistry.merge(schemaParser.parse(loadSchema("trace.graphqls")));
|
||||
typeRegistry.merge(schemaParser.parse(loadSchema("overview-layer.graphqls")));
|
||||
RuntimeWiring wiring = buildRuntimeWiring();
|
||||
return schemaGenerator.makeExecutableSchema(typeRegistry, wiring);
|
||||
}
|
||||
|
||||
private File loadSchema(final String s) {
|
||||
return new File(GraphQLInitializer.class.getClassLoader().getResource("ui-graphql/" + s).getFile());
|
||||
}
|
||||
|
||||
private RuntimeWiring buildRuntimeWiring() {
|
||||
WiringFactory dynamicWiringFactory = new WiringFactory() {
|
||||
@Override
|
||||
public boolean providesTypeResolver(final InterfaceWiringEnvironment environment) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeResolver getTypeResolver(final InterfaceWiringEnvironment environment) {
|
||||
return env -> GraphQLObjectType.newObject().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean providesDataFetcher(final FieldWiringEnvironment environment) {
|
||||
logger.info("data fetcher: {},{}", environment.getFieldDefinition(), environment.getParentType());
|
||||
return false;
|
||||
}
|
||||
};
|
||||
return RuntimeWiring.newRuntimeWiring()
|
||||
.wiringFactory(dynamicWiringFactory).build();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* 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.ui.protocol;
|
||||
|
||||
import graphql.schema.idl.EchoingWiringFactory;
|
||||
import graphql.schema.idl.RuntimeWiring;
|
||||
import graphql.schema.idl.SchemaGenerator;
|
||||
import graphql.schema.idl.SchemaParser;
|
||||
import graphql.schema.idl.TypeDefinitionRegistry;
|
||||
import java.io.File;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class GraphQLScriptTest {
|
||||
|
||||
@Test
|
||||
public void assertScriptFormat() {
|
||||
SchemaParser schemaParser = new SchemaParser();
|
||||
SchemaGenerator schemaGenerator = new SchemaGenerator();
|
||||
|
||||
TypeDefinitionRegistry typeRegistry = new TypeDefinitionRegistry();
|
||||
typeRegistry.merge(schemaParser.parse(loadSchema("common.graphqls")));
|
||||
typeRegistry.merge(schemaParser.parse(loadSchema("trace.graphqls")));
|
||||
typeRegistry.merge(schemaParser.parse(loadSchema("overview-layer.graphqls")));
|
||||
RuntimeWiring wiring = buildRuntimeWiring();
|
||||
assertThat(schemaGenerator.makeExecutableSchema(typeRegistry, wiring).getAllTypesAsList().size(), is(32));
|
||||
}
|
||||
|
||||
private File loadSchema(final String s) {
|
||||
return new File(GraphQLScriptTest.class.getClassLoader().getResource("ui-graphql/" + s).getFile());
|
||||
}
|
||||
|
||||
private RuntimeWiring buildRuntimeWiring() {
|
||||
return RuntimeWiring.newRuntimeWiring().wiringFactory(new EchoingWiringFactory()).build();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue