-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create pom.xml * Add boiler plate code * Add test code & resources * Re-org src/test code * Update read me & adding postman collection, minor pom updates * Create maven.yml * Update maven.yml * rm files not needed
- Loading branch information
1 parent
622bb77
commit 033b62c
Showing
26 changed files
with
729 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | ||
|
||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: Java CI with Maven | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: Build with Maven | ||
run: mvn -B package --file pom.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store | ||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
{ | ||
"info": { | ||
"_postman_id": "bae0e3d0-2b86-46aa-b6df-523497a2296a", | ||
"name": "GraphQL collection", | ||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" | ||
}, | ||
"item": [ | ||
{ | ||
"name": "mutations", | ||
"item": [ | ||
{ | ||
"name": "createPost", | ||
"request": { | ||
"method": "POST", | ||
"header": [], | ||
"body": { | ||
"mode": "graphql", | ||
"graphql": { | ||
"query": "mutation createPost ($title: String!, $text: String!, $category: String, $authorId: String!) {\n createPost (title: $title, text: $text, category: $category, authorId: $authorId) {\n id\n title\n text\n category\n }\n}", | ||
"variables": "{\n \"title\": \"new post\",\n \"text\": \"new post text\",\n \"category\": \"category\",\n \"authorId\": \"Author0\"\n}" | ||
} | ||
}, | ||
"url": { | ||
"raw": "http://localhost:8080/graphql", | ||
"protocol": "http", | ||
"host": [ | ||
"localhost" | ||
], | ||
"port": "8080", | ||
"path": [ | ||
"graphql" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "queries", | ||
"item": [ | ||
{ | ||
"name": "get recent posts", | ||
"request": { | ||
"method": "POST", | ||
"header": [], | ||
"body": { | ||
"mode": "graphql", | ||
"graphql": { | ||
"query": "{\r\n recentPosts(count: 10, offset: 0) {\r\n id\r\n title\r\n category\r\n text\r\n author {\r\n id\r\n name\r\n thumbnail\r\n }\r\n }\r\n}", | ||
"variables": "" | ||
} | ||
}, | ||
"url": { | ||
"raw": "http://localhost:8080/graphql", | ||
"protocol": "http", | ||
"host": [ | ||
"localhost" | ||
], | ||
"port": "8080", | ||
"path": [ | ||
"graphql" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
}, | ||
{ | ||
"name": "recentPosts - variables", | ||
"request": { | ||
"method": "POST", | ||
"header": [], | ||
"body": { | ||
"mode": "graphql", | ||
"graphql": { | ||
"query": "query recentPosts ($count: Int, $offset: Int) {\n recentPosts (count: $count, offset: $offset) {\n id\n title\n text\n category\n }\n}", | ||
"variables": "{\n \"count\": 5,\n \"offset\": 0\n}" | ||
} | ||
}, | ||
"url": { | ||
"raw": "http://localhost:8080/graphql", | ||
"protocol": "http", | ||
"host": [ | ||
"localhost" | ||
], | ||
"port": "8080", | ||
"path": [ | ||
"graphql" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
} | ||
] | ||
} | ||
], | ||
"event": [ | ||
{ | ||
"listen": "prerequest", | ||
"script": { | ||
"type": "text/javascript", | ||
"exec": [ | ||
"" | ||
] | ||
} | ||
}, | ||
{ | ||
"listen": "test", | ||
"script": { | ||
"type": "text/javascript", | ||
"exec": [ | ||
"" | ||
] | ||
} | ||
} | ||
], | ||
"variable": [ | ||
{ | ||
"key": "url", | ||
"value": "", | ||
"type": "string" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,43 @@ | ||
# graphql-box | ||
# graphql-box | ||
|
||
## Technologies: | ||
JDK corretto-17.0.9, Spring Boot 2, GraphQL, Maven 3 | ||
|
||
## Build & Run Tests: | ||
``` | ||
mvn clean package | ||
``` | ||
|
||
## Run Main Class Directly: | ||
``` | ||
com.graphql.box.intro.GraphqlApplication | ||
``` | ||
|
||
### GraphQL Queries & Mutation (Methods: Postman, Curl, & GraphiQL UI) | ||
|
||
#### Query | ||
|
||
##### curl | ||
```shell script | ||
curl \ | ||
--request POST 'localhost:8080/graphql' \ | ||
--header 'Content-Type: application/json' \ | ||
--data-raw '{"query":"query {\n recentPosts(count: 2, offset: 0) {\n id\n title\n author {\n id\n posts {\n id\n }\n }\n }\n}"}' | ||
``` | ||
##### GraphiQL UI | ||
![recentPosts-graphiql](./screenshots/recentPosts-graphiql.png?raw=true "recentPosts-graphiql") | ||
|
||
##### Postman | ||
![recentPosts-postman](./screenshots/recentPosts-postman.png?raw=true "recentPosts-postman") | ||
|
||
#### Mutation | ||
|
||
##### curl | ||
```shell script | ||
curl \ | ||
--request POST 'localhost:8080/graphql' \ | ||
--header 'Content-Type: application/json' \ | ||
--data-raw '{"query":"mutation {\n createPost(title: \"New Title\", authorId: \"Author2\", text: \"New Text\") {\n id\n category\n author {\n id\n name\n }\n }\n}"}' | ||
``` | ||
##### GraphiQL UI | ||
![createPost-graphiql](./screenshots/createPost-graphiql.png?raw=true "recentPosts-graphiql") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>graphql-sandbox</artifactId> | ||
<name>graphql-sandbox</name> | ||
<packaging>war</packaging> | ||
|
||
<groupId>com.graphql.box</groupId> | ||
<version>1.0.0</version> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.7.11</version> | ||
<relativePath /> | ||
</parent> | ||
|
||
<properties> | ||
<servlet.version>4.0.1</servlet.version> | ||
<jsonassert.version>1.5.1</jsonassert.version> | ||
<jakarta.annotation-api.version>1.3.5</jakarta.annotation-api.version> | ||
<os-maven-plugin.version>1.6.2</os-maven-plugin.version> | ||
<maven-war-plugin.version>3.3.2</maven-war-plugin.version> | ||
<os-maven-plugin.version>1.7.0</os-maven-plugin.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-graphql</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>${lombok.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.annotation</groupId> | ||
<artifactId>jakarta.annotation-api</artifactId> | ||
<version>${jakarta.annotation-api.version}</version> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-webflux</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.graphql</groupId> | ||
<artifactId>spring-graphql-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.skyscreamer</groupId> | ||
<artifactId>jsonassert</artifactId> | ||
<version>${jsonassert.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<version>${servlet.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<extensions> | ||
<extension> | ||
<groupId>kr.motd.maven</groupId> | ||
<artifactId>os-maven-plugin</artifactId> | ||
<version>${os-maven-plugin.version}</version> | ||
</extension> | ||
</extensions> | ||
</build> | ||
|
||
</project> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions
16
src/main/java/com/graphql/box/intro/GraphqlApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.graphql.box.intro; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; | ||
|
||
@SpringBootApplication(exclude = { | ||
SecurityAutoConfiguration.class | ||
}) | ||
public class GraphqlApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(GraphqlApplication.class, args); | ||
} | ||
|
||
} |
Oops, something went wrong.