Skip to content

fix: enable default distinct configuration property #135

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 1 commit into from
May 6, 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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class GraphQLJpaQueryProperties {
/**
* Enable or disable distinct distinct sql query fetcher.
*/
private boolean isDefaultDistinct = false;
private boolean isDefaultDistinct = true;

/**
* Enable or disable QraphQL module services.
Expand Down Expand Up @@ -105,7 +105,7 @@ public void setUseDistinctParameter(boolean useDistinctParameter) {
/**
* @return the distinctFetcher
*/
public boolean isDefautltDistinct() {
public boolean isDefaultDistinct() {
return isDefaultDistinct;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
spring.graphql.jpa.query.name=Query
spring.graphql.jpa.query.description=
spring.graphql.jpa.query.description=Query root
spring.graphql.jpa.query.useDistinctParameter=false
spring.graphql.jpa.query.defaultDistinct=false
spring.graphql.jpa.query.defaultDistinct=true
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,6 +4,11 @@

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 @@ -13,18 +18,15 @@
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 {

@Autowired
private GraphQLSchema graphQLSchema;

@Autowired
private GraphQLJpaQueryProperties graphQLJpaQueryProperties;

@SpringBootApplication
static class Application {
Expand Down Expand Up @@ -96,5 +98,12 @@ public void contextLoads() {
}


@Test
public void configurationProperties() {
// given
assertThat(graphQLJpaQueryProperties.isDefaultDistinct()).isTrue();
assertThat(graphQLJpaQueryProperties.isUseDistinctParameter()).isFalse();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void configure(GraphQLShemaRegistration registry) {
new GraphQLJpaSchemaBuilder(entityManager)
.name("GraphQLBooks")
.useDistinctParameter(properties.isUseDistinctParameter())
.setDefaultDistinct(properties.isDefautltDistinct())
.setDefaultDistinct(properties.isDefaultDistinct())
.build()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ spring:
query:
name: Query
description: Combined GraphQL Jpa Query for Starwars and Books Example
useDistinctParameter: true
use-distinct-parameter: true
enabled: true
path: graphql
path: /graphql

starwars:
hikari:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*/
class GraphQLJpaQueryDataFetcher extends QraphQLJpaBaseDataFetcher {

private boolean defaultDistinct = false;
private boolean defaultDistinct = true;

private static final String HIBERNATE_QUERY_PASS_DISTINCT_THROUGH = "hibernate.query.passDistinctThrough";
private static final String ORG_HIBERNATE_CACHEABLE = "org.hibernate.cacheable";
Expand Down