Skip to content

Commit 3094a6d

Browse files
authored
fix: spring.graphql.jpa.query.path must be specified (#94)
* fix: remove duplicate graphql-jpa-query-autoconfigure dependency * fix: stop tracking .classpath * fix: add spring-boot-configuration-processor dependency * fix: missing graphql.path property in starters * fix: add missing Starwars entity models
1 parent 6edb557 commit 3094a6d

File tree

12 files changed

+266
-66
lines changed

12 files changed

+266
-66
lines changed

graphql-jpa-query-autoconfigure/.classpath

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

graphql-jpa-query-autoconfigure/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
<artifactId>hibernate-validator</artifactId>
3131
<scope>test</scope>
3232
</dependency>
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-configuration-processor</artifactId>
36+
<optional>true</optional>
37+
</dependency>
3338
</dependencies>
3439

3540
</project>

graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLJpaQueryProperties.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,9 @@
1818
import javax.validation.constraints.NotEmpty;
1919

2020
import org.springframework.boot.context.properties.ConfigurationProperties;
21-
import org.springframework.context.annotation.PropertySource;
22-
import org.springframework.context.annotation.PropertySources;
2321
import org.springframework.validation.annotation.Validated;
2422

2523
@ConfigurationProperties(prefix="spring.graphql.jpa.query")
26-
@PropertySources(value= {
27-
@PropertySource("classpath:/com/introproventures/graphql/jpa/query/boot/autoconfigure/default.properties"),
28-
@PropertySource(value = "classpath:graphql-jpa-autoconfigure.properties", ignoreResourceNotFound = true)
29-
})
3024
@Validated
3125
public class GraphQLJpaQueryProperties {
3226

graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfiguration.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import org.springframework.boot.context.properties.EnableConfigurationProperties;
1010
import org.springframework.context.annotation.Bean;
1111
import org.springframework.context.annotation.Configuration;
12+
import org.springframework.context.annotation.PropertySource;
13+
import org.springframework.context.annotation.PropertySources;
1214
import org.springframework.util.CollectionUtils;
1315

1416
import graphql.GraphQL;
@@ -17,6 +19,10 @@
1719
@Configuration
1820
@ConditionalOnClass(GraphQL.class)
1921
@EnableConfigurationProperties(GraphQLJpaQueryProperties.class)
22+
@PropertySources(value= {
23+
@PropertySource("classpath:com/introproventures/graphql/jpa/query/boot/autoconfigure/default.properties"),
24+
@PropertySource(value = "classpath:graphql-jpa-autoconfigure.properties", ignoreResourceNotFound = true)
25+
})
2026
public class GraphQLSchemaAutoConfiguration {
2127

2228
private final List<GraphQLSchemaConfigurer> graphQLSchemaConfigurers = new ArrayList<>();

graphql-jpa-query-example-merge/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727
<artifactId>graphql-jpa-query-schema</artifactId>
2828
</dependency>
2929

30-
<dependency>
31-
<groupId>com.introproventures</groupId>
32-
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
33-
</dependency>
34-
3530
<dependency>
3631
<groupId>com.introproventures</groupId>
3732
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.introproventures.graphql.jpa.query.example;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
7+
import org.springframework.test.context.junit4.SpringRunner;
8+
9+
@RunWith(SpringRunner.class)
10+
@SpringBootTest(webEnvironment=WebEnvironment.DEFINED_PORT)
11+
public class ApplicationTest {
12+
13+
@Test
14+
public void contextLoads() {
15+
// success
16+
}
17+
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright 2017 IntroPro Ventures Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.introproventures.graphql.jpa.query.example.starwars;
18+
19+
import java.util.Set;
20+
21+
import javax.persistence.ElementCollection;
22+
import javax.persistence.Entity;
23+
import javax.persistence.EnumType;
24+
import javax.persistence.Enumerated;
25+
import javax.persistence.Id;
26+
import javax.persistence.JoinColumn;
27+
import javax.persistence.JoinTable;
28+
import javax.persistence.ManyToMany;
29+
import javax.persistence.OrderBy;
30+
31+
import com.introproventures.graphql.jpa.query.annotation.GraphQLDescription;
32+
import lombok.EqualsAndHashCode;
33+
import lombok.Getter;
34+
import lombok.Setter;
35+
import lombok.ToString;
36+
37+
@Entity
38+
@GraphQLDescription("Abstract representation of an entity in the Star Wars Universe")
39+
@Getter
40+
@Setter
41+
@ToString
42+
@EqualsAndHashCode(exclude={"appearsIn","friends"}) // Fixes NPE in Hibernate when initializing loaded collections #1
43+
public abstract class Character {
44+
45+
@Id
46+
@GraphQLDescription("Primary Key for the Character Class")
47+
String id;
48+
49+
@GraphQLDescription("Name of the character")
50+
String name;
51+
52+
@GraphQLDescription("Who are the known friends to this character")
53+
@ManyToMany
54+
@JoinTable(name="character_friends",
55+
joinColumns=@JoinColumn(name="source_id", referencedColumnName="id"),
56+
inverseJoinColumns=@JoinColumn(name="friend_id", referencedColumnName="id"))
57+
Set<Character> friends;
58+
59+
@GraphQLDescription("What Star Wars episodes does this character appear in")
60+
@ElementCollection(targetClass = Episode.class)
61+
@Enumerated(EnumType.ORDINAL)
62+
@OrderBy
63+
Set<Episode> appearsIn;
64+
65+
Character() {}
66+
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2017 IntroPro Ventures Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.introproventures.graphql.jpa.query.example.starwars;
18+
19+
import javax.persistence.Entity;
20+
import javax.persistence.Id;
21+
import javax.persistence.JoinColumn;
22+
import javax.persistence.ManyToOne;
23+
24+
import com.introproventures.graphql.jpa.query.annotation.GraphQLDescription;
25+
import lombok.Data;
26+
27+
@Entity
28+
@GraphQLDescription("Database driven enumeration")
29+
@Data
30+
public class CodeList {
31+
32+
@Id
33+
@GraphQLDescription("Primary Key for the Code List Class")
34+
Long id;
35+
36+
String type;
37+
String code;
38+
Integer sequence;
39+
boolean active;
40+
String description;
41+
42+
@ManyToOne
43+
@JoinColumn(name = "parent_id")
44+
CodeList parent;
45+
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2017 IntroPro Ventures Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.introproventures.graphql.jpa.query.example.starwars;
18+
19+
import javax.persistence.Entity;
20+
21+
import com.introproventures.graphql.jpa.query.annotation.GraphQLDescription;
22+
23+
import lombok.Data;
24+
import lombok.EqualsAndHashCode;
25+
26+
@Entity
27+
@GraphQLDescription("Represents an electromechanical robot in the Star Wars Universe")
28+
@Data
29+
@EqualsAndHashCode(callSuper=true)
30+
public class Droid extends Character {
31+
32+
@GraphQLDescription("Documents the primary purpose this droid serves")
33+
String primaryFunction;
34+
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2017 IntroPro Ventures Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.introproventures.graphql.jpa.query.example.starwars;
18+
19+
public enum Episode {
20+
21+
PHANTOM_MENACE,
22+
ATTACK_OF_THE_CLONES,
23+
REVENGE_OF_THE_SITH,
24+
A_NEW_HOPE,
25+
EMPIRE_STRIKES_BACK,
26+
RETURN_OF_THE_JEDI,
27+
THE_FORCE_AWAKENS
28+
29+
}

0 commit comments

Comments
 (0)