Skip to content

Commit e5e3b95

Browse files
authored
Merge pull request #2 from graphql-java/spring-boot-integration
basic spring boot integration
2 parents 411a79e + b82b741 commit e5e3b95

16 files changed

Lines changed: 678 additions & 0 deletions

File tree

spring-boot-integration/.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.gradle
2+
/build/
3+
!gradle/wrapper/gradle-wrapper.jar
4+
5+
### STS ###
6+
.apt_generated
7+
.classpath
8+
.factorypath
9+
.project
10+
.settings
11+
.springBeans
12+
.sts4-cache
13+
14+
### IntelliJ IDEA ###
15+
.idea
16+
*.iws
17+
*.iml
18+
*.ipr
19+
/out/
20+
21+
### NetBeans ###
22+
/nbproject/private/
23+
/nbbuild/
24+
/dist/
25+
/nbdist/
26+
/.nb-gradle/

spring-boot-integration/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# GraphQL Java spring boot integration
2+
3+
A very simple example of how to integrate GraphQL Java with Spring boot.
4+
5+
To build the example code in this repository type:
6+
7+
```
8+
./gradlew build
9+
```
10+
11+
To run the example code type:
12+
13+
```
14+
./gradlew bootRun
15+
```
16+
17+
To access the example application, point your browser at:
18+
http://localhost:8080/
19+
20+
# Code Explanation
21+
22+
The actual Spring MVC Controller is `GraphQLController` which accepts GET and POST requests on `/graphql`.
23+
24+
It uses the `GraphQL` instance provided by `GraphQLProvider`.
25+
26+
The actual data is retrieved by the DataFetchers in `GraphQLDataFetchers`.
27+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
buildscript {
2+
ext {
3+
springBootVersion = '2.0.5.RELEASE'
4+
}
5+
repositories {
6+
mavenCentral()
7+
}
8+
dependencies {
9+
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
10+
}
11+
}
12+
13+
apply plugin: 'java'
14+
apply plugin: 'eclipse'
15+
apply plugin: 'org.springframework.boot'
16+
apply plugin: 'io.spring.dependency-management'
17+
18+
group = 'com.graphql-java.examples'
19+
version = '0.0.1-SNAPSHOT'
20+
sourceCompatibility = 1.8
21+
22+
repositories {
23+
mavenCentral()
24+
}
25+
26+
27+
dependencies {
28+
implementation('org.springframework.boot:spring-boot-starter-web')
29+
implementation('com.graphql-java:graphql-java:10.0')
30+
implementation('com.google.guava:guava:26.0-jre')
31+
testImplementation('org.springframework.boot:spring-boot-starter-test')
32+
}
53.4 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Sun Oct 07 10:24:43 AEDT 2018
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip

spring-boot-integration/gradlew

Lines changed: 172 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spring-boot-integration/gradlew.bat

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'spring-boot-integration'
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package graphql.examples.springboot;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class Application {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(Application.class, args);
11+
}
12+
}

0 commit comments

Comments
 (0)