Skip to content

thangchung/practical-dapr

Repository files navigation

practical-dapr

Practical Dapr on Coolstore business model

Price graphql-api identity-api product-catalog-api inventory-api

Docker images

Give a Star! ⭐

If you liked practical-dapr project or if it helped you, please give a star ⭐ for this repository. That will not only help strengthen our .NET community but also improve cloud-native apps development skills for .NET developers in around the world. Thank you very much 👍

High Level Architecture

Communication Style

Get starting

Start required components

$ docker-compose -f docker-compose.yml -f docker-compose.override.yml run sqlserver

Run projects with Dapr CLI

$ cd src\GraphApi\CoolStore.GraphApi
$ dapr run --app-id graphql-api --port 5102 --app-port 5101 dotnet run
$ cd src\ProductCatalog\CoolStore.ProductCatalogApi
$ dapr run --app-id product-catalog-api --port 5202 --app-port 5201 dotnet run
$ cd src\Inventory\CoolStore.InventoryApi
$ dapr run --app-id inventory-api --grpc-port 5303 --port 5302 --app-port 5301 dotnet run

Run with tye on local development

$ type run

Test it

Query

query {
    products(
    page: 1
    pageSize: 5
    where: { price_lte: 10000 }
    order_by: { price: DESC }
  ) {
    edges {
      id
      name
      imageUrl
      price
      categoryId
      categoryName
      inventoryId
      inventoryLocation
    }
    totalCount
  }
}

Mutation

mutation createProductMutation($createProductInput: CreateProductInput!) {
  createProduct(createProductInput: $createProductInput) {
    product {
      id
      name
    }
  }
}
{
  "createProductInput": {
    "name": "product 1",
    "description": "this is a description",
    "imageUrl": "https://picsum.photos/1200/900?image=100",
    "price": 100,
    "categoryId": "77666AA8-682C-4047-B075-04839281630A",
    "inventoryId": "90C9479E-A11C-4D6D-AAAA-0405B6C0EFCD"
  }
}

Setup Azure

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :p