Skip to content

Commit 6359449

Browse files
authored
fix: enable default distinct configuration property (#135)
1 parent a18a6ce commit 6359449

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class GraphQLJpaQueryProperties {
4444
/**
4545
* Enable or disable distinct distinct sql query fetcher.
4646
*/
47-
private boolean isDefaultDistinct = false;
47+
private boolean isDefaultDistinct = true;
4848

4949
/**
5050
* Enable or disable QraphQL module services.
@@ -105,7 +105,7 @@ public void setUseDistinctParameter(boolean useDistinctParameter) {
105105
/**
106106
* @return the distinctFetcher
107107
*/
108-
public boolean isDefautltDistinct() {
108+
public boolean isDefaultDistinct() {
109109
return isDefaultDistinct;
110110
}
111111

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
spring.graphql.jpa.query.name=Query
2-
spring.graphql.jpa.query.description=
2+
spring.graphql.jpa.query.description=Query root
33
spring.graphql.jpa.query.useDistinctParameter=false
4-
spring.graphql.jpa.query.defaultDistinct=false
4+
spring.graphql.jpa.query.defaultDistinct=true
55
spring.graphql.jpa.query.enabled=true
66
spring.graphql.jpa.query.path=/graphql

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

+15-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
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;
712
import org.junit.Test;
813
import org.junit.runner.RunWith;
914
import org.springframework.beans.factory.annotation.Autowired;
@@ -13,18 +18,15 @@
1318
import org.springframework.stereotype.Component;
1419
import org.springframework.test.context.junit4.SpringRunner;
1520

16-
import graphql.GraphQL;
17-
import graphql.Scalars;
18-
import graphql.schema.GraphQLFieldDefinition;
19-
import graphql.schema.GraphQLObjectType;
20-
import graphql.schema.GraphQLSchema;
21-
2221
@RunWith(SpringRunner.class)
2322
@SpringBootTest(webEnvironment=WebEnvironment.NONE)
2423
public class GraphQLSchemaAutoConfigurationTest {
2524

2625
@Autowired
2726
private GraphQLSchema graphQLSchema;
27+
28+
@Autowired
29+
private GraphQLJpaQueryProperties graphQLJpaQueryProperties;
2830

2931
@SpringBootApplication
3032
static class Application {
@@ -96,5 +98,12 @@ public void contextLoads() {
9698
}
9799

98100

101+
@Test
102+
public void configurationProperties() {
103+
// given
104+
assertThat(graphQLJpaQueryProperties.isDefaultDistinct()).isTrue();
105+
assertThat(graphQLJpaQueryProperties.isUseDistinctParameter()).isFalse();
106+
}
107+
99108

100109
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void configure(GraphQLShemaRegistration registry) {
9090
new GraphQLJpaSchemaBuilder(entityManager)
9191
.name("GraphQLBooks")
9292
.useDistinctParameter(properties.isUseDistinctParameter())
93-
.setDefaultDistinct(properties.isDefautltDistinct())
93+
.setDefaultDistinct(properties.isDefaultDistinct())
9494
.build()
9595
);
9696
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ spring:
1010
query:
1111
name: Query
1212
description: Combined GraphQL Jpa Query for Starwars and Books Example
13-
useDistinctParameter: true
13+
use-distinct-parameter: true
1414
enabled: true
15-
path: graphql
15+
path: /graphql
1616

1717
starwars:
1818
hikari:

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
*/
4848
class GraphQLJpaQueryDataFetcher extends QraphQLJpaBaseDataFetcher {
4949

50-
private boolean defaultDistinct = false;
50+
private boolean defaultDistinct = true;
5151

5252
private static final String HIBERNATE_QUERY_PASS_DISTINCT_THROUGH = "hibernate.query.passDistinctThrough";
5353
private static final String ORG_HIBERNATE_CACHEABLE = "org.hibernate.cacheable";

0 commit comments

Comments
 (0)