Skip to content

[feature]: Add a virtual field bookCount #3890

@hindochahitarth

Description

@hindochahitarth

👀 Is there an existing feature request for this?

  • I have searched the existing issues

🔖 Enhancement description

Problem
When viewing an author, there is no quick way to see how many books they have written without fetching the entire list of books. This information is often needed for high-level summaries or author profiles.

Proposed Solution
Add a virtual field bookCount to the

Author
type in the GraphQL schema.

GraphQL Schema:
graphql
type Author {
id: ID
firstName: String
lastName: String
bookCount: Int # New Field
books: [Book]
}
Controller/Entity:
Add a method in the

BookController
or update the

Author
entity to calculate the size of the books list.
Expected Behavior
When querying an author, the user can request the bookCount field.
The system returns the integer count of books associated with that author.

🎤 Why should this be worked on?

Data Efficiency: Allows clients to get aggregate data (count) without the overhead of transferring the full list of books.
Improved UX: Useful for UI components that display author statistics.
💻 Repository spring-boot-postgres-graphql

GDG CHARUSAT TEAM : T137

💻 Repository

keploy

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions