This PR introduces a Categorization System to the library demo. Previously, books were only associated with authors. This change adds a
Category
entity, allowing books to be grouped by genres or topics (e.g., "Fiction", "Science", "Biography").
Summary of changes:
Created a
Category
JPA entity with id, name, and description.
Implemented
CategoryRepository
for data persistence.
Added
CategoryInput
DTO and updated
BookInput
to support linking books to categories via categoryId.
Updated the GraphQL Schema with:
New
Category
type.
Queries:
getAllCategories
,
getCategoryById
.
Mutation:
addCategory
.
Updated
Book
type to include its category details.
Enhanced
BookController
with mapping logic for the new GraphQL endpoints. Fixeskeploy/keploy#3889
Type of change
New feature (non-breaking change which adds functionality)
How Has This Been Tested?
The changes were verified manually using the GraphQL interface (localhost:8081/graphiql) and recorded using Keploy.
Reproduction Steps:
Start the app with Keploy: keploy record -c "./mvnw spring-boot:run"
Create a category:
graphql
mutation { addCategory(category: { name: "Biography", description: "Life stories" }) { id name } }
Create a book linked to that category:
graphql
mutation { addBook(book: { name: "Example Book", pageCount: 100, authorId: 1, categoryId: 1 }) { id name category { name } } }
Fetch all categories to see the linked books:
graphql
query { getAllCategories { name books { name } } }
Additional Context
The implementation preserves the existing functionality of the library demo while providing a foundation for more advanced features like genre-based filtering and search.
Checklist:
My code follows the style guidelines of this project
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation
My changes generate no new warnings
I have added tests that prove my fix is effective or that my feature works
New and existing unit tests pass locally with my changes
Any dependent changes have been merged and published in downstream modules
I have checked my code and corrected any misspellings
I have tagged the reviewers in a comment below incase my pull request is ready for a review
I have signed the commit message to agree to Developer Certificate of Origin (DCO) (to certify that you wrote or otherwise have the right to submit your contribution to the project.) by adding "--signoff" to my git commit command.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Template
GDG CHARUSAT TEAM ID Team 137
Description
This PR introduces a Categorization System to the library demo. Previously, books were only associated with authors. This change adds a
Category
entity, allowing books to be grouped by genres or topics (e.g., "Fiction", "Science", "Biography").
Summary of changes:
Created a
Category
JPA entity with id, name, and description.
Implemented
CategoryRepository
for data persistence.
Added
CategoryInput
DTO and updated
BookInput
to support linking books to categories via categoryId.
Updated the GraphQL Schema with:
New
Category
type.
Queries:
getAllCategories
,
getCategoryById
.
Mutation:
addCategory
.
Updated
Book
type to include its category details.
Enhanced
BookController
with mapping logic for the new GraphQL endpoints.
Fixes keploy/keploy#3889
Type of change
New feature (non-breaking change which adds functionality)
How Has This Been Tested?
The changes were verified manually using the GraphQL interface (localhost:8081/graphiql) and recorded using Keploy.
Reproduction Steps:
Start the app with Keploy: keploy record -c "./mvnw spring-boot:run"
Create a category:
graphql
mutation { addCategory(category: { name: "Biography", description: "Life stories" }) { id name } }
Create a book linked to that category:
graphql
mutation { addBook(book: { name: "Example Book", pageCount: 100, authorId: 1, categoryId: 1 }) { id name category { name } } }
Fetch all categories to see the linked books:
graphql
query { getAllCategories { name books { name } } }
Additional Context
The implementation preserves the existing functionality of the library demo while providing a foundation for more advanced features like genre-based filtering and search.
Checklist:
GDG CHARUSAT TEAM ID Team 137