Sample Book Recommendation App using GraphQL / SpringBoot / JPA / MapStruct / H2
- Author (name, email , city , state , country)
- Book (id , name , authors ,genres, sample,awards)
- BookReview (book,reviewer,rating)
- Book to Author (Many to Many)
- Book to Review (One to Many)
- Create Author
mutation {
createAuthor(name: "Author1", email: "[email protected]", city: "C" , state: "S", country: "CC") { name, email }
}
- Create Book
mutation {
createBook(name: "Graph QL", authors: [1,2], genres: "Technology", awards: ["NY Best Seller","Best Book of Year"]) { id , name }
}
mutation {
createBook(name: "Big Nate", authors: [1], genres: "Children", sample: "Sample chapters from the book") { id , name }
}
- Create Review
mutation {
createReview(book: 1, reviewer: "rev1", rating: 2) { book {name} , rating, reviewer }
}
- Query for Book Recommendation
query {
recommendBook(authorname: "Author1") { book {id, name} , rating }
}
- Update Book to Add awards
mutation {
updateBook(id: 2, awards: ["Best Kids Book of Year"]) { name, awards }
}
mvn spring-boot:run
$ curl \
> --request POST 'localhost:8080/graphql' \
> --header 'Content-Type: application/json' \
> --data-raw '{"query":"mutation {\n createAuthor(name: \"Author1\", email: \"[email protected]\", city: \"C\" , state: \"S\", country: \"CC\") { name, email }\n}"}'