Skip to content

Latest commit

 

History

History
101 lines (79 loc) · 2.31 KB

README.md

File metadata and controls

101 lines (79 loc) · 2.31 KB

Car GraphQL API

Build Status

This is a simple GraphQL model API written in JAVA 12 with Spring Boot and GraphQL Schema Publisher & Query Resolver - SPQR.

Environment Provisioning

  • 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

Run Application

  • Execute: $ ./gradlew bootRun
  • Access: http://localhost:8081/graphiql

Executing Operations

Mutations

  • 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)
    }
    

Queries

  • Gets all cars:

    {
       cars {
         id
         brand
         color
       }
    }
    
  • Gets a car by id:

    { 
       car(id: 1) {
         price
         year
       }
    }
    

REST Support

It's possible perform REST operations on API using Swagger UI. Only access: http://localhost:8081/swagger-ui.hml;

Meta

Iago Paixãoeuiagopaixao@gmail.com

distributed under MIT license

https://github.com/euiagosilva/car-graphql-api