GraphQL is a modern replacement for the well known REST API server. This is a pure GraphQL server application - an example API server.
This is a sample graphql spring boot project. This project has implemented all the crud operations in a simple way.
- Java 17
- Spring Boot 2.7.4
- Gradle 7.5.1
- GraphQL Java
- Input data validation.
- Custom Exception
git clone https://github.com/codeprismtechnologies/starter-graphql-springboot.git
- Make sure you are using Java version 11 or 17
- Install and start MySQL server
- Make sure using gradle version using 7+
- After cloning project. Refresh gradle once.
- Run project as springboot application
- To start executing queries using graphiql/playground. Copy any url(playground recommended) from below and open in any browser Safari/Chrome/Mozilla..etc
http://localhost:9090/playground
http://localhost:9090/graphiql
To create new user:
mutation{
signUp(user:{
displayName:"your nyce name"
firebaseId:"123HFN",
email:"your email",
phoneNumber:"1234567890",
dateOfBirth:"2022-01-10",
gender:MALE,
profileUrl:"your profile url",
loginStatus:LOGGEDIN,
role:USER,
provider:FACEBOOK,
language:"your language code",
heartPoints:2.0,
state:"your state name",
country:"your country code",
city:"your city name",
address:"your full address",
passportId:"your passport id",
taxId:"your tax Id",
postalId:"your postal id",
timeZone:"Etc/UTC",
cityZenShipCountry:"INDIA",
lastLogin:"2020-04-03 12:10:00"
}){
id
displayName
.......
}
}
To update user details:
mutation{
updateSignUp(user:{
userId:1
displayName:"your updated nyce name"
firebaseId:"123HFN",
email:"your email",
phoneNumber:"1234567890",
dateOfBirth:"2022-01-10",
gender:MALE,
profileUrl:"your profile url",
loginStatus:LOGGEDIN,
role:USER,
provider:FACEBOOK,
language:"your language code",
heartPoints:2.0,
state:"your state name",
country:"your country code",
city:"your city name",
address:"your full address",
passportId:"your passport id",
taxId:"your tax Id",
postalId:"your postal id",
timeZone:"Etc/UTC",
cityZenShipCountry:"INDIA",
lastLogin:"2020-04-03 12:10:00"
}){
id
displayName
......
}
}
To Get user details:
query{
getUser(userId:1){
id
displayName
profileUrl
phoneNumber
.....
}
}
To GetAll user details:
# you can put count acording to your choice
query{
getAllUser(count:2){
id
displayName
profileUrl
phoneNumber
}
}
To Delete user:
mutation{
deleteUser(userId:2)
}