Skip to content

charlybutar21/springboot-graphQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL CRUD Application

This project is a simple CRUD application built with Spring Boot and GraphQL, showcasing how to manage products using modern GraphQL queries and mutations. The project adheres to clean code principles and uses H2 database for development.


Table of Contents


Features

  • GraphQL Queries and Mutations for CRUD operations:
    • Create, Read, Update, Delete products.
  • Integrated GraphiQL interface for testing.
  • H2 in-memory database for easy development and testing.
  • Follows clean code and best practices.

Technologies Used

  • Spring Boot (v3.x)
  • Spring Data JPA
  • GraphQL Java
  • H2 Database
  • Lombok
  • Maven

Getting Started

Prerequisites

  1. Java 17 or higher installed on your system.
  2. Maven (v3.x or higher) installed.
  3. Recommended IDE: IntelliJ IDEA.

Installation

  1. Clone the repository:

    git clone https://github.com/charlybutar21/springboot-graphQL.git
    cd springboot-graphQL
  2. Build the project:

    mvn clean install
  3. Run the application:

    mvn spring-boot:run
  4. Access the application:


Usage

GraphQL Endpoints

  1. Get All Products

    query {
      getAllProducts {
        id
        name
        description
        price
      }
    }
  2. Get Product By ID

     query {
       getProductById(id: "1") {
         id
         name
         description
         price
       }
     }
  3. Create Product

     mutation {
       createProduct(input: {
         name: "New Product",
         description: "Product description",
         price: 100.0
       }) {
         id
         name
         description
         price
       }
     }
  4. Update Product

    mutation {
      updateProduct(id: "1", input: {
        name: "Updated Product",
        description: "Updated description",
        price: 150.0
      }) {
        id
        name
        description
        price
      }
    }
  5. Delete Product

    mutation {
      deleteProduct(id: "1")
    }

Testing with Postman

  1. Import the postman-collection.json.
  2. Use the pre-defined queries and mutations for testing.

GraphiQL Interface

  1. Open http://localhost:8080/graphiql?path=/graphql.
  2. Use the interactive UI to test queries and mutations.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages