Skip to content

Commit 034aca1

Browse files
authored
Merge pull request #2 from introproventures/master
merge master
2 parents 9e5e3e0 + 6edb557 commit 034aca1

File tree

30 files changed

+553
-217
lines changed

30 files changed

+553
-217
lines changed

CHANGELOG.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
# Change Log
22

3-
## 0.3.14-SNAPSHOT
3+
## 0.3.15-SNAPSHOT
4+
* fix: Configuration properties are ignored when merging bug (#88) [f838056](https://github.com/introproventures/graphql-jpa-query/commit/f838056009ca884d45e451b96a7a28dd8f9ea5a1)
5+
* fix: upgrade to Spring Boot 2.1.3.RELEASE (#87) [ee0aa6c](https://github.com/introproventures/graphql-jpa-query/commit/ee0aa6c9ad5fead0f5a15e2133460fdebb9a0724)
6+
* Refactor SchemaBuilder using Introspection (#86) [493f65d](https://github.com/introproventures/graphql-jpa-query/commit/493f65daa0e95d50a2ee8787af4444bcb365c2ed)
7+
* support calcs fields and functions (#85) [1cbf29c](https://github.com/introproventures/graphql-jpa-query/commit/1cbf29c21d845d75c291ec4bafd5e13b7b27b21c)
8+
* feat: add JPA @EmbeddedId support (#84) [0def68d](https://github.com/introproventures/graphql-jpa-query/commit/0def68d42c817858a2d5248d10c4c1d13fcd8ad2)
9+
* Update README.md [ac75192](https://github.com/introproventures/graphql-jpa-query/commit/ac751922119f5f8159bcbf5d89069a584ade6a79)
10+
* Update README.md [4d783e2](https://github.com/introproventures/graphql-jpa-query/commit/4d783e25683b0847705b911dcad1289ebe1b47b8)
11+
* Update README.md [369e2b5](https://github.com/introproventures/graphql-jpa-query/commit/369e2b58964dbaa1d1dec4867f5524af6df948eb)
12+
* Update README.md [a553ca6](https://github.com/introproventures/graphql-jpa-query/commit/a553ca626b46c292cc1f4d6fa7947b5f8ad8e89c)
13+
* Update README.md [fe2b7ca](https://github.com/introproventures/graphql-jpa-query/commit/fe2b7ca8407f6421767e0c28ec7a40879c8f8fc7)
14+
* Update README.md [25b140e](https://github.com/introproventures/graphql-jpa-query/commit/25b140ecd2fd0185adf535bfeaa94592d65d298a)
15+
* Update README.md [8b16599](https://github.com/introproventures/graphql-jpa-query/commit/8b165996e872ee0872ed8c654461f2637332a7b1)
16+
* fix: Clean up application.yaml configurations [b672e43](https://github.com/introproventures/graphql-jpa-query/commit/b672e437d68435e08862dc97438f8ae198fc9b5e)
17+
* Update README.md [b83a22d](https://github.com/introproventures/graphql-jpa-query/commit/b83a22d3f82fd310f590364dc60a510e220094d8)
18+
* Update README.md [8111ee4](https://github.com/introproventures/graphql-jpa-query/commit/8111ee4e1fe130cf4f8a89677709d069fad1e36a)
19+
* Update README.md [f484e23](https://github.com/introproventures/graphql-jpa-query/commit/f484e2325cdf873cc5d65cd72a7d17053ddc2787)
20+
* feat: Created example to merge two JPA data sources into one schema (#79) [12caf3a](https://github.com/introproventures/graphql-jpa-query/commit/12caf3a8ad8cee64932d1cbc1fa955888ccd5e14)
21+
* Update README.md [ca18221](https://github.com/introproventures/graphql-jpa-query/commit/ca1822123c2e34fe7f50fe804a53f7367c841cda)
22+
* Update README.md [dfaa0ed](https://github.com/introproventures/graphql-jpa-query/commit/dfaa0ed4e26d92f469e3eba6fa3e3062e125313d)
423
* Extract graphql-jpa-query-web module from starter (#74) [8d72bbe](https://github.com/introproventures/graphql-jpa-query/commit/8d72bbee8d6aeb568604e7070d90c10657a766e4)
524
* fix: configure gitHub url [b0839ca](https://github.com/introproventures/graphql-jpa-query/commit/b0839ca427b8a05efd5d4819a1ec2ac1f3b7ad2b)
625
* fix: (version) update git-changelog-maven-plugin to 0.4.0 [7867ed4](https://github.com/introproventures/graphql-jpa-query/commit/7867ed417fb36f7d0d3e10b8f108397c1f816f53)

graphql-jpa-query-annotations/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.introproventures</groupId>
88
<artifactId>graphql-jpa-query-dependencies</artifactId>
9-
<version>0.3.14-SNAPSHOT</version>
9+
<version>0.3.15-SNAPSHOT</version>
1010
<relativePath>../graphql-jpa-query-dependencies</relativePath>
1111
</parent>
1212

graphql-jpa-query-autoconfigure/pom.xml

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>com.introproventures</groupId>
55
<artifactId>graphql-jpa-query-build</artifactId>
6-
<version>0.3.14-SNAPSHOT</version>
6+
<version>0.3.15-SNAPSHOT</version>
77
<relativePath>../graphql-jpa-query-build</relativePath>
88
</parent>
99
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
@@ -19,7 +19,17 @@
1919
<groupId>org.springframework.boot</groupId>
2020
<artifactId>spring-boot-autoconfigure</artifactId>
2121
</dependency>
22+
23+
<dependency>
24+
<groupId>javax.validation</groupId>
25+
<artifactId>validation-api</artifactId>
26+
</dependency>
2227

28+
<dependency>
29+
<groupId>org.hibernate.validator</groupId>
30+
<artifactId>hibernate-validator</artifactId>
31+
<scope>test</scope>
32+
</dependency>
2333
</dependencies>
2434

2535
</project>
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,20 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package com.introproventures.graphql.jpa.query.boot.autoconfigure;
16+
package com.introproventures.graphql.jpa.query.autoconfigure;
17+
18+
import javax.validation.constraints.NotEmpty;
1719

18-
import org.hibernate.validator.constraints.NotEmpty;
1920
import org.springframework.boot.context.properties.ConfigurationProperties;
21+
import org.springframework.context.annotation.PropertySource;
22+
import org.springframework.context.annotation.PropertySources;
2023
import org.springframework.validation.annotation.Validated;
2124

2225
@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+
})
2330
@Validated
2431
public class GraphQLJpaQueryProperties {
2532

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

+13-4
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,26 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6-
import graphql.GraphQL;
7-
import graphql.schema.GraphQLSchema;
86
import org.springframework.beans.factory.annotation.Autowired;
97
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
108
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
9+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
1110
import org.springframework.context.annotation.Bean;
1211
import org.springframework.context.annotation.Configuration;
1312
import org.springframework.util.CollectionUtils;
1413

14+
import graphql.GraphQL;
15+
import graphql.schema.GraphQLSchema;
16+
1517
@Configuration
1618
@ConditionalOnClass(GraphQL.class)
19+
@EnableConfigurationProperties(GraphQLJpaQueryProperties.class)
1720
public class GraphQLSchemaAutoConfiguration {
1821

1922
private final List<GraphQLSchemaConfigurer> graphQLSchemaConfigurers = new ArrayList<>();
23+
24+
@Autowired
25+
private GraphQLJpaQueryProperties properties;
2026

2127
@Autowired(required = true)
2228
public void setGraphQLSchemaConfigurers(List<GraphQLSchemaConfigurer> configurers) {
@@ -28,13 +34,16 @@ public void setGraphQLSchemaConfigurers(List<GraphQLSchemaConfigurer> configurer
2834
@Bean
2935
@ConditionalOnMissingBean(GraphQLSchema.class)
3036
public GraphQLSchemaFactoryBean graphQLSchemaFactoryBean() {
31-
GraphQLShemaRegistration graphQLShemaRegistration = new GraphQLShemaRegistration();
37+
GraphQLShemaRegistrationImpl graphQLShemaRegistration = new GraphQLShemaRegistrationImpl();
3238

3339
for (GraphQLSchemaConfigurer configurer : graphQLSchemaConfigurers) {
3440
configurer.configure(graphQLShemaRegistration);
3541
}
3642

37-
return new GraphQLSchemaFactoryBean(graphQLShemaRegistration.getManagedGraphQLSchemas());
43+
return new GraphQLSchemaFactoryBean(graphQLShemaRegistration.getManagedGraphQLSchemas())
44+
.setQueryName(properties.getName())
45+
.setQueryDescription(properties.getDescription());
46+
3847

3948
};
4049

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

+69-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,34 @@
55
import java.util.stream.Collectors;
66
import java.util.stream.Stream;
77

8+
import org.springframework.beans.factory.config.AbstractFactoryBean;
9+
810
import graphql.schema.GraphQLFieldDefinition;
911
import graphql.schema.GraphQLObjectType;
1012
import graphql.schema.GraphQLSchema;
11-
import org.springframework.beans.factory.config.AbstractFactoryBean;
1213

1314
public class GraphQLSchemaFactoryBean extends AbstractFactoryBean<GraphQLSchema>{
1415

15-
private final GraphQLSchema[] managedGraphQLSchemas;
16+
private static final String QUERY_NAME = "Query";
17+
private static final String QUERY_DESCRIPTION = "";
18+
private static final String SUBSCRIPTION_NAME = "Subscription";
19+
private static final String SUBSCRIPTION_DESCRIPTION = "";
20+
private static final String MUTATION_NAME = "Mutation";
21+
private static final String MUTATION_DESCRIPTION = "";
22+
23+
24+
private final GraphQLSchema[] managedGraphQLSchemas;
25+
26+
private String queryName = QUERY_NAME;
27+
private String queryDescription = QUERY_DESCRIPTION;
28+
29+
private String subscriptionName = SUBSCRIPTION_NAME;
30+
private String subscriptionDescription = SUBSCRIPTION_DESCRIPTION;
1631

32+
private String mutationName = MUTATION_NAME;
33+
private String mutationDescription = MUTATION_DESCRIPTION;
34+
35+
1736
public GraphQLSchemaFactoryBean(GraphQLSchema[] managedGraphQLSchemas) {
1837
this.managedGraphQLSchemas = managedGraphQLSchemas;
1938
}
@@ -46,13 +65,22 @@ protected GraphQLSchema createInstance() throws Exception {
4665
.collect(Collectors.toList());
4766

4867
if(!mutations.isEmpty())
49-
schemaBuilder.mutation(GraphQLObjectType.newObject().name("Mutation").fields(mutations));
68+
schemaBuilder.mutation(GraphQLObjectType.newObject()
69+
.name(this.mutationName)
70+
.description(this.mutationDescription)
71+
.fields(mutations));
5072

5173
if(!queries.isEmpty())
52-
schemaBuilder.query(GraphQLObjectType.newObject().name("Query").fields(queries));
74+
schemaBuilder.query(GraphQLObjectType.newObject()
75+
.name(this.queryName)
76+
.description(this.queryDescription)
77+
.fields(queries));
5378

5479
if(!subscriptions.isEmpty())
55-
schemaBuilder.subscription(GraphQLObjectType.newObject().name("Subscription").fields(subscriptions));
80+
schemaBuilder.subscription(GraphQLObjectType.newObject()
81+
.name(this.subscriptionName)
82+
.description(this.subscriptionDescription)
83+
.fields(subscriptions));
5684

5785
return schemaBuilder.build();
5886
}
@@ -62,4 +90,40 @@ public Class<?> getObjectType() {
6290
return GraphQLSchema.class;
6391
}
6492

93+
public GraphQLSchemaFactoryBean setQueryName(String name) {
94+
this.queryName = name;
95+
96+
return this;
97+
}
98+
99+
public GraphQLSchemaFactoryBean setQueryDescription(String description) {
100+
this.queryDescription = description;
101+
102+
return this;
103+
}
104+
105+
public GraphQLSchemaFactoryBean setSubscriptionName(String subscriptionName) {
106+
this.subscriptionName = subscriptionName;
107+
108+
return this;
109+
}
110+
111+
public GraphQLSchemaFactoryBean setSubscriptionDescription(String subscriptionDescription) {
112+
this.subscriptionDescription = subscriptionDescription;
113+
114+
return this;
115+
}
116+
117+
public GraphQLSchemaFactoryBean setMutationName(String mutationName) {
118+
this.mutationName = mutationName;
119+
120+
return this;
121+
}
122+
123+
public GraphQLSchemaFactoryBean setMutationDescription(String mutationDescription) {
124+
this.mutationDescription = mutationDescription;
125+
126+
return this;
127+
}
128+
65129
}
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
package com.introproventures.graphql.jpa.query.autoconfigure;
22

3-
import java.util.LinkedHashSet;
4-
import java.util.Set;
5-
63
import graphql.schema.GraphQLSchema;
74

8-
public class GraphQLShemaRegistration {
9-
10-
Set<GraphQLSchema> managedGraphQLSchemas = new LinkedHashSet<GraphQLSchema>();
5+
public interface GraphQLShemaRegistration {
116

12-
public void register(GraphQLSchema graphQLSchema) {
13-
managedGraphQLSchemas.add(graphQLSchema);
14-
}
7+
public void register(GraphQLSchema graphQLSchema);
158

16-
public GraphQLSchema[] getManagedGraphQLSchemas() {
17-
return managedGraphQLSchemas.toArray(new GraphQLSchema[] {});
18-
}
199

2010
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.introproventures.graphql.jpa.query.autoconfigure;
2+
3+
import java.util.LinkedHashSet;
4+
import java.util.Set;
5+
6+
import graphql.schema.GraphQLSchema;
7+
8+
public class GraphQLShemaRegistrationImpl implements GraphQLShemaRegistration {
9+
10+
Set<GraphQLSchema> managedGraphQLSchemas = new LinkedHashSet<GraphQLSchema>();
11+
12+
public void register(GraphQLSchema graphQLSchema) {
13+
managedGraphQLSchemas.add(graphQLSchema);
14+
}
15+
16+
public GraphQLSchema[] getManagedGraphQLSchemas() {
17+
return managedGraphQLSchemas.toArray(new GraphQLSchema[] {});
18+
}
19+
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
spring.graphql.jpa.query.name=Query
2+
spring.graphql.jpa.query.description=
3+
spring.graphql.jpa.query.enabled=true
4+
spring.graphql.jpa.query.path=/graphql

graphql-jpa-query-autoconfigure/src/test/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfigurationTest.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44

55
import java.util.Map;
66

7-
import graphql.GraphQL;
8-
import graphql.Scalars;
9-
import graphql.schema.GraphQLFieldDefinition;
10-
import graphql.schema.GraphQLObjectType;
11-
import graphql.schema.GraphQLSchema;
127
import org.junit.Test;
138
import org.junit.runner.RunWith;
149
import org.springframework.beans.factory.annotation.Autowired;
@@ -18,6 +13,12 @@
1813
import org.springframework.stereotype.Component;
1914
import org.springframework.test.context.junit4.SpringRunner;
2015

16+
import graphql.GraphQL;
17+
import graphql.Scalars;
18+
import graphql.schema.GraphQLFieldDefinition;
19+
import graphql.schema.GraphQLObjectType;
20+
import graphql.schema.GraphQLSchema;
21+
2122
@RunWith(SpringRunner.class)
2223
@SpringBootTest(webEnvironment=WebEnvironment.NONE)
2324
public class GraphQLSchemaAutoConfigurationTest {
@@ -87,6 +88,11 @@ public void contextLoads() {
8788
// then
8889
assertThat(result.toString()).isEqualTo("{hello=world}");
8990
assertThat(result2.toString()).isEqualTo("{greet=hello world}");
91+
92+
assertThat(graphQLSchema.getQueryType())
93+
.extracting(GraphQLObjectType::getName, GraphQLObjectType::getDescription)
94+
.containsExactly("GraphQLBooks", "GraphQL Books Schema Description");
95+
9096
}
9197

9298

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
spring:
2+
jpa:
3+
hibernate.ddl-auto: create-drop
4+
show-sql: true
5+
h2:
6+
console.enabled: true
7+
8+
graphql:
9+
jpa:
10+
query:
11+
name: GraphQLBooks
12+
description: GraphQL Books Schema Description
13+
enabled: true
14+
path: /graphql

graphql-jpa-query-boot-starter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.introproventures</groupId>
99
<artifactId>graphql-jpa-query-build</artifactId>
10-
<version>0.3.14-SNAPSHOT</version>
10+
<version>0.3.15-SNAPSHOT</version>
1111
<relativePath>../graphql-jpa-query-build</relativePath>
1212
</parent>
1313

graphql-jpa-query-boot-starter/src/main/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/EnableGraphQLJpaQuery.java

-37
This file was deleted.

0 commit comments

Comments
 (0)