Skip to content

Commit 02e0ef7

Browse files
authored
Merge pull request #21 from graphql-java/spring-boot-3-update
Update tutorial code for Spring Boot 3
2 parents cfa9dea + 330d902 commit 02e0ef7

13 files changed

Lines changed: 79 additions & 77 deletions

File tree

.gitignore

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
HELP.md
12
.gradle
2-
/build/
3+
build/
34
!gradle/wrapper/gradle-wrapper.jar
5+
!**/src/main/**/build/
6+
!**/src/test/**/build/
47

58
### STS ###
69
.apt_generated
@@ -10,17 +13,25 @@
1013
.settings
1114
.springBeans
1215
.sts4-cache
16+
bin/
17+
!**/src/main/**/bin/
18+
!**/src/test/**/bin/
1319

1420
### IntelliJ IDEA ###
1521
.idea
1622
*.iws
1723
*.iml
1824
*.ipr
19-
/out/
25+
out/
26+
!**/src/main/**/out/
27+
!**/src/test/**/out/
2028

2129
### NetBeans ###
2230
/nbproject/private/
2331
/nbbuild/
2432
/dist/
2533
/nbdist/
26-
/.nb-gradle/
34+
/.nb-gradle/
35+
36+
### VS Code ###
37+
.vscode/

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 GraphQL Java
3+
Copyright (c) 2024 GraphQL Java
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Book details example
1+
# Book details tutorial example
22

3-
4-
This is the source code for the "Getting started with GraphQL Java and Spring Boot" which
5-
is available here: https://www.graphql-java.com/tutorials/getting-started-with-spring-boot/
3+
This repository contains the source code for the tutorial "Getting started with GraphQL Java and Spring Boot" which is available here: https://www.graphql-java.com/tutorials/getting-started-with-spring-boot/

build.gradle

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
plugins {
2-
id 'org.springframework.boot' version '2.7.1'
3-
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
42
id 'java'
3+
id 'org.springframework.boot' version '3.2.1'
4+
id 'io.spring.dependency-management' version '1.1.4'
55
}
66

7-
group = 'com.graphql-java.tutorial'
7+
group = 'com.graphqljava.tutorial'
88
version = '0.0.1-SNAPSHOT'
9-
sourceCompatibility = '17'
9+
10+
java {
11+
sourceCompatibility = '17'
12+
}
1013

1114
repositories {
1215
mavenCentral()

gradle/wrapper/gradle-wrapper.jar

-16 KB
Binary file not shown.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

gradlew

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

gradlew.bat

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

src/main/java/com/graphqljava/tutorial/bookDetails/Author.java

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,16 @@
33
import java.util.Arrays;
44
import java.util.List;
55

6-
public class Author {
7-
private String id;
8-
private String firstName;
9-
private String lastName;
10-
11-
public Author(String id, String firstName, String lastName) {
12-
this.id = id;
13-
this.firstName = firstName;
14-
this.lastName = lastName;
15-
}
6+
record Author(String id, String firstName, String lastName) {
167

178
private static List<Author> authors = Arrays.asList(
18-
new Author("author-1", "Joanne", "Rowling"),
19-
new Author("author-2", "Herman", "Melville"),
20-
new Author("author-3", "Anne", "Rice")
9+
new Author("author-1", "Joanne", "Rowling"),
10+
new Author("author-2", "Herman", "Melville"),
11+
new Author("author-3", "Anne", "Rice")
2112
);
2213

2314
public static Author getById(String id) {
24-
return authors.stream().filter(author -> author.getId().equals(id)).findFirst().orElse(null);
15+
return authors.stream().filter(author -> author.id().equals(id)).findFirst().orElse(null);
2516
}
2617

27-
public String getId() {
28-
return id;
29-
}
3018
}

src/main/java/com/graphqljava/tutorial/bookDetails/Book.java

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,16 @@
33
import java.util.Arrays;
44
import java.util.List;
55

6-
public class Book {
7-
8-
private String id;
9-
private String name;
10-
private int pageCount;
11-
private String authorId;
12-
13-
public Book(String id, String name, int pageCount, String authorId) {
14-
this.id = id;
15-
this.name = name;
16-
this.pageCount = pageCount;
17-
this.authorId = authorId;
18-
}
6+
record Book(String id, String name, int pageCount, String authorId) {
197

208
private static List<Book> books = Arrays.asList(
21-
new Book("book-1", "Harry Potter and the Philosopher's Stone", 223, "author-1"),
22-
new Book("book-2", "Moby Dick", 635, "author-2"),
23-
new Book("book-3", "Interview with the vampire", 371, "author-3")
9+
new Book("book-1", "Harry Potter and the Philosopher's Stone", 223, "author-1"),
10+
new Book("book-2", "Moby Dick", 635, "author-2"),
11+
new Book("book-3", "Interview with the vampire", 371, "author-3")
2412
);
2513

2614
public static Book getById(String id) {
27-
return books.stream().filter(book -> book.getId().equals(id)).findFirst().orElse(null);
15+
return books.stream().filter(book -> book.id().equals(id)).findFirst().orElse(null);
2816
}
2917

30-
public String getId() {
31-
return id;
32-
}
33-
34-
public String getAuthorId() {
35-
return authorId;
36-
}
3718
}

0 commit comments

Comments
 (0)