Skip to content

Commit 040e3f1

Browse files
almericoigdianov
authored andcommitted
Play with doker branch (#10)
* docker file added also docker image can be created using: `mvn clean package docker:build -DskipTests` * added compose file * Updated README.md * removed deploy section in compose * Renamed graphiql.html to index.html to resolve GET / request * Streamline Maven build with Docker Hub push and image tagging using: `mvn clean package docker:build -DpushImage`
1 parent 3ae136b commit 040e3f1

File tree

6 files changed

+93
-16
lines changed

6 files changed

+93
-16
lines changed

README.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,26 @@ of sorting by name for Human objects. The default sort order can be specified us
275275

276276
Performance
277277
-----------
278-
The JPA DataFetcher implementation will attempt to build dynamic fetch graph in order to optimize query performance and avoid N+1 lazy loading.
278+
The JPA DataFetcher implementation will attempt to build dynamic fetch graph in order to optimize query performance and avoid N+1 lazy loading. However, if there are composite foreign keys being used on `@ManyToOne` association declared in GraphQL query, Hibernate persistence provider will issue a separate SQL query to resolve the parent entity.
279279

280-
Examples
280+
GraphiQL Browser
281281
--------
282282

283-
GraphiQL (https://github.com/graphql/graphiql) can be used for simple testing. You can build and launch provided example as a Spring Boot Application, then navigate to http://localhost:8080/graphiql.html to load GraphiQL browser. The collapsed Docs panel can opened by clicking on the button in the upper right corner to expose current test schema models.
283+
GraphiQL (https://github.com/graphql/graphiql) can be used for simple testing. You can build and launch provided example as a Spring Boot Application, then navigate to http://localhost:8080/ to load GraphiQL browser. The collapsed Docs panel can opened by clicking on the button in the upper right corner to expose current test schema models.
284284

285285
You can run GraphQL queries in the left pannel. Type the query and hit the run button. The results should come up in the middle
286286
panel. If your query has variables, there is a minimized panel at the bottom left. Simply click on this to expand, and
287287
type in your variables as a JSON string with quoted keys.
288288

289+
Run Example in Docker
290+
------
291+
You can quickly start GraphQL JPA Query Example in Docker Swarm online using the community-run Docker playground: `play-with-docker.com (PWD)` by clicking the button below:
292+
293+
[![Try in PWD](https://cdn.rawgit.com/play-with-docker/stacks/cff22438/assets/images/button.png)](http://play-with-docker.com/?stack=https://raw.githubusercontent.com/introproventures/graphql-jpa-query/play_with_doker/graphql-jpa-query-example/docker-compose.yml&stack_name=graphhql)
294+
295+
After PWD session is ready, select the Docker container instance on the left and then click on the link at the top with exposed port 8080 to run the example. If you get an error message that says: "error routing request", wait for at least 20 seconds after container instance is created to launch the Spring Boot Application.
296+
297+
289298
License
290299
-------
291300
Apache License v2.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: "3.2"
2+
services:
3+
gpaphql-jpa-query-example:
4+
volumes:
5+
- "/var/run/docker.sock:/var/run/docker.sock"
6+
ports:
7+
- 8080:8080
8+
image: introproventures/graphql-jpa-query-example:latest
9+
networks:
10+
- application
11+
networks:
12+
application:
13+
driver: overlay

graphql-jpa-query-example/pom.xml

+48
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,52 @@
2929
</dependency>
3030

3131
</dependencies>
32+
33+
<build>
34+
35+
<finalName>${project.artifactId}</finalName>
36+
37+
<plugins>
38+
<plugin>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-maven-plugin</artifactId>
41+
<!--version>1.5.7.RELEASE</version-->
42+
<executions>
43+
<execution>
44+
<goals>
45+
<goal>repackage</goal>
46+
</goals>
47+
</execution>
48+
</executions>
49+
</plugin>
50+
<plugin>
51+
<groupId>com.spotify</groupId>
52+
<artifactId>docker-maven-plugin</artifactId>
53+
<version>0.4.14</version>
54+
<configuration>
55+
<serverId>docker-hub</serverId>
56+
<registryUrl>https://index.docker.io/v1/</registryUrl>
57+
<imageName>introproventures/${project.artifactId}</imageName>
58+
<dockerDirectory>src/main/docker</dockerDirectory>
59+
<resources>
60+
<resource>
61+
<targetPath>/</targetPath>
62+
<directory>${project.build.directory}</directory>
63+
<include>${project.build.finalName}.jar</include>
64+
</resource>
65+
</resources>
66+
67+
<!-- optionally overwrite tags every time image is built with docker:build -->
68+
<forceTags>true</forceTags>
69+
<imageTags>
70+
<imageTag>${project.version}</imageTag>
71+
<imageTag>latest</imageTag>
72+
</imageTags>
73+
74+
</configuration>
75+
76+
</plugin>
77+
78+
</plugins>
79+
</build>
3280
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM openjdk:8-jdk-alpine
2+
3+
VOLUME /var/log/
4+
VOLUME /tmp
5+
6+
EXPOSE 8080
7+
8+
ADD graphql-jpa-query-example.jar app.jar
9+
10+
ENV JAVA_OPTS=""
11+
12+
ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar

graphql-jpa-query-example/src/main/java/com/introproventures/graphql/jpa/query/example/Application.java

+8-13
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,19 @@
33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55

6+
/**
7+
* GraphQL JPA Query Example with Spring Boot Autoconfiguration
8+
*
9+
* You can configure GraphQL JPA Query properties in application.yml
10+
*
11+
* @author Igor Dianov
12+
*
13+
*/
614
@SpringBootApplication
715
public class Application {
816

917
public static void main(String[] args) {
1018
SpringApplication.run(Application.class, args);
1119
}
1220

13-
// @Bean
14-
// public GraphQLExecutor graphQLExecutor(final GraphQLSchemaBuilder graphQLSchemaBuilder) {
15-
// return new GraphQLJpaExecutor(graphQLSchemaBuilder.build());
16-
// }
17-
//
18-
// @Bean
19-
// public GraphQLSchemaBuilder graphQLSchemaBuilder(final EntityManager entityManager) {
20-
//
21-
// return new GraphQLJpaSchemaBuilder(entityManager)
22-
// .name("GrapQLBooks")
23-
// .description("Books JPA Test Schema");
24-
// }
25-
2621
}

0 commit comments

Comments
 (0)