GraphQL Spring Boot Application for User and Post Management - Demonstrating efficient user and post management with precise data queries
Schema definition and query/mutation handling
Data fetching and relationship resolution
Business logic and transaction management
Data access and persistence
Entity definitions and relationships
query {
getUser(id: "1") {
id
name
email
posts {
id
title
}
}
}
query {
getUsersPaged(page: 0, size: 2) {
id
name
email
}
}
query {
getPostsByUser(userId: "1") {
id
title
content
}
}
query {
getAllUsers {
id
name
email
}
}
mutation {
createUser(input: {
name: "Alice Johnson",
email: "alice@example.com"
}) {
id
name
email
}
}
mutation {
createPost(input: {
title: "GraphQL with Spring",
content: "Content goes here",
authorId: "1"
}) {
id
title
author {
id
name
}
}
}
Test the API using Postman with either:
{
"query": "query { getUser(id: \"1\") { id name } }"
}
Access the in-memory database console at:
http://localhost:8080/h2-console
JDBC URL: jdbc:h2:mem:testdb
Username: sa (no password)
git clone https://github.com/PritiAryal/UserLookup.git cd UserLookup
mvn clean install
mvn spring-boot:run
http://localhost:8080/graphql