Skip to content

giovanoh/products-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Products GraphQL API

A GraphQL API for managing products and categories built with .NET 8 and Hot Chocolate.

🚀 Features

  • GraphQL API with Hot Chocolate
  • Entity Framework Core with SQLite
  • Clean Architecture
  • CRUD operations for Products and Categories
  • Error handling and logging

📋 Prerequisites

  • .NET 8 SDK
  • SQLite (included in the project)
  • Your favorite IDE (VS Code, Visual Studio, Rider, etc.)

🛠️ Setup

  1. Clone the repository:
git clone https://github.com/giovanoh/products-graphql
cd products-graphql
  1. Restore dependencies:
dotnet restore
  1. Run the application:
dotnet run --project src/Products.API

The API will be available at http://localhost:5000/graphql

📚 API Documentation

GraphQL Endpoint

The GraphQL endpoint is available at /graphql. You can use tools like Banana or GraphQL Playground to interact with the API.

Available Operations

Queries

Products:

  • getProducts: List all products
  • getProductById(id: Int!): Get a specific product by ID

Categories:

  • getCategories: List all categories
  • getCategoryById(id: Int!): Get a specific category by ID

Mutations

Products:

  • createProduct(input: ProductInput!): Create a new product
    input ProductInput {
      name: String!
      price: Decimal!
      description: String!
      categoryId: Int!
    }
  • updateProduct(id: Int!, input: UpdateProductInput!): Update an existing product
    input UpdateProductInput {
      name: String
      price: Decimal
      description: String
      categoryId: Int
    }
  • deleteProduct(id: Int!): Delete a product

Categories:

  • createCategory(input: CategoryInput!): Create a new category
    input CategoryInput {
      name: String!
    }
  • updateCategory(id: Int!, input: UpdateCategoryInput!): Update an existing category
    input UpdateCategoryInput {
      name: String
    }
  • deleteCategory(id: Int!): Delete a category

🏗️ Project Structure

src/
├── Products.API/
│   ├── Domain/           # Domain models and interfaces
│   ├── GraphQL/          # GraphQL types, queries, and mutations
│   ├── Infrastructure/   # Data access and external services
│   └── Program.cs        # Application entry point

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

.NET 8 GraphQL API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages