Skip to content

Commit 8d72bbe

Browse files
authored
Extract graphql-jpa-query-web module from starter (#74)
* fix: Extract graphql-jpa-query-web module from starter * fix: (git) add .classpath to .gitignore * fix: add GraphQLControllerAutoConfigurationTest
1 parent b0839ca commit 8d72bbe

File tree

19 files changed

+141
-29
lines changed

19 files changed

+141
-29
lines changed

.gitignore

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Eclipse
2-
#.classpath
32
.project/
43
.settings/
54
build/
@@ -21,13 +20,4 @@ target/
2120
# Eclipse
2221
.project
2322
.springBeans
24-
25-
26-
27-
graphql-jpa-query-schema/\.classpath
28-
29-
graphql-jpa-query-annotations/\.classpath
30-
31-
graphql-jpa-query-example/\.classpath
32-
33-
graphql-jpa-query-boot-starter/\.classpath
23+
.classpath

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

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
2424
</dependency>
2525

26+
<dependency>
27+
<groupId>com.introproventures</groupId>
28+
<artifactId>graphql-jpa-query-web</artifactId>
29+
</dependency>
30+
2631
<dependency>
2732
<groupId>org.springframework.boot</groupId>
2833
<artifactId>spring-boot-starter</artifactId>

graphql-jpa-query-boot-starter/src/main/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/EnableGraphQLJpaQuery.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
import java.lang.annotation.Retention;
2323
import java.lang.annotation.Target;
2424

25+
import com.introproventures.graphql.jpa.query.boot.autoconfigure.GraphQLJpaQueryAutoConfiguration.DefaultGraphQLJpaQueryConfiguration;
26+
import com.introproventures.graphql.jpa.query.boot.autoconfigure.GraphQLJpaQueryAutoConfiguration.GraphQLJpaQuerySchemaConfigurer;
2527
import org.springframework.context.annotation.Import;
2628
import org.springframework.context.annotation.PropertySource;
2729

28-
import com.introproventures.graphql.jpa.query.boot.autoconfigure.GraphQLJpaQueryAutoConfiguration.DefaultActivitiGraphQLJpaConfiguration;
29-
3030
@Documented
3131
@Retention( RUNTIME )
3232
@Target( TYPE )
33-
@Import(DefaultActivitiGraphQLJpaConfiguration.class)
33+
@Import({DefaultGraphQLJpaQueryConfiguration.class, GraphQLJpaQuerySchemaConfigurer.class})
3434
@PropertySource("classpath:/com/introproventures/graphql/jpa/query/boot/autoconfigure/default.properties")
3535
public @interface EnableGraphQLJpaQuery {
3636

graphql-jpa-query-boot-starter/src/main/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/GraphQLJpaQueryAutoConfiguration.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder;
2424
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
2525
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
26-
import com.introproventures.graphql.jpa.query.web.GraphQLController;
2726
import graphql.GraphQL;
2827
import graphql.schema.GraphQLSchema;
2928
import org.springframework.beans.factory.annotation.Autowired;
@@ -33,7 +32,6 @@
3332
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3433
import org.springframework.context.annotation.Bean;
3534
import org.springframework.context.annotation.Configuration;
36-
import org.springframework.context.annotation.Import;
3735
import org.springframework.context.annotation.ImportAware;
3836
import org.springframework.context.annotation.PropertySource;
3937
import org.springframework.core.type.AnnotationMetadata;
@@ -62,9 +60,8 @@ public void configure(GraphQLShemaRegistration registry) {
6260
}
6361

6462
@Configuration
65-
@Import(GraphQLController.class)
6663
@EnableConfigurationProperties(GraphQLJpaQueryProperties.class)
67-
public static class DefaultActivitiGraphQLJpaConfiguration implements ImportAware {
64+
public static class DefaultGraphQLJpaQueryConfiguration implements ImportAware {
6865

6966
@Autowired
7067
GraphQLJpaQueryProperties properties;

graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/EnableGraphQLJpaQueryTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder;
3131
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
3232
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
33-
import com.introproventures.graphql.jpa.query.web.model.Author;
33+
import com.introproventures.graphql.jpa.query.starter.model.Author;
3434

3535
@RunWith(SpringRunner.class)
3636
@SpringBootTest(

graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/boot/autoconfigure/GraphQLJpaQueryAutoConfigurationTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import com.introproventures.graphql.jpa.query.schema.GraphQLSchemaBuilder;
3131
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
3232
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaSchemaBuilder;
33-
import com.introproventures.graphql.jpa.query.web.model.Author;
33+
import com.introproventures.graphql.jpa.query.starter.model.Author;
3434

3535
@RunWith(SpringRunner.class)
3636
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)

graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/web/GraphQLControllerIT.java graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/starter/GraphQLJpaQueryStarterIT.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package com.introproventures.graphql.jpa.query.web;
16+
package com.introproventures.graphql.jpa.query.starter;
1717

1818
import java.io.IOException;
1919
import java.util.HashMap;
@@ -41,7 +41,7 @@
4141

4242
@RunWith(SpringRunner.class)
4343
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
44-
public class GraphQLControllerIT {
44+
public class GraphQLJpaQueryStarterIT {
4545
private static final String WAR_AND_PEACE = "War and Peace";
4646

4747
@SpringBootApplication

graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/web/model/Author.java graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/starter/model/Author.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.introproventures.graphql.jpa.query.web.model;
17+
package com.introproventures.graphql.jpa.query.starter.model;
1818

1919
import java.util.Collection;
2020

graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/web/model/Book.java graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/starter/model/Book.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.introproventures.graphql.jpa.query.web.model;
17+
package com.introproventures.graphql.jpa.query.starter.model;
1818

1919
import javax.persistence.Entity;
2020
import javax.persistence.EnumType;

graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/web/model/Genre.java graphql-jpa-query-boot-starter/src/test/java/com/introproventures/graphql/jpa/query/starter/model/Genre.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.introproventures.graphql.jpa.query.web.model;
17+
package com.introproventures.graphql.jpa.query.starter.model;
1818

1919
public enum Genre {
2020
NOVEL, PLAY

graphql-jpa-query-dependencies/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@
5959
<artifactId>graphql-jpa-query-autoconfigure</artifactId>
6060
<version>${project.version}</version>
6161
</dependency>
62+
<dependency>
63+
<groupId>com.introproventures</groupId>
64+
<artifactId>graphql-jpa-query-web</artifactId>
65+
<version>${project.version}</version>
66+
</dependency>
6267
</dependencies>
6368
</dependencyManagement>
6469

graphql-jpa-query-web/pom.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<parent>
4+
<groupId>com.introproventures</groupId>
5+
<artifactId>graphql-jpa-query-build</artifactId>
6+
<version>0.3.13-SNAPSHOT</version>
7+
<relativePath>../graphql-jpa-query-build</relativePath>
8+
</parent>
9+
<artifactId>graphql-jpa-query-web</artifactId>
10+
11+
<dependencies>
12+
<dependency>
13+
<groupId>com.introproventures</groupId>
14+
<artifactId>graphql-jpa-query-schema</artifactId>
15+
<optional>true</optional>
16+
</dependency>
17+
<dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-starter-web</artifactId>
20+
<optional>true</optional>
21+
</dependency>
22+
</dependencies>
23+
24+
</project>

graphql-jpa-query-boot-starter/src/main/java/com/introproventures/graphql/jpa/query/web/GraphQLController.java graphql-jpa-query-web/src/main/java/com/introproventures/graphql/jpa/query/web/GraphQLController.java

-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor;
2727
import com.introproventures.graphql.jpa.query.schema.impl.GraphQLJpaExecutor;
2828
import graphql.ExecutionResult;
29-
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
30-
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
3129
import org.springframework.http.MediaType;
3230
import org.springframework.validation.annotation.Validated;
3331
import org.springframework.web.bind.annotation.GetMapping;
@@ -43,8 +41,6 @@
4341
*
4442
*/
4543
@RestController
46-
@ConditionalOnWebApplication
47-
@ConditionalOnClass(GraphQLExecutor.class)
4844
public class GraphQLController {
4945

5046
private static final String PATH = "${spring.graphql.jpa.query.path:/graphql}";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.introproventures.graphql.jpa.query.web.autoconfigure;
2+
3+
import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor;
4+
import com.introproventures.graphql.jpa.query.web.GraphQLController;
5+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
6+
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
7+
import org.springframework.context.annotation.Configuration;
8+
import org.springframework.context.annotation.Import;
9+
10+
@Configuration
11+
@ConditionalOnWebApplication
12+
@ConditionalOnClass(GraphQLExecutor.class)
13+
public class GraphQLControllerAutoConfiguration {
14+
15+
@Import(GraphQLController.class)
16+
public static class DefaultGraphQLControllerConfiguration {
17+
18+
}
19+
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
2+
com.introproventures.graphql.jpa.query.web.autoconfigure.GraphQLControllerAutoConfiguration
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.introproventures.graphql.jpa.query.web.autoconfigure;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor;
6+
import com.introproventures.graphql.jpa.query.web.GraphQLController;
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
import org.springframework.beans.factory.annotation.Autowired;
10+
import org.springframework.boot.autoconfigure.SpringBootApplication;
11+
import org.springframework.boot.test.context.SpringBootTest;
12+
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
13+
import org.springframework.boot.test.mock.mockito.MockBean;
14+
import org.springframework.test.context.junit4.SpringRunner;
15+
16+
@RunWith(SpringRunner.class)
17+
@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)
18+
public class GraphQLControllerAutoConfigurationTest {
19+
20+
@MockBean
21+
private GraphQLExecutor graphQLExecutor;
22+
23+
@Autowired
24+
private GraphQLController graphQLController;
25+
26+
@SpringBootApplication
27+
static class Application {
28+
29+
}
30+
31+
@Test
32+
public void contextLoads() {
33+
assertThat(graphQLController).isNotNull();
34+
}
35+
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.introproventures.graphql.jpa.query.web.autoconfigure;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import com.introproventures.graphql.jpa.query.schema.GraphQLExecutor;
6+
import com.introproventures.graphql.jpa.query.web.GraphQLController;
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
import org.springframework.beans.factory.annotation.Autowired;
10+
import org.springframework.boot.autoconfigure.SpringBootApplication;
11+
import org.springframework.boot.test.context.SpringBootTest;
12+
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
13+
import org.springframework.boot.test.mock.mockito.MockBean;
14+
import org.springframework.test.context.junit4.SpringRunner;
15+
16+
@RunWith(SpringRunner.class)
17+
@SpringBootTest(webEnvironment=WebEnvironment.NONE)
18+
public class GraphQLControllerAutoConfigurationWebNoneTest {
19+
20+
@MockBean
21+
private GraphQLExecutor graphQLExecutor;
22+
23+
@Autowired(required=false)
24+
private GraphQLController graphQLController;
25+
26+
@SpringBootApplication
27+
static class Application {
28+
29+
}
30+
31+
@Test
32+
public void contextLoads() {
33+
assertThat(graphQLController).isNull();
34+
}
35+
36+
}

pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<module>graphql-jpa-query-dependencies</module>
3939
<module>graphql-jpa-query-build</module>
4040
<module>graphql-jpa-query-autoconfigure</module>
41+
<module>graphql-jpa-query-web</module>
4142
</modules>
4243

4344
<distributionManagement>

0 commit comments

Comments
 (0)