This is a GraphQL API for retrieving restaurant menu data.
NestJS was chosen for this project due to its modular architecture, dependency injection, and built-in support for GraphQL. These features make it an excellent choice for building scalable and maintainable APIs. The structured approach provided by NestJS ensures clear separation of concerns, which simplifies testing and future enhancements.
- GraphQL Resolvers: Handle incoming queries (
getCategories
,getMenuItems
) and delegate logic to the service layer. - Service Layer: Processes menu-related operations and interacts with static data or, in a real-world scenario, a database.
- Static Data: Stored in
menu-data.ts
, representing a predefined dataset for the restaurant's menu.
- Clone the repository.
- Install dependencies:
npm install
- Start the server:
npm run start
Run unit tests: npm run test
Run e2e tests: npm run test:e2e
Visit http://localhost:8080/graphql
and use the GraphQL Playground to test queries.
query { getCategories { name items { name price } } }
Fetching Menu Items for a Specific Category: Returns menu items for the specified category (e.g., "Appetizers").
query { getMenuItems(categoryName: "Appetizers") { name price } }
query { getMenuItems(categoryName: "NonExistentCategory") { name price } }