This is a simple GraphQL model API written in JAVA 12 with Spring Boot and GraphQL Schema Publisher & Query Resolver - SPQR.
- Download the project:
$ git clone https://github.com/euiagosilva/car-graphql-api.git
- Solve dependencies:
$ ./gradlew clean build -x test
- Testing execution:
$ ./gradlew test
- Install Docker and Docker Compose in your OS;
- Create the postgres database container:
$ docker-compose -f docker/docker-compose-postgres.yml up
- Execute:
$ ./gradlew bootRun
- Access:
http://localhost:8081/graphiql
-
Save a Car:
mutation { saveCar(car: { brand: "BMW" color: "Black" description: "BMW M5 First Edition inspired by BMW Individual" price: 78.890 year: 2017 model: "M5 Sedan" isNew: false }) { id } }
-
Update a Car:
mutation { updateCar(car: { id: 1 brand: "BMW" color: "Yellow" description: "BMW M5 First Edition inspired by BMW Individual" price: 78.890 year: 2018 model: "M5 Sedan" isNew: false }) { id } }
-
Deletes a car by id:
mutation { deleteCar(id: 1) }
-
Gets all cars:
{ cars { id brand color } }
-
Gets a car by id:
{ car(id: 1) { price year } }
It's possible perform REST operations on API using Swagger UI. Only access: http://localhost:8081/swagger-ui.hml
;
Iago Paixão – euiagopaixao@gmail.com
distributed under MIT license