Skip to main content

Posts

Showing posts from September, 2025

Spring Boot GraphQL Save, Update and Delete - Database MutationMapping

Learn how to get started with Graphql using spring boot framework. In this session, you will be learning like how to add the schema details and mapping the function and request payload with Graphql @MutationMapping into your controller class. So you can preform like Save, update and delete operation using graphql You need Spring web, JPA, Mysql, Lombok and Spring Graphql dependencies to your pom module. schema.graphqls (This file should be created inside the resources/graphql folder) type Query{ findAll: [User] userById(id: ID): User } type User{ id: ID name: String gender: String emailId: String } type Mutation{ addUser(userDetails: UserDetails): User updateUser(userDetails: UserDetails): User deleteUser(id: ID): String } input UserDetails{ id: ID name: String gender: String emailId: String } UserGQLController .java package com.hakeemit.graphql.controller; import com.hakeemit.graphql.entity.User; import com.hakeemit.gra...

Spring Boot GraphQL REST API - GET Function using Query Mapping

Learn how to get started with Graphql using spring boot framework. In this article, you will be learning like how to add the schema details and mapping the function and request payload with Graphql @QueryMapping into your controller class. You need Spring web, JPA, Mysql, Lombok and Spring Graphql dependencies to your pom module. schema.graphqls (This file should be created inside the resources/graphql folder) type Query{ findAll: [User] userById(id: ID): User } type User{ id: ID name: String gender: String emailId: String } UserGQLController .java package com.hakeemit.graphql.controller; import com.hakeemit.graphql.entity.User; import com.hakeemit.graphql.entity.UserDetails; import com.hakeemit.graphql.service.UserServices; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.graphql.data.method.annotation.Argument; import org.springframework.graphql.data.method.annotation.MutationMapping; import org.springframe...

Spring Boot Mysql Database Tutorial with Example Code - GET/POST/PUT/DELETE

 Learn how to connect to mysql database using spring boot framework. In this article you will learn the different types of @GetMapping/ @PostMapping / @PutMapping and @DeleteMapping Usages and their components @RestController, @Service, @Repository and @Entity. Goto Spring Initializer  https://start.spring.io/ and add the following dependencies like Spring web, JPA, lombok and mysql driver similar to below image Generate the boilerplate code and open the project into your IDE. Follow the below screenshot and create the respective packages to maintain your code easily. Lets Create the follow classes UserController.java package com.hakeemit.database.controller; import com.hakeemit.database.entity.User; import com.hakeemit.database.entity.UserDetails; import com.hakeemit.database.service.UserServices; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController public class UserContr...

Spring Boot Hello World Tutorial - GetMapping REST API

Learn How to get started with Spring boot framework. Create your very first REST API using Spring Boot and the @RestController  @GetMapping annotation. Whether you're new to Java development or just getting started with Spring Boot, this step-by-step guide will help you understand the core concepts and build a simple "Hello World" RESTful API. Go to Spring Initializer  https://start.spring.io/ and fill out the following details similar to below image and add Spring web dependency HelloController.java - Create new package and new class and add the following code into that class package com.hakeemit.hello.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController { @GetMapping("/hello") public String hello(){ return "Hello World"; } } Your project structure will look like this  Once you run the application. Go ...