1.创建Springboot工程
2.引入依赖
我看很多demo,引用的依赖,artifactId
都是graphql-spring-boot-starter
,但是groupId
不同。
第一种:groupId
是com.graphql-java-kickstart
<!-- GraphQL -->
<dependency>
<groupId>com.graphql-java-kickstart</groupId>
<artifactId>graphql-spring-boot-starter</artifactId>
<version>${graphql-starter.version}</version>
</dependency>
<dependency>
<groupId>com.graphql-java-kickstart</groupId>
<artifactId>graphiql-spring-boot-starter</artifactId>
<version>${graphql-starter.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.graphql-java-kickstart</groupId>
<artifactId>graphql-spring-boot-starter-test</artifactId>
<version>${graphql-starter.version}</version>
<scope>test</scope>
</dependency>
第二种:groupId
是com.graphql-java
<!-- https://mvnrepository.com/artifact/com.graphql-java/graphql-spring-boot-starter -->
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-spring-boot-starter</artifactId>
<version>5.0.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.graphql-java/graphiql-spring-boot-starter -->
<!-- 图形化工具便于调式 -->
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphiql-spring-boot-starter</artifactId>
<version>5.0.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.graphql-java/graphql-java-tools -->
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-tools</artifactId>
<version>5.2.4</version>
</dependency>
百度了很多文档,自己项目中用的第二种
3.graphiql简介
graphiql, 它是graphql服务内置的一个编辑器, 将graphql接口文档化, 同时提供便捷调用的能力
浏览器可以直接访问http://localhost:8080/graphiql
进入调试页面
下面这个属性,默认是true
,表示是否开启graphiql
graphiql.enabled=false