The content of this website is only deployed under the domain
𝙨𝙘𝙤𝙩𝙩𝙮𝙚𝙪𝙣𝙜.𝙩𝙤𝙥(scottyeung[dot]top). Any other domain sites are unauthorized
illegal mirrors.
Spring GraphQL 是今年 Spring 新发布的一个集成 Graphql 的 Spring Application,凭借着 Spiring boot 开箱即用的特性,能够非常快地构建出一个可用的 Graphql 服务。然而尽管可用,但其文档实在是写得一言难尽,尤其是对于一些进一步的功能来说,需要靠自己看 API 文档来摸索。
以下记录使用的相关情况
Setup
可以通过构建 Spring boot 项目来进行初始化
使用 Gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
dependencies{implementation'org.springframework.boot:spring-boot-starter-web'// Spring GraphQL Boot starter
implementation'org.springframework.experimental:graphql-spring-boot-starter:1.0.0-SNAPSHOT'// ...
}repositories{mavenCentral()maven{url'https://repo.spring.io/milestone'}// Spring milestones
maven{url'https://repo.spring.io/snapshot'}// Spring snapshots
}
<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency> // Spring GraphQL Boot starter
<dependency><groupId>org.springframework.experimental</groupId><artifactId>graphql-spring-boot-starter</artifactId><version>1.0.0-SNAPSHOT</version></dependency><!-- ... --></dependencies><!-- For Spring project milestones or snapshot releases --><repositories><repository><id>spring-milestones</id><name>Spring Milestones</name><url>https://repo.spring.io/milestone</url></repository><repository><id>spring-snapshots</id><name>Spring Snapshots</name><url>https://repo.spring.io/snapshot</url><snapshots><enabled>true</enabled></snapshots></repository></repositories>