Skip to content

Commit 508527f

Browse files
authored
Update spring-graphql-web example to use Books entity model (#403)
* Update spring-graphql-web to use books entity model * Apply prettier formatting
1 parent 836a0be commit 508527f

File tree

4 files changed

+7
-117
lines changed

4 files changed

+7
-117
lines changed

examples/spring-graphql-web/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</dependency>
3535
<dependency>
3636
<groupId>com.introproventures</groupId>
37-
<artifactId>graphql-jpa-query-test-model-starwars</artifactId>
37+
<artifactId>graphql-jpa-query-test-model-books</artifactId>
3838
</dependency>
3939
<dependency>
4040
<groupId>com.h2database</groupId>

examples/spring-graphql-web/src/main/java/com/introproventures/graphql/jpa/query/example/Application.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
package com.introproventures.graphql.jpa.query.example;
1717

1818
import com.introproventures.graphql.jpa.query.autoconfigure.EnableGraphQLJpaQuerySchema;
19-
import com.introproventures.graphql.jpa.query.schema.model.starwars.Character;
19+
import com.introproventures.graphql.jpa.query.schema.model.book.Book;
2020
import org.springframework.boot.SpringApplication;
2121
import org.springframework.boot.autoconfigure.SpringBootApplication;
22-
import org.springframework.context.annotation.Configuration;
2322

2423
/**
2524
* GraphQL JPA Query Example with Spring Boot Autoconfiguration
@@ -30,13 +29,10 @@
3029
*
3130
*/
3231
@SpringBootApplication
32+
@EnableGraphQLJpaQuerySchema(basePackageClasses = Book.class)
3333
public class Application {
3434

3535
public static void main(String[] args) {
3636
SpringApplication.run(Application.class, args);
3737
}
38-
39-
@Configuration
40-
@EnableGraphQLJpaQuerySchema(basePackageClasses = Character.class)
41-
static class StarwarsJpaModelConfiguration {}
4238
}

examples/spring-graphql-web/src/main/resources/application.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ spring:
77
h2:
88
console.enabled: true
99
datasource:
10-
url: jdbc:h2:mem:starwars
10+
url: jdbc:h2:mem:data
11+
sql:
12+
init:
13+
data-locations: classpath:books.sql
1114
graphql:
1215
schema:
1316
printer:
Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +0,0 @@
1-
-- Insert Code Lists
2-
insert into code_list (id, type, code, description, sequence, active, parent_id) values
3-
(0, 'org.crygier.graphql.model.starwars.Gender', 'Male', 'Male', 1, true, null),
4-
(1, 'org.crygier.graphql.model.starwars.Gender', 'Female', 'Female', 2, true, null);
5-
6-
-- Insert Droid Functions
7-
insert into droid_function(id, function) values
8-
( '1000', 'Protocol'),
9-
( '1001', 'Astromech');
10-
11-
-- Insert Droids
12-
insert into character (id, name, primary_function, dtype) values
13-
('2000', 'C-3PO', '1000', 'Droid'),
14-
('2001', 'R2-D2', '1001', 'Droid');
15-
16-
-- Insert Humans
17-
insert into character (id, name, home_planet, favorite_droid_id, dtype, gender_code_id) values
18-
('1000', 'Luke Skywalker', 'Tatooine', '2000', 'Human', 0),
19-
('1001', 'Darth Vader', 'Tatooine', '2001', 'Human', 0),
20-
('1002', 'Han Solo', NULL, NULL, 'Human', 0),
21-
('1003', 'Leia Organa', 'Alderaan', NULL, 'Human', 1),
22-
('1004', 'Wilhuff Tarkin', NULL, NULL, 'Human', 0);
23-
24-
-- Luke's friends
25-
insert into character_friends (source_id, friend_id) values
26-
('1000', '1002'),
27-
('1000', '1003'),
28-
('1000', '2000'),
29-
('1000', '2001');
30-
31-
-- Luke Appears in
32-
insert into character_appears_in (character_id, appears_in) values
33-
('1000', 3),
34-
('1000', 4),
35-
('1000', 5),
36-
('1000', 6);
37-
38-
-- Vader's friends
39-
insert into character_friends (source_id, friend_id) values
40-
('1001', '1004');
41-
42-
-- Vader Appears in
43-
insert into character_appears_in (character_id, appears_in) values
44-
('1001', 3),
45-
('1001', 4),
46-
('1001', 5);
47-
48-
-- Solo's friends
49-
insert into character_friends (source_id, friend_id) values
50-
('1002', '1000'),
51-
('1002', '1003'),
52-
('1002', '2001');
53-
54-
-- Solo Appears in
55-
insert into character_appears_in (character_id, appears_in) values
56-
('1002', 3),
57-
('1002', 4),
58-
('1002', 5),
59-
('1002', 6);
60-
61-
-- Leia's friends
62-
insert into character_friends (source_id, friend_id) values
63-
('1003', '1000'),
64-
('1003', '1002'),
65-
('1003', '2000'),
66-
('1003', '2001');
67-
68-
-- Leia Appears in
69-
insert into character_appears_in (character_id, appears_in) values
70-
('1003', 3),
71-
('1003', 4),
72-
('1003', 5),
73-
('1003', 6);
74-
75-
-- Wilhuff's friends
76-
insert into character_friends (source_id, friend_id) values
77-
('1004', '1001');
78-
79-
-- Wilhuff Appears in
80-
insert into character_appears_in (character_id, appears_in) values
81-
('1004', 3);
82-
83-
-- C3PO's friends
84-
insert into character_friends (source_id, friend_id) values
85-
('2000', '1000'),
86-
('2000', '1002'),
87-
('2000', '1003'),
88-
('2000', '2001');
89-
90-
-- C3PO Appears in
91-
insert into character_appears_in (character_id, appears_in) values
92-
('2000', 3),
93-
('2000', 4),
94-
('2000', 5),
95-
('2000', 6);
96-
97-
-- R2's friends
98-
insert into character_friends (source_id, friend_id) values
99-
('2001', '1000'),
100-
('2001', '1002'),
101-
('2001', '1003');
102-
103-
-- R2 Appears in
104-
insert into character_appears_in (character_id, appears_in) values
105-
('2001', 3),
106-
('2001', 4),
107-
('2001', 5),
108-
('2001', 6);
109-

0 commit comments

Comments
 (0)