diff --git a/graphql-jpa-query-autoconfigure/pom.xml b/graphql-jpa-query-autoconfigure/pom.xml
index 65878745d..c749bf258 100644
--- a/graphql-jpa-query-autoconfigure/pom.xml
+++ b/graphql-jpa-query-autoconfigure/pom.xml
@@ -19,7 +19,17 @@
org.springframework.boot
spring-boot-autoconfigure
+
+
+ javax.validation
+ validation-api
+
+
+ org.hibernate.validator
+ hibernate-validator
+ test
+
\ No newline at end of file
diff --git a/graphql-jpa-query-boot-starter/src/main/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/GraphQLJpaQueryProperties.java b/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLJpaQueryProperties.java
similarity index 83%
rename from graphql-jpa-query-boot-starter/src/main/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/GraphQLJpaQueryProperties.java
rename to graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLJpaQueryProperties.java
index 4c3ee3a03..5383630ee 100644
--- a/graphql-jpa-query-boot-starter/src/main/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/GraphQLJpaQueryProperties.java
+++ b/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLJpaQueryProperties.java
@@ -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 {
diff --git a/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfiguration.java b/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfiguration.java
index 2842940b3..21c524178 100644
--- a/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfiguration.java
+++ b/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfiguration.java
@@ -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 graphQLSchemaConfigurers = new ArrayList<>();
+
+ @Autowired
+ private GraphQLJpaQueryProperties properties;
@Autowired(required = true)
public void setGraphQLSchemaConfigurers(List configurers) {
@@ -28,13 +34,16 @@ public void setGraphQLSchemaConfigurers(List 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());
+
};
diff --git a/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaFactoryBean.java b/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaFactoryBean.java
index 02499123b..92837b666 100644
--- a/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaFactoryBean.java
+++ b/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaFactoryBean.java
@@ -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{
- 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;
}
@@ -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();
}
@@ -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;
+ }
+
}
diff --git a/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLShemaRegistration.java b/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLShemaRegistration.java
index b91e17632..296734e59 100644
--- a/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLShemaRegistration.java
+++ b/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLShemaRegistration.java
@@ -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 managedGraphQLSchemas = new LinkedHashSet();
+public interface GraphQLShemaRegistration {
- public void register(GraphQLSchema graphQLSchema) {
- managedGraphQLSchemas.add(graphQLSchema);
- }
+ public void register(GraphQLSchema graphQLSchema);
- public GraphQLSchema[] getManagedGraphQLSchemas() {
- return managedGraphQLSchemas.toArray(new GraphQLSchema[] {});
- }
}
diff --git a/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLShemaRegistrationImpl.java b/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLShemaRegistrationImpl.java
new file mode 100644
index 000000000..a0a17f3b7
--- /dev/null
+++ b/graphql-jpa-query-autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLShemaRegistrationImpl.java
@@ -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 managedGraphQLSchemas = new LinkedHashSet();
+
+ public void register(GraphQLSchema graphQLSchema) {
+ managedGraphQLSchemas.add(graphQLSchema);
+ }
+
+ public GraphQLSchema[] getManagedGraphQLSchemas() {
+ return managedGraphQLSchemas.toArray(new GraphQLSchema[] {});
+ }
+
+}
diff --git a/graphql-jpa-query-autoconfigure/src/main/resources/com/introproventures/graphql/jpa/query/boot/autoconfigure/default.properties b/graphql-jpa-query-autoconfigure/src/main/resources/com/introproventures/graphql/jpa/query/boot/autoconfigure/default.properties
new file mode 100644
index 000000000..8a9deba1d
--- /dev/null
+++ b/graphql-jpa-query-autoconfigure/src/main/resources/com/introproventures/graphql/jpa/query/boot/autoconfigure/default.properties
@@ -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
\ No newline at end of file
diff --git a/graphql-jpa-query-autoconfigure/src/test/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfigurationTest.java b/graphql-jpa-query-autoconfigure/src/test/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfigurationTest.java
index 09129b729..e8cd94c6c 100644
--- a/graphql-jpa-query-autoconfigure/src/test/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfigurationTest.java
+++ b/graphql-jpa-query-autoconfigure/src/test/java/com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfigurationTest.java
@@ -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;
@@ -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 {
@@ -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");
+
}
diff --git a/graphql-jpa-query-autoconfigure/src/test/resources/application.yml b/graphql-jpa-query-autoconfigure/src/test/resources/application.yml
new file mode 100644
index 000000000..97b45f456
--- /dev/null
+++ b/graphql-jpa-query-autoconfigure/src/test/resources/application.yml
@@ -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
\ No newline at end of file
diff --git a/graphql-jpa-query-boot-starter/src/main/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/EnableGraphQLJpaQuery.java b/graphql-jpa-query-boot-starter/src/main/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/EnableGraphQLJpaQuery.java
deleted file mode 100644
index 2e3ce63ce..000000000
--- a/graphql-jpa-query-boot-starter/src/main/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/EnableGraphQLJpaQuery.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2017 IntroPro Ventures, Inc. and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.introproventures.graphql.jpa.query.boot.autoconfigure;
-
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import com.introproventures.graphql.jpa.query.boot.autoconfigure.GraphQLJpaQueryAutoConfiguration.DefaultGraphQLJpaQueryConfiguration;
-import com.introproventures.graphql.jpa.query.boot.autoconfigure.GraphQLJpaQueryAutoConfiguration.GraphQLJpaQuerySchemaConfigurer;
-import org.springframework.context.annotation.Import;
-import org.springframework.context.annotation.PropertySource;
-
-@Documented
-@Retention( RUNTIME )
-@Target( TYPE )
-@Import({DefaultGraphQLJpaQueryConfiguration.class, GraphQLJpaQuerySchemaConfigurer.class})
-@PropertySource("classpath:/com/introproventures/graphql/jpa/query/boot/autoconfigure/default.properties")
-public @interface EnableGraphQLJpaQuery {
-
-}
diff --git a/graphql-jpa-query-boot-starter/src/main/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/GraphQLJpaQueryAutoConfiguration.java b/graphql-jpa-query-boot-starter/src/main/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/GraphQLJpaQueryAutoConfiguration.java
index 5b63fe8fd..d4d755fb6 100644
--- a/graphql-jpa-query-boot-starter/src/main/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/GraphQLJpaQueryAutoConfiguration.java
+++ b/graphql-jpa-query-boot-starter/src/main/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/GraphQLJpaQueryAutoConfiguration.java
@@ -17,30 +17,25 @@
import javax.persistence.EntityManager;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLSchemaConfigurer;
import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLShemaRegistration;
import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor;
import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder;
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
+
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.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.ImportAware;
-import org.springframework.context.annotation.PropertySource;
-import org.springframework.core.type.AnnotationMetadata;
-import org.springframework.util.Assert;
@Configuration
-@PropertySource("classpath:/com/introproventures/graphql/jpa/query/boot/autoconfigure/default.properties")
@ConditionalOnClass(GraphQL.class)
-@ConditionalOnProperty(name="spring.graphql.jpa.query.enabled", havingValue="true", matchIfMissing=false)
+@ConditionalOnProperty(name="spring.graphql.jpa.query.enabled", havingValue="true", matchIfMissing=true)
public class GraphQLJpaQueryAutoConfiguration {
@Configuration
@@ -54,18 +49,13 @@ public GraphQLJpaQuerySchemaConfigurer(GraphQLSchemaBuilder graphQLSchemaBuilder
@Override
public void configure(GraphQLShemaRegistration registry) {
-
registry.register(graphQLSchemaBuilder.build());
}
}
@Configuration
- @EnableConfigurationProperties(GraphQLJpaQueryProperties.class)
- public static class DefaultGraphQLJpaQueryConfiguration implements ImportAware {
+ public static class DefaultGraphQLJpaQueryConfiguration {
- @Autowired
- GraphQLJpaQueryProperties properties;
-
@Bean
@ConditionalOnMissingBean(GraphQLExecutor.class)
public GraphQLExecutor graphQLExecutor(GraphQLSchema graphQLSchema) {
@@ -75,17 +65,8 @@ public GraphQLExecutor graphQLExecutor(GraphQLSchema graphQLSchema) {
@Bean
@ConditionalOnMissingBean(GraphQLSchemaBuilder.class)
public GraphQLSchemaBuilder graphQLSchemaBuilder(final EntityManager entityManager) {
- Assert.notNull(properties.getName(), "GraphQL schema name cannot be null.");
- Assert.notNull(properties.getDescription(), "GraphQL schema description cannot be null.");
-
- return new GraphQLJpaSchemaBuilder(entityManager)
- .name(properties.getName())
- .description(properties.getDescription());
+ return new GraphQLJpaSchemaBuilder(entityManager);
}
- @Override
- public void setImportMetadata(AnnotationMetadata importMetadata) {
- properties.setEnabled(true);
- }
}
}
diff --git a/graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/EnableGraphQLJpaQueryTest.java b/graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/EnableGraphQLJpaQueryTest.java
deleted file mode 100644
index 44d6d9079..000000000
--- a/graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/EnableGraphQLJpaQueryTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2017 IntroPro Ventures, Inc. and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.introproventures.graphql.jpa.query.boot.autoconfigure;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.domain.EntityScan;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor;
-import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder;
-import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
-import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
-import com.introproventures.graphql.jpa.query.starter.model.Author;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(
- properties={"spring.graphql.jpa.query.enabled=false"},
- webEnvironment = WebEnvironment.RANDOM_PORT
-)
-public class EnableGraphQLJpaQueryTest {
-
- @SpringBootApplication(exclude=GraphQLJpaQueryAutoConfiguration.class)
- @EntityScan(basePackageClasses=Author.class)
- @EnableGraphQLJpaQuery
- static class Application {
- }
-
- @Autowired
- GraphQLJpaQueryProperties graphQLJpaQueryProperties;
-
- @Autowired
- GraphQLExecutor graphQLExecutor;
-
- @Autowired
- GraphQLSchemaBuilder graphQLSchemaBuilder;
-
- @Test
- public void contextIsConfigured() {
- assertThat(graphQLExecutor).isInstanceOf(GraphQLJpaExecutor.class);
- assertThat(graphQLSchemaBuilder).isInstanceOf(GraphQLJpaSchemaBuilder.class);
-
- assertThat(graphQLJpaQueryProperties.getName()).isEqualTo("GraphQLBooks");
- assertThat(graphQLJpaQueryProperties.getDescription()).isEqualTo("GraphQL Books Schema Description");
- assertThat(graphQLJpaQueryProperties.getPath()).isEqualTo("/graphql");
- assertThat(graphQLJpaQueryProperties.isEnabled()).isEqualTo(true);
-
- }
-
-}
diff --git a/graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/GraphQLJpaQueryAutoConfigurationTest.java b/graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/GraphQLJpaQueryAutoConfigurationTest.java
index 73b89d99c..189d47c3e 100644
--- a/graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/GraphQLJpaQueryAutoConfigurationTest.java
+++ b/graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/GraphQLJpaQueryAutoConfigurationTest.java
@@ -32,6 +32,9 @@
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
import com.introproventures.graphql.jpa.query.starter.model.Author;
+import graphql.schema.GraphQLObjectType;
+import graphql.schema.GraphQLSchema;
+
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class GraphQLJpaQueryAutoConfigurationTest {
@@ -41,24 +44,26 @@ public class GraphQLJpaQueryAutoConfigurationTest {
static class Application {
}
- @Autowired
- GraphQLJpaQueryProperties graphQLJpaQueryProperties;
+ @Autowired(required=false)
+ private GraphQLExecutor graphQLExecutor;
- @Autowired
- GraphQLExecutor graphQLExecutor;
+ @Autowired(required=false)
+ private GraphQLSchemaBuilder graphQLSchemaBuilder;
@Autowired
- GraphQLSchemaBuilder graphQLSchemaBuilder;
+ private GraphQLSchema graphQLSchema;
@Test
public void contextIsAutoConfigured() {
- assertThat(graphQLExecutor).isInstanceOf(GraphQLJpaExecutor.class);
- assertThat(graphQLSchemaBuilder).isInstanceOf(GraphQLJpaSchemaBuilder.class);
+ assertThat(graphQLExecutor).isNotNull()
+ .isInstanceOf(GraphQLJpaExecutor.class);
+
+ assertThat(graphQLSchemaBuilder).isNotNull()
+ .isInstanceOf(GraphQLJpaSchemaBuilder.class);
- assertThat(graphQLJpaQueryProperties.getName()).isEqualTo("GraphQLBooks");
- assertThat(graphQLJpaQueryProperties.getDescription()).isEqualTo("GraphQL Books Schema Description");
- assertThat(graphQLJpaQueryProperties.getPath()).isEqualTo("/graphql");
- assertThat(graphQLJpaQueryProperties.isEnabled()).isEqualTo(true);
+ assertThat(graphQLSchema.getQueryType())
+ .extracting(GraphQLObjectType::getName, GraphQLObjectType::getDescription)
+ .containsExactly("GraphQLBooks", "GraphQL Books Schema Description");
}
}
\ No newline at end of file
diff --git a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java
index 7a00249b9..72947aabf 100644
--- a/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java
+++ b/graphql-jpa-query-schema/src/main/java/com/introproventures/graphql/jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java
@@ -106,7 +106,7 @@ public class GraphQLJpaSchemaBuilder implements GraphQLSchemaBuilder {
private EntityManager entityManager;
- private String name = "GraphQL JPA Schema";
+ private String name = "GraphQLJPAQuery";
private String description = "GraphQL Schema for all entities in this JPA application";