https://github.com/wajid7511/graphqldemo
Built a GraphQL API with ASP.NET Core and HotChocolate, focusing on SQL database integration and code-first schema design. Implemented CRUD operations, pagination, and AutoMapper. Managed EF Core migrations and conducted unit tests with MSTest. Created detailed API documentation and Readme
https://github.com/wajid7511/graphqldemo
automapper code-first-approach docker entity-framework-core graphql graphql-api hotchocolate mongodb netcore producer rabbitmq rabbitmq-consumer sql unittesting webapi worker-service
Last synced: 3 months ago
JSON representation
Built a GraphQL API with ASP.NET Core and HotChocolate, focusing on SQL database integration and code-first schema design. Implemented CRUD operations, pagination, and AutoMapper. Managed EF Core migrations and conducted unit tests with MSTest. Created detailed API documentation and Readme
- Host: GitHub
- URL: https://github.com/wajid7511/graphqldemo
- Owner: wajid7511
- Created: 2023-01-25T20:16:06.000Z (over 2 years ago)
- Default Branch: development
- Last Pushed: 2025-02-14T13:21:49.000Z (3 months ago)
- Last Synced: 2025-02-14T14:28:05.671Z (3 months ago)
- Topics: automapper, code-first-approach, docker, entity-framework-core, graphql, graphql-api, hotchocolate, mongodb, netcore, producer, rabbitmq, rabbitmq-consumer, sql, unittesting, webapi, worker-service
- Language: C#
- Homepage:
- Size: 4.68 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GraphQL API with ASP.NET Core and HotChocolate
## Overview
This project demonstrates the implementation of a GraphQL API using ASP.NET Core and HotChocolate, with a SQL & Mongo database backend. The project employs a Code First approach to define the GraphQL schema and uses AutoMapper to map database entities to the GraphQL schema.
## Features
- **GraphQL HotChocolate**: Provides a powerful and flexible GraphQL server implementation.
- **ASP.NET Core**: Serves as the web framework for building the API.
- **SQL Database**: Stores data for groceries and products.
- **AutoMapper**: Maps database entities to GraphQL schema models.
- **Code First Approach**: Defines GraphQL schema based on C# classes.## GraphQL Schema
### Mutations
1. **AddGrocery**
- Adds a new grocery to the database.
- Input: `GroceryInput` type.
- Output: `GrocerySchema` type.2. **AddProducts**
- Adds a product to a specified grocery.
- Input: `ProductInput` type.
- Output: `ProductSchema` type.3. **AddCustomer**
- Adds a Customer .
- Input: `CustomerInput` type.
- Output: `CustomerSchema` type.### Queries
1. **GetProducts**
- Retrieves a list of products with pagination support.
- Output: List of `ProductSchema` types.
- Pagination: Uses `UseOffsetPaging` to handle page navigation with `pageInfo` that includes `hasNextPage` and `hasPreviousPage`.2. **GetGroceries**
- Retrieves a list of groceries with pagination support.
- Output: List of `GrocerySchema` types.
- Pagination: Uses `UseOffsetPaging` to handle page navigation with `pageInfo` that includes `hasNextPage` and `hasPreviousPage`.3. **GetCustomers**
- Retrieves a list of customers with pagination support.
- Output: List of `CustomerSchema` types.
- Pagination: Uses `UseOffsetPaging` to handle page navigation with `pageInfo` that includes `hasNextPage` and `hasPreviousPage`.## Installation
1. **Clone the Repository**
```bash
git clone
cd
2. **Restore Dependencies**```bash
dotnet restore
```
3. **Configuration**
Database Connection: Ensure your SQL and mongo database connection string is correctly configured in appsettings.json or appsettings.development.json.
**Note** Open Terminal should be open GraphQlDemo folder not Project1. **Add Migration** "nameof Migration Replace with migration name"
```bash
dotnet ef migrations add PriceInProduct --context GraphQlDatabaseContext --output-dir Migrations --project Data/Database/GraphQl.Database.csproj```
2. **Update Database**
```bash
dotnet ef database update --startup-project GraphQlDemo```
4. **Run Application**
```bash
dotnet run
```
5. **Usage**
Open your browser and navigate to https://localhost:7104/graphql/ to interact with the GraphQL API.
Use the GraphQL Playground or any GraphQL client to execute queries and mutations.## Queries and Result Screenshots
You can find the example query and Screenshots in Queries_Result Folder## Contribution
Feel free to fork the repository and submit pull requests with improvements or new features.## License
This project is licensed under the MIT License. See the LICENSE file for details.## Contact
For any questions or feedback, please contact [email protected], Phone Number: +971566290465.