Skip to content

thangchung/practical-dapr

Repository files navigation

practical-dapr

Practical Dapr on Coolstore business model

graphql-api identity-api product-catalog-api

High Level Architecture

Get starting

1. Manual run with Visual Studio or Visual Code

Step 1

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

Step 2

$ dotnet run -p \src\GraphApi\CoolStore.GraphApi\CoolStore.GraphApi.csproj
$ dotnet run -p \src\ProductCatalog\CoolStore.ProductCatalogApi\CoolStore.ProductCatalogApi.csproj

2. Run with Dapr

Step 1

$ cd src\ProductCatalog\CoolStore.ProductCatalogApi
$ dapr run --app-id product-catalog-api --port 5002 --grpc-port 15002 dotnet run
$ cd src\GraphApi\CoolStore.GraphApi
$ dapr run --app-id graphql-api --port 5000 dotnet run

3. Test it

query {
    products(currentPage: 1, highPrice: 1000) {
    id
    name
    imageUrl
  }
}
  • 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": "88ef3cab-5f7e-4111-b151-3fe0d9c20733"
  }
}

Best reference articles