Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 401b626

Browse files
committed
Converted dataloader example to gradle and bumped graphql-java version
1 parent 6c0683b commit 401b626

File tree

6 files changed

+42
-105
lines changed

6 files changed

+42
-105
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
sourceCompatibility = 1.8
6+
7+
repositories {
8+
mavenCentral()
9+
}
10+
11+
dependencies {
12+
compile("org.springframework.boot:spring-boot-starter-web:$LIB_SPRING_BOOT_VER")
13+
compile(project(":graphql-spring-boot-starter"))
14+
compile(project(":graphiql-spring-boot-starter"))
15+
16+
compile "com.graphql-java-kickstart:graphql-java-tools:$LIB_GRAPHQL_JAVA_TOOLS_VER"
17+
18+
testCompile "org.springframework.boot:spring-boot-starter-test:$LIB_SPRING_BOOT_VER"
19+
testCompile(project(":graphql-spring-boot-starter-test"))
20+
}
21+
22+
jar.enabled = false
23+
uploadArchives.enabled = false
24+
bintrayUpload.enabled = false
25+
install.enabled = false

example-request-scoped-dataloader/pom.xml

Lines changed: 0 additions & 92 deletions
This file was deleted.

example-request-scoped-dataloader/src/main/java/graphql/servlet/examples/dataloader/requestscope/CustomGraphQLContextBuilder.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import org.springframework.stereotype.Component;
88

99
import javax.servlet.http.HttpServletRequest;
10+
import javax.servlet.http.HttpServletResponse;
11+
import javax.websocket.Session;
1012
import javax.websocket.server.HandshakeRequest;
1113
import java.util.concurrent.CompletableFuture;
1214

@@ -20,8 +22,8 @@ public CustomGraphQLContextBuilder(CustomerRepository customerRepository) {
2022
}
2123

2224
@Override
23-
public GraphQLContext build(HttpServletRequest req) {
24-
GraphQLContext context = new GraphQLContext(req);
25+
public GraphQLContext build(HttpServletRequest req, HttpServletResponse response) {
26+
GraphQLContext context = new GraphQLContext(req, response);
2527
context.setDataLoaderRegistry(buildDataLoaderRegistry());
2628

2729
return context;
@@ -36,8 +38,8 @@ public GraphQLContext build() {
3638
}
3739

3840
@Override
39-
public GraphQLContext build(HandshakeRequest request) {
40-
GraphQLContext context = new GraphQLContext(request);
41+
public GraphQLContext build(Session session, HandshakeRequest request) {
42+
GraphQLContext context = new GraphQLContext(session, request);
4143
context.setDataLoaderRegistry(buildDataLoaderRegistry());
4244

4345
return context;
@@ -51,4 +53,4 @@ private DataLoaderRegistry buildDataLoaderRegistry() {
5153
customerRepository.getUserNamesForIds(customerIds))));
5254
return dataLoaderRegistry;
5355
}
54-
}
56+
}

example-request-scoped-dataloader/src/main/java/graphql/servlet/examples/dataloader/requestscope/CustomerRepository.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ public class CustomerRepository {
1313
private final Map<Integer, String> data;
1414

1515
private CustomerRepository() {
16-
data = new HashMap<Integer, String>();
17-
data.put(Integer.valueOf(101), "Customer Name 1");
18-
data.put(Integer.valueOf(102), "Customer Name 2");
19-
data.put(Integer.valueOf(103), "Customer Name 3");
20-
data.put(Integer.valueOf(104), "Customer Name 4");
21-
data.put(Integer.valueOf(105), "Customer Name 5");
22-
data.put(Integer.valueOf(106), "Customer Name 6");
16+
data = new HashMap<>();
17+
data.put(101, "Customer Name 1");
18+
data.put(102, "Customer Name 2");
19+
data.put(103, "Customer Name 3");
20+
data.put(104, "Customer Name 4");
21+
data.put(105, "Customer Name 5");
22+
data.put(106, "Customer Name 6");
2323
}
2424

2525
public List getUserNamesForIds(List<Integer> customerIds) {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ TARGET_COMPATIBILITY = 1.8
3636

3737
###
3838

39-
LIB_GRAPHQL_JAVA_VER = 9.2
39+
LIB_GRAPHQL_JAVA_VER = 11.0
4040
LIB_JUNIT_VER = 4.12
4141
LIB_SPRING_CORE_VER = 5.0.4.RELEASE
4242
LIB_SPRING_BOOT_VER = 2.0.5.RELEASE

settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ include ":example"
3232
include ":example-spring-common"
3333
include ':example-graphql-tools'
3434
include ':example-graphql-subscription'
35+
include ':example-request-scoped-dataloader'
36+
3537
include ':graphql-spring-boot-test'
3638
include ':graphql-spring-boot-test-autoconfigure'
3739

0 commit comments

Comments
 (0)