Skip to content

merge master #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
# Change Log

## 0.3.14-SNAPSHOT
## 0.3.15-SNAPSHOT
* fix: Configuration properties are ignored when merging bug (#88) [f838056](https://github.com/introproventures/graphql-jpa-query/commit/f838056009ca884d45e451b96a7a28dd8f9ea5a1)
* fix: upgrade to Spring Boot 2.1.3.RELEASE (#87) [ee0aa6c](https://github.com/introproventures/graphql-jpa-query/commit/ee0aa6c9ad5fead0f5a15e2133460fdebb9a0724)
* Refactor SchemaBuilder using Introspection (#86) [493f65d](https://github.com/introproventures/graphql-jpa-query/commit/493f65daa0e95d50a2ee8787af4444bcb365c2ed)
* support calcs fields and functions (#85) [1cbf29c](https://github.com/introproventures/graphql-jpa-query/commit/1cbf29c21d845d75c291ec4bafd5e13b7b27b21c)
* feat: add JPA @EmbeddedId support (#84) [0def68d](https://github.com/introproventures/graphql-jpa-query/commit/0def68d42c817858a2d5248d10c4c1d13fcd8ad2)
* Update README.md [ac75192](https://github.com/introproventures/graphql-jpa-query/commit/ac751922119f5f8159bcbf5d89069a584ade6a79)
* Update README.md [4d783e2](https://github.com/introproventures/graphql-jpa-query/commit/4d783e25683b0847705b911dcad1289ebe1b47b8)
* Update README.md [369e2b5](https://github.com/introproventures/graphql-jpa-query/commit/369e2b58964dbaa1d1dec4867f5524af6df948eb)
* Update README.md [a553ca6](https://github.com/introproventures/graphql-jpa-query/commit/a553ca626b46c292cc1f4d6fa7947b5f8ad8e89c)
* Update README.md [fe2b7ca](https://github.com/introproventures/graphql-jpa-query/commit/fe2b7ca8407f6421767e0c28ec7a40879c8f8fc7)
* Update README.md [25b140e](https://github.com/introproventures/graphql-jpa-query/commit/25b140ecd2fd0185adf535bfeaa94592d65d298a)
* Update README.md [8b16599](https://github.com/introproventures/graphql-jpa-query/commit/8b165996e872ee0872ed8c654461f2637332a7b1)
* fix: Clean up application.yaml configurations [b672e43](https://github.com/introproventures/graphql-jpa-query/commit/b672e437d68435e08862dc97438f8ae198fc9b5e)
* Update README.md [b83a22d](https://github.com/introproventures/graphql-jpa-query/commit/b83a22d3f82fd310f590364dc60a510e220094d8)
* Update README.md [8111ee4](https://github.com/introproventures/graphql-jpa-query/commit/8111ee4e1fe130cf4f8a89677709d069fad1e36a)
* Update README.md [f484e23](https://github.com/introproventures/graphql-jpa-query/commit/f484e2325cdf873cc5d65cd72a7d17053ddc2787)
* feat: Created example to merge two JPA data sources into one schema (#79) [12caf3a](https://github.com/introproventures/graphql-jpa-query/commit/12caf3a8ad8cee64932d1cbc1fa955888ccd5e14)
* Update README.md [ca18221](https://github.com/introproventures/graphql-jpa-query/commit/ca1822123c2e34fe7f50fe804a53f7367c841cda)
* Update README.md [dfaa0ed](https://github.com/introproventures/graphql-jpa-query/commit/dfaa0ed4e26d92f469e3eba6fa3e3062e125313d)
* Extract graphql-jpa-query-web module from starter (#74) [8d72bbe](https://github.com/introproventures/graphql-jpa-query/commit/8d72bbee8d6aeb568604e7070d90c10657a766e4)
* fix: configure gitHub url [b0839ca](https://github.com/introproventures/graphql-jpa-query/commit/b0839ca427b8a05efd5d4819a1ec2ac1f3b7ad2b)
* fix: (version) update git-changelog-maven-plugin to 0.4.0 [7867ed4](https://github.com/introproventures/graphql-jpa-query/commit/7867ed417fb36f7d0d3e10b8f108397c1f816f53)
Expand Down
2 changes: 1 addition & 1 deletion graphql-jpa-query-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-dependencies</artifactId>
<version>0.3.14-SNAPSHOT</version>
<version>0.3.15-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-dependencies</relativePath>
</parent>

Expand Down
12 changes: 11 additions & 1 deletion graphql-jpa-query-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.3.14-SNAPSHOT</version>
<version>0.3.15-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
Expand All @@ -19,7 +19,17 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>

<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>

<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.introproventures.graphql.jpa.query.boot.autoconfigure;
package com.introproventures.graphql.jpa.query.autoconfigure;

import javax.validation.constraints.NotEmpty;

import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.validation.annotation.Validated;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@
import java.util.ArrayList;
import java.util.List;

import graphql.GraphQL;
import graphql.schema.GraphQLSchema;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.CollectionUtils;

import graphql.GraphQL;
import graphql.schema.GraphQLSchema;

@Configuration
@ConditionalOnClass(GraphQL.class)
@EnableConfigurationProperties(GraphQLJpaQueryProperties.class)
public class GraphQLSchemaAutoConfiguration {

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

@Autowired
private GraphQLJpaQueryProperties properties;

@Autowired(required = true)
public void setGraphQLSchemaConfigurers(List<GraphQLSchemaConfigurer> configurers) {
Expand All @@ -28,13 +34,16 @@ public void setGraphQLSchemaConfigurers(List<GraphQLSchemaConfigurer> configurer
@Bean
@ConditionalOnMissingBean(GraphQLSchema.class)
public GraphQLSchemaFactoryBean graphQLSchemaFactoryBean() {
GraphQLShemaRegistration graphQLShemaRegistration = new GraphQLShemaRegistration();
GraphQLShemaRegistrationImpl graphQLShemaRegistration = new GraphQLShemaRegistrationImpl();

for (GraphQLSchemaConfigurer configurer : graphQLSchemaConfigurers) {
configurer.configure(graphQLShemaRegistration);
}

return new GraphQLSchemaFactoryBean(graphQLShemaRegistration.getManagedGraphQLSchemas());
return new GraphQLSchemaFactoryBean(graphQLShemaRegistration.getManagedGraphQLSchemas())
.setQueryName(properties.getName())
.setQueryDescription(properties.getDescription());


};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,34 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.springframework.beans.factory.config.AbstractFactoryBean;

import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLSchema;
import org.springframework.beans.factory.config.AbstractFactoryBean;

public class GraphQLSchemaFactoryBean extends AbstractFactoryBean<GraphQLSchema>{

private final GraphQLSchema[] managedGraphQLSchemas;
private static final String QUERY_NAME = "Query";
private static final String QUERY_DESCRIPTION = "";
private static final String SUBSCRIPTION_NAME = "Subscription";
private static final String SUBSCRIPTION_DESCRIPTION = "";
private static final String MUTATION_NAME = "Mutation";
private static final String MUTATION_DESCRIPTION = "";


private final GraphQLSchema[] managedGraphQLSchemas;

private String queryName = QUERY_NAME;
private String queryDescription = QUERY_DESCRIPTION;

private String subscriptionName = SUBSCRIPTION_NAME;
private String subscriptionDescription = SUBSCRIPTION_DESCRIPTION;

private String mutationName = MUTATION_NAME;
private String mutationDescription = MUTATION_DESCRIPTION;


public GraphQLSchemaFactoryBean(GraphQLSchema[] managedGraphQLSchemas) {
this.managedGraphQLSchemas = managedGraphQLSchemas;
}
Expand Down Expand Up @@ -46,13 +65,22 @@ protected GraphQLSchema createInstance() throws Exception {
.collect(Collectors.toList());

if(!mutations.isEmpty())
schemaBuilder.mutation(GraphQLObjectType.newObject().name("Mutation").fields(mutations));
schemaBuilder.mutation(GraphQLObjectType.newObject()
.name(this.mutationName)
.description(this.mutationDescription)
.fields(mutations));

if(!queries.isEmpty())
schemaBuilder.query(GraphQLObjectType.newObject().name("Query").fields(queries));
schemaBuilder.query(GraphQLObjectType.newObject()
.name(this.queryName)
.description(this.queryDescription)
.fields(queries));

if(!subscriptions.isEmpty())
schemaBuilder.subscription(GraphQLObjectType.newObject().name("Subscription").fields(subscriptions));
schemaBuilder.subscription(GraphQLObjectType.newObject()
.name(this.subscriptionName)
.description(this.subscriptionDescription)
.fields(subscriptions));

return schemaBuilder.build();
}
Expand All @@ -62,4 +90,40 @@ public Class<?> getObjectType() {
return GraphQLSchema.class;
}

public GraphQLSchemaFactoryBean setQueryName(String name) {
this.queryName = name;

return this;
}

public GraphQLSchemaFactoryBean setQueryDescription(String description) {
this.queryDescription = description;

return this;
}

public GraphQLSchemaFactoryBean setSubscriptionName(String subscriptionName) {
this.subscriptionName = subscriptionName;

return this;
}

public GraphQLSchemaFactoryBean setSubscriptionDescription(String subscriptionDescription) {
this.subscriptionDescription = subscriptionDescription;

return this;
}

public GraphQLSchemaFactoryBean setMutationName(String mutationName) {
this.mutationName = mutationName;

return this;
}

public GraphQLSchemaFactoryBean setMutationDescription(String mutationDescription) {
this.mutationDescription = mutationDescription;

return this;
}

}
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
package com.introproventures.graphql.jpa.query.autoconfigure;

import java.util.LinkedHashSet;
import java.util.Set;

import graphql.schema.GraphQLSchema;

public class GraphQLShemaRegistration {

Set<GraphQLSchema> managedGraphQLSchemas = new LinkedHashSet<GraphQLSchema>();
public interface GraphQLShemaRegistration {

public void register(GraphQLSchema graphQLSchema) {
managedGraphQLSchemas.add(graphQLSchema);
}
public void register(GraphQLSchema graphQLSchema);

public GraphQLSchema[] getManagedGraphQLSchemas() {
return managedGraphQLSchemas.toArray(new GraphQLSchema[] {});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.introproventures.graphql.jpa.query.autoconfigure;

import java.util.LinkedHashSet;
import java.util.Set;

import graphql.schema.GraphQLSchema;

public class GraphQLShemaRegistrationImpl implements GraphQLShemaRegistration {

Set<GraphQLSchema> managedGraphQLSchemas = new LinkedHashSet<GraphQLSchema>();

public void register(GraphQLSchema graphQLSchema) {
managedGraphQLSchemas.add(graphQLSchema);
}

public GraphQLSchema[] getManagedGraphQLSchemas() {
return managedGraphQLSchemas.toArray(new GraphQLSchema[] {});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spring.graphql.jpa.query.name=Query
spring.graphql.jpa.query.description=
spring.graphql.jpa.query.enabled=true
spring.graphql.jpa.query.path=/graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

import java.util.Map;

import graphql.GraphQL;
import graphql.Scalars;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLSchema;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -18,6 +13,12 @@
import org.springframework.stereotype.Component;
import org.springframework.test.context.junit4.SpringRunner;

import graphql.GraphQL;
import graphql.Scalars;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLObjectType;
import graphql.schema.GraphQLSchema;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvironment.NONE)
public class GraphQLSchemaAutoConfigurationTest {
Expand Down Expand Up @@ -87,6 +88,11 @@ public void contextLoads() {
// then
assertThat(result.toString()).isEqualTo("{hello=world}");
assertThat(result2.toString()).isEqualTo("{greet=hello world}");

assertThat(graphQLSchema.getQueryType())
.extracting(GraphQLObjectType::getName, GraphQLObjectType::getDescription)
.containsExactly("GraphQLBooks", "GraphQL Books Schema Description");

}


Expand Down
14 changes: 14 additions & 0 deletions graphql-jpa-query-autoconfigure/src/test/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
spring:
jpa:
hibernate.ddl-auto: create-drop
show-sql: true
h2:
console.enabled: true

graphql:
jpa:
query:
name: GraphQLBooks
description: GraphQL Books Schema Description
enabled: true
path: /graphql
2 changes: 1 addition & 1 deletion graphql-jpa-query-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.3.14-SNAPSHOT</version>
<version>0.3.15-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>

Expand Down

This file was deleted.

Loading