Skip to content

merge master #4

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 7 commits into from
Mar 26, 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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log

## 0.3.17-SNAPSHOT
## 0.3.18-SNAPSHOT
* chore: enable Docker build by default [ec3f1a6](https://github.com/introproventures/graphql-jpa-query/commit/ec3f1a6c5daa3390fd738e2d2cef4f7a58b24e2d)
* fix: use bean naming convention for property names [6df3c30](https://github.com/introproventures/graphql-jpa-query/commit/6df3c30d1a16681da07d81d7ca64fed9d885ac57)
* distinct sql and ignore field in filters and sorting (#95) [bde04d5](https://github.com/introproventures/graphql-jpa-query/commit/bde04d5702943cd7d5e70d071e8a49df4ef8ad9f)
* fix: use embeddableType javaType to cache corresponding GraphQL type (#98) [ce4f85a](https://github.com/introproventures/graphql-jpa-query/commit/ce4f85a462d9c746d62c56e3f69be5beebd9d28c)
* feat: add where relation attributes criteria expressions (#96) [b296d8a](https://github.com/introproventures/graphql-jpa-query/commit/b296d8a2c9ad9d0a8b6b58d54f5cd6dcfded953f)
* chore: skip Docker plugin on release [2933500](https://github.com/introproventures/graphql-jpa-query/commit/2933500644bd6b781919a24c5583c6708f046a13)
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.17-SNAPSHOT</version>
<version>0.3.18-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-dependencies</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.introproventures.graphql.jpa.query.annotation;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target( { TYPE, FIELD })
@Retention(RUNTIME)
public @interface GraphQLIgnoreFilter {
}

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


import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target( { FIELD })
@Retention(RUNTIME)
public @interface GraphQLIgnoreOrder {
}

2 changes: 1 addition & 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.17-SNAPSHOT</version>
<version>0.3.18-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ public class GraphQLJpaQueryProperties {
@NotEmpty
private String description;

/**
* Enable or disable distinct parameter.
*/
private boolean isUseDistinctParameter = false;

/**
* Enable or disable distinct distinct sql query fetcher.
*/
private boolean isDefaultDistinct = false;

/**
* Enable or disable QraphQL module services.
*/
Expand Down Expand Up @@ -78,6 +88,34 @@ public void setDescription(String description) {
this.description = description;
}

/**
* @return the useDistinctParameter
*/
public boolean isUseDistinctParameter() {
return isUseDistinctParameter;
}

/**
* @param useDistinctParameter the useDistinctParameter to set
*/
public void setUseDistinctParameter(boolean useDistinctParameter) {
this.isUseDistinctParameter = useDistinctParameter;
}

/**
* @return the distinctFetcher
*/
public boolean isDefautltDistinct() {
return isDefaultDistinct;
}

/**
* @param isDefaultDistinct the distinctFetcher to set
*/
public void setDefaultDistinct(boolean isDefaultDistinct) {
this.isDefaultDistinct = isDefaultDistinct;
}

/**
* @return the enabled
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
spring.graphql.jpa.query.name=Query
spring.graphql.jpa.query.description=
spring.graphql.jpa.query.useDistinctParameter=false
spring.graphql.jpa.query.defaultDistinct=false
spring.graphql.jpa.query.enabled=true
spring.graphql.jpa.query.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.17-SNAPSHOT</version>
<version>0.3.18-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
spring.graphql.jpa.query.name=GraphQLJpaQuery
spring.graphql.jpa.query.description=GraphQL Jpa Query Schema Specification
spring.graphql.jpa.query.useDistinctParameter=false
spring.graphql.jpa.query.distinctFetcher=false
spring.graphql.jpa.query.enabled=true
spring.graphql.jpa.query.path=/graphql
2 changes: 1 addition & 1 deletion graphql-jpa-query-build/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-dependencies</artifactId>
<version>0.3.17-SNAPSHOT</version>
<version>0.3.18-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-dependencies</relativePath>
</parent>
<artifactId>graphql-jpa-query-build</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion graphql-jpa-query-dependencies/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</artifactId>
<version>0.3.17-SNAPSHOT</version>
<version>0.3.18-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>graphql-jpa-query-dependencies</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions graphql-jpa-query-example-merge/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.3.17-SNAPSHOT</version>
<version>0.3.18-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>

<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<skipDocker>${maven.deploy.skip}</skipDocker>
<skipDocker>false</skipDocker>
</properties>

<dependencies>
Expand All @@ -32,7 +32,7 @@
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import javax.persistence.Id;
import javax.persistence.ManyToOne;

import com.introproventures.graphql.jpa.query.annotation.GraphQLIgnoreFilter;
import com.introproventures.graphql.jpa.query.annotation.GraphQLIgnoreOrder;
import lombok.Data;

@Data
Expand All @@ -31,6 +33,8 @@ public class Book {
@Id
Long id;

@GraphQLIgnoreOrder
@GraphQLIgnoreFilter
String title;

@ManyToOne(fetch=FetchType.LAZY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLJpaQueryProperties;
import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLSchemaConfigurer;
import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLShemaRegistration;
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.H2Dialect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
Expand Down Expand Up @@ -74,14 +76,22 @@ public static class GraphQLJpaQuerySchemaConfigurer implements GraphQLSchemaConf

private final EntityManager entityManager;

@Autowired
private GraphQLJpaQueryProperties properties;

public GraphQLJpaQuerySchemaConfigurer(@Qualifier("bookEntityManager") EntityManagerFactory entityManager) {
this.entityManager = entityManager.createEntityManager();
}

@Override
public void configure(GraphQLShemaRegistration registry) {

registry.register(new GraphQLJpaSchemaBuilder(entityManager).name("GraphQLBooks").build());
registry.register(
new GraphQLJpaSchemaBuilder(entityManager)
.name("GraphQLBooks")
.useDistinctParameter(properties.isUseDistinctParameter())
.setDefaultDistinct(properties.isDefautltDistinct())
.build()
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ spring:
query:
name: Query
description: Combined GraphQL Jpa Query for Starwars and Books Example
useDistinctParameter: true
enabled: true
path: graphql

starwars:
hikari:
Expand Down
4 changes: 2 additions & 2 deletions graphql-jpa-query-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.3.17-SNAPSHOT</version>
<version>0.3.18-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>

<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<skipDocker>${maven.deploy.skip}</skipDocker>
<skipDocker>false</skipDocker>
</properties>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion graphql-jpa-query-schema/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.introproventures</groupId>
<artifactId>graphql-jpa-query-build</artifactId>
<version>0.3.17-SNAPSHOT</version>
<version>0.3.18-SNAPSHOT</version>
<relativePath>../graphql-jpa-query-build</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
*
*/
class GraphQLJpaQueryDataFetcher extends QraphQLJpaBaseDataFetcher {

private boolean defaultDistinct = false;

private static final String HIBERNATE_QUERY_PASS_DISTINCT_THROUGH = "hibernate.query.passDistinctThrough";
private static final String ORG_HIBERNATE_CACHEABLE = "org.hibernate.cacheable";
Expand All @@ -57,6 +59,19 @@ public GraphQLJpaQueryDataFetcher(EntityManager entityManager, EntityType<?> ent
super(entityManager, entityType);
}

public GraphQLJpaQueryDataFetcher(EntityManager entityManager, EntityType<?> entityType, boolean defaultDistinct) {
super(entityManager, entityType);
this.defaultDistinct = defaultDistinct;
}

public boolean isDefaultDistinct() {
return defaultDistinct;
}

public void setDefaultDistinct(boolean defaultDistinct) {
this.defaultDistinct = defaultDistinct;
}

@Override
public Object get(DataFetchingEnvironment environment) {
Field field = environment.getFields().iterator().next();
Expand All @@ -69,7 +84,7 @@ public Object get(DataFetchingEnvironment environment) {

Optional<Argument> pageArgument = getPageArgument(field);
Page page = extractPageArgument(environment, field);
Argument distinctArg = extractArgument(environment, field, GraphQLJpaSchemaBuilder.SELECT_DISTINCT_PARAM_NAME, new BooleanValue(true));
Argument distinctArg = extractArgument(environment, field, GraphQLJpaSchemaBuilder.SELECT_DISTINCT_PARAM_NAME, new BooleanValue(defaultDistinct));

boolean isDistinct = ((BooleanValue) distinctArg.getValue()).isValue();

Expand Down
Loading