https://github.com/ravisankarchinnam/spring-boot-graphql
Spring Boot GraphQL Api Example/Implementation
https://github.com/ravisankarchinnam/spring-boot-graphql
graphiql graphql h2 rest spring-boot swagger
Last synced: 17 days ago
JSON representation
Spring Boot GraphQL Api Example/Implementation
- Host: GitHub
- URL: https://github.com/ravisankarchinnam/spring-boot-graphql
- Owner: ravisankarchinnam
- Created: 2018-08-14T07:12:12.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-16T07:44:18.000Z (about 7 years ago)
- Last Synced: 2025-04-02T06:22:33.703Z (6 months ago)
- Topics: graphiql, graphql, h2, rest, spring-boot, swagger
- Language: Java
- Size: 82 KB
- Stars: 2
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GraphQL-Spring-boot Application:
This Standalone Spring boot project demonstrates the crud operations on Tour services using GraphQL as API.
[](https://travis-ci.org/ravisankarchinnam/spring-boot-graphQL)
## 1. In Memory H2 Database is used.
So you can modify application.properies as per your loving database.## 2. Running as a Packaged Application (Following ways)
Way-1 : java -jar target/spring-boot-graphql-0.0.1-SNAPSHOT.warWay-2 : mvn spring-boot:run (using maven)
## 3. Once the application is started you can access http://localhost:8080/graphiql
## Testing the Application:
## GraphQL
### To retrieve AllTours:
```
GraphiQL Syntax:
query {
allTours {
name
type
description
agency {
name
rating
}
}
}
JSON/postman syntax:
{
"query":"{allTours{name type description agency {name rating} }}"
}
```
### To createTour:
```
GraphiQL Syntax:
mutation {
createTour(input: {name:"India", price:"34543.43",duration:"3", type:LUXURY,agency:1}){
name
}
}
JSON/postman syntax:
{
"query": "mutation createTour($input: CreateTourInput!) {createTour(input: $input){name}}","variables":{"input": {"name":"India", "price":"34543.43","duration":"3", "type":"LUXURY","agency":1} },"operationName":"createTour"
}
```
### To retrieve a single Tour:
```
GraphiQL Syntax:
query {
tour(id:1){
name
description
type
agency{
name
rating
}
}
}
JSON/postman syntax:
{
"query":"{tour(id:1){name description}}"
}
```
## To delete a Tour:
```
GraphiQL Syntax:
mutation {
deleteTour(id:10)
}
JSON/postman syntax:
{
"query": "mutation deleteTour {deleteTour(id:4)}","variables":null,"operationName":"deleteTour"
}
```
### To updateTour:
```
GraphiQL Syntax:
mutation
{
updateTour(input: {id: 4, name:"India", price:"986666.43",duration:"3", type:LUXURY,agency:1}){
name
}
}
JSON/postman syntax:
{
"query": "mutation updateTour($input: UpdateTourInput!) {updateTour(input: $input){name}}","variables":{"input": {"id":4, "name":"India", "price":"908765.43","duration":"3", "type":"LUXURY","agency":1} },"operationName":"updateTour"
}
```
## To retrieve allAgencies:
```
GraphiQL Syntax:
query{
allAgencies{
name
}
}
JSON/postman syntax:
{
"query":"{allAgencies{name rating}}"
}
```
### To retrieve a single Agency:
```
GraphiQL Syntax:
query {
agency(id:1){
name
rating
}
}
JSON/postman syntax:
{
"query":"{agency(id:1){name rating}}"
}
```
## To update Agency rating:
```
GraphiQL Syntax:
mutation{
updateAgencyRating(id:1, rating:5){
rating
name
}
}
JSON/postman syntax:
{
"query":"mutation updateAgencyRating {updateAgencyRating(id:1, rating:2){name rating}}", "operationName": "updateAgencyRating"
}
```
## REST:Swagger UI is configured in this application to provide rest endpoints. So if you want to test the services using REST URL's,
you can visit http://localhost:8080/swagger-ui.html
Tour: http://localhost:8080/api/rest/tour/
Agency: http://localhost:8080/api/rest/agency/