Skip to content

Commit 3185087

Browse files
authored
Merge pull request #4 from introproventures/master
merge master
2 parents 18ec562 + 2d2f5d1 commit 3185087

File tree

25 files changed

+396
-33
lines changed

25 files changed

+396
-33
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Change Log
22

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

graphql-jpa-query-annotations/pom.xml

Lines changed: 1 addition & 1 deletion
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.17-SNAPSHOT</version>
9+
<version>0.3.18-SNAPSHOT</version>
1010
<relativePath>../graphql-jpa-query-dependencies</relativePath>
1111
</parent>
1212

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.introproventures.graphql.jpa.query.annotation;
2+
3+
import java.lang.annotation.Retention;
4+
import java.lang.annotation.Target;
5+
6+
import static java.lang.annotation.ElementType.FIELD;
7+
import static java.lang.annotation.ElementType.TYPE;
8+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
9+
10+
@Target( { TYPE, FIELD })
11+
@Retention(RUNTIME)
12+
public @interface GraphQLIgnoreFilter {
13+
}
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.introproventures.graphql.jpa.query.annotation;
2+
3+
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.Target;
6+
7+
import static java.lang.annotation.ElementType.FIELD;
8+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
9+
10+
@Target( { FIELD })
11+
@Retention(RUNTIME)
12+
public @interface GraphQLIgnoreOrder {
13+
}
14+

graphql-jpa-query-autoconfigure/pom.xml

Lines changed: 1 addition & 1 deletion
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.17-SNAPSHOT</version>
6+
<version>0.3.18-SNAPSHOT</version>
77
<relativePath>../graphql-jpa-query-build</relativePath>
88
</parent>
99
<artifactId>graphql-jpa-query-autoconfigure</artifactId>

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ public class GraphQLJpaQueryProperties {
3636
@NotEmpty
3737
private String description;
3838

39+
/**
40+
* Enable or disable distinct parameter.
41+
*/
42+
private boolean isUseDistinctParameter = false;
43+
44+
/**
45+
* Enable or disable distinct distinct sql query fetcher.
46+
*/
47+
private boolean isDefaultDistinct = false;
48+
3949
/**
4050
* Enable or disable QraphQL module services.
4151
*/
@@ -78,6 +88,34 @@ public void setDescription(String description) {
7888
this.description = description;
7989
}
8090

91+
/**
92+
* @return the useDistinctParameter
93+
*/
94+
public boolean isUseDistinctParameter() {
95+
return isUseDistinctParameter;
96+
}
97+
98+
/**
99+
* @param useDistinctParameter the useDistinctParameter to set
100+
*/
101+
public void setUseDistinctParameter(boolean useDistinctParameter) {
102+
this.isUseDistinctParameter = useDistinctParameter;
103+
}
104+
105+
/**
106+
* @return the distinctFetcher
107+
*/
108+
public boolean isDefautltDistinct() {
109+
return isDefaultDistinct;
110+
}
111+
112+
/**
113+
* @param isDefaultDistinct the distinctFetcher to set
114+
*/
115+
public void setDefaultDistinct(boolean isDefaultDistinct) {
116+
this.isDefaultDistinct = isDefaultDistinct;
117+
}
118+
81119
/**
82120
* @return the enabled
83121
*/
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
spring.graphql.jpa.query.name=Query
22
spring.graphql.jpa.query.description=
3+
spring.graphql.jpa.query.useDistinctParameter=false
4+
spring.graphql.jpa.query.defaultDistinct=false
35
spring.graphql.jpa.query.enabled=true
46
spring.graphql.jpa.query.path=/graphql

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

Lines changed: 1 addition & 1 deletion
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.17-SNAPSHOT</version>
10+
<version>0.3.18-SNAPSHOT</version>
1111
<relativePath>../graphql-jpa-query-build</relativePath>
1212
</parent>
1313

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
spring.graphql.jpa.query.name=GraphQLJpaQuery
22
spring.graphql.jpa.query.description=GraphQL Jpa Query Schema Specification
3+
spring.graphql.jpa.query.useDistinctParameter=false
4+
spring.graphql.jpa.query.distinctFetcher=false
35
spring.graphql.jpa.query.enabled=true
46
spring.graphql.jpa.query.path=/graphql

graphql-jpa-query-build/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>com.introproventures</groupId>
55
<artifactId>graphql-jpa-query-dependencies</artifactId>
6-
<version>0.3.17-SNAPSHOT</version>
6+
<version>0.3.18-SNAPSHOT</version>
77
<relativePath>../graphql-jpa-query-dependencies</relativePath>
88
</parent>
99
<artifactId>graphql-jpa-query-build</artifactId>

graphql-jpa-query-dependencies/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>com.introproventures</groupId>
55
<artifactId>graphql-jpa-query</artifactId>
6-
<version>0.3.17-SNAPSHOT</version>
6+
<version>0.3.18-SNAPSHOT</version>
77
<relativePath>..</relativePath>
88
</parent>
99
<artifactId>graphql-jpa-query-dependencies</artifactId>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<parent>
88
<groupId>com.introproventures</groupId>
99
<artifactId>graphql-jpa-query-build</artifactId>
10-
<version>0.3.17-SNAPSHOT</version>
10+
<version>0.3.18-SNAPSHOT</version>
1111
<relativePath>../graphql-jpa-query-build</relativePath>
1212
</parent>
1313

1414
<properties>
1515
<maven.deploy.skip>true</maven.deploy.skip>
16-
<skipDocker>${maven.deploy.skip}</skipDocker>
16+
<skipDocker>false</skipDocker>
1717
</properties>
1818

1919
<dependencies>
@@ -32,7 +32,7 @@
3232
<groupId>com.introproventures</groupId>
3333
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
3434
</dependency>
35-
35+
3636
<dependency>
3737
<groupId>org.springframework.boot</groupId>
3838
<artifactId>spring-boot-starter-web</artifactId>

graphql-jpa-query-example-merge/src/main/java/com/introproventures/graphql/jpa/query/example/books/Book.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import javax.persistence.Id;
2424
import javax.persistence.ManyToOne;
2525

26+
import com.introproventures.graphql.jpa.query.annotation.GraphQLIgnoreFilter;
27+
import com.introproventures.graphql.jpa.query.annotation.GraphQLIgnoreOrder;
2628
import lombok.Data;
2729

2830
@Data
@@ -31,6 +33,8 @@ public class Book {
3133
@Id
3234
Long id;
3335

36+
@GraphQLIgnoreOrder
37+
@GraphQLIgnoreFilter
3438
String title;
3539

3640
@ManyToOne(fetch=FetchType.LAZY)

graphql-jpa-query-example-merge/src/main/java/com/introproventures/graphql/jpa/query/example/books/BooksSchemaConfiguration.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
import javax.persistence.EntityManagerFactory;
88
import javax.sql.DataSource;
99

10+
import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLJpaQueryProperties;
1011
import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLSchemaConfigurer;
1112
import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLShemaRegistration;
1213
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
1314
import org.hibernate.cfg.AvailableSettings;
1415
import org.hibernate.dialect.H2Dialect;
16+
import org.springframework.beans.factory.annotation.Autowired;
1517
import org.springframework.beans.factory.annotation.Qualifier;
1618
import org.springframework.boot.context.properties.ConfigurationProperties;
1719
import org.springframework.boot.jdbc.DataSourceBuilder;
@@ -74,14 +76,22 @@ public static class GraphQLJpaQuerySchemaConfigurer implements GraphQLSchemaConf
7476

7577
private final EntityManager entityManager;
7678

79+
@Autowired
80+
private GraphQLJpaQueryProperties properties;
81+
7782
public GraphQLJpaQuerySchemaConfigurer(@Qualifier("bookEntityManager") EntityManagerFactory entityManager) {
7883
this.entityManager = entityManager.createEntityManager();
7984
}
8085

8186
@Override
8287
public void configure(GraphQLShemaRegistration registry) {
83-
84-
registry.register(new GraphQLJpaSchemaBuilder(entityManager).name("GraphQLBooks").build());
88+
registry.register(
89+
new GraphQLJpaSchemaBuilder(entityManager)
90+
.name("GraphQLBooks")
91+
.useDistinctParameter(properties.isUseDistinctParameter())
92+
.setDefaultDistinct(properties.isDefautltDistinct())
93+
.build()
94+
);
8595
}
8696
}
8797

graphql-jpa-query-example-merge/src/main/resources/application.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ spring:
1010
query:
1111
name: Query
1212
description: Combined GraphQL Jpa Query for Starwars and Books Example
13+
useDistinctParameter: true
1314
enabled: true
15+
path: graphql
1416

1517
starwars:
1618
hikari:

graphql-jpa-query-example/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<parent>
88
<groupId>com.introproventures</groupId>
99
<artifactId>graphql-jpa-query-build</artifactId>
10-
<version>0.3.17-SNAPSHOT</version>
10+
<version>0.3.18-SNAPSHOT</version>
1111
<relativePath>../graphql-jpa-query-build</relativePath>
1212
</parent>
1313

1414
<properties>
1515
<maven.deploy.skip>true</maven.deploy.skip>
16-
<skipDocker>${maven.deploy.skip}</skipDocker>
16+
<skipDocker>false</skipDocker>
1717
</properties>
1818

1919
<dependencies>

graphql-jpa-query-schema/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.introproventures</groupId>
77
<artifactId>graphql-jpa-query-build</artifactId>
8-
<version>0.3.17-SNAPSHOT</version>
8+
<version>0.3.18-SNAPSHOT</version>
99
<relativePath>../graphql-jpa-query-build</relativePath>
1010
</parent>
1111

graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaQueryDataFetcher.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
*
4747
*/
4848
class GraphQLJpaQueryDataFetcher extends QraphQLJpaBaseDataFetcher {
49+
50+
private boolean defaultDistinct = false;
4951

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

62+
public GraphQLJpaQueryDataFetcher(EntityManager entityManager, EntityType<?> entityType, boolean defaultDistinct) {
63+
super(entityManager, entityType);
64+
this.defaultDistinct = defaultDistinct;
65+
}
66+
67+
public boolean isDefaultDistinct() {
68+
return defaultDistinct;
69+
}
70+
71+
public void setDefaultDistinct(boolean defaultDistinct) {
72+
this.defaultDistinct = defaultDistinct;
73+
}
74+
6075
@Override
6176
public Object get(DataFetchingEnvironment environment) {
6277
Field field = environment.getFields().iterator().next();
@@ -69,7 +84,7 @@ public Object get(DataFetchingEnvironment environment) {
6984

7085
Optional<Argument> pageArgument = getPageArgument(field);
7186
Page page = extractPageArgument(environment, field);
72-
Argument distinctArg = extractArgument(environment, field, GraphQLJpaSchemaBuilder.SELECT_DISTINCT_PARAM_NAME, new BooleanValue(true));
87+
Argument distinctArg = extractArgument(environment, field, GraphQLJpaSchemaBuilder.SELECT_DISTINCT_PARAM_NAME, new BooleanValue(defaultDistinct));
7388

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

0 commit comments

Comments
 (0)