Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bitxon/java-spring-graphql
https://github.com/bitxon/java-spring-graphql
graphql spring
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/bitxon/java-spring-graphql
- Owner: bitxon
- Created: 2024-01-21T20:03:16.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-06-29T19:35:52.000Z (6 months ago)
- Last Synced: 2024-11-08T05:04:33.285Z (about 2 months ago)
- Topics: graphql, spring
- Language: Java
- Homepage:
- Size: 55.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GraphQL with Spring Boot
## Run application
Run application with test context (auto start postgress)
```shell
./gradlew bootTestRun
```Note: if you want to run the application from your IDE\
Use `RunLocalApplication`## Test application
Open [GraphiQL UI](http://localhost:8080/graphiql)
Get Employee By Id
```graphql
query GetEmployeeById($id: ID!) {
employee(id: $id) {
id
name
organization {
name
}
}
}
```
```json
{"id": "1"}
```Get All Employees
```graphql
query GetAllEmployees {
employees {
id
name
organization {
name
}
}
}
```Get Organization By Id
```graphql
query GetOrganizationById($id: ID!) {
organization(id: $id) {
id
name
employees {
name
}
}
}
```
```json
{"id": "1"}
```Get All Organizations With Pagination
```graphql
query GetAllOrganizations($first: Int, $after: String, $last: Int, $before: String) {
organizations(first: $first, after: $after, last: $last, before: $before) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
id
name
employees {
name
}
}
}
}
}
```
```json
{"first": 5}
```
Create Employee
```graphql
mutation CreateEmployee($name: String!, $email: String!, $organizationId: Int!) {
createEmployee(employee: { name: $name, email: $email, organizationId: $organizationId}) {
id
name
}
}
```
```json
{
"name": "John Doe",
"email": "[email protected]",
"organizationId": 3
}
```Create Organization
```graphql
mutation CreateOrganization($name: String!) {
createOrganization(name: $name) {
id
name
}
}
```
```json
{"name": "Organization Test Name"}
```