Introduction
ShopNest public partners use REST; internal services use gRPC; mobile apps may prefer GraphQL (Hot Chocolate) — choose the right protocol per client.
After this article you will
- Compare REST vs gRPC vs GraphQL honestly
- Add Hot Chocolate GraphQL endpoint
- GraphQL queries, mutations, subscriptions
- OData for rich REST querying
- Multi-protocol gateway pattern
Prerequisites
- Article 71 — Blazor Complete Guide
- Articles 1–64 ShopNest foundations (MVC, EF Core, API, auth, deploy)
Architecture & design
| Style | Strength | ShopNest use |
|---|---|---|
| REST | Universal, cacheable | Public catalog API |
| gRPC | Speed, contracts | Inventory ↔ Warehouse |
| GraphQL | Flexible queries | Mobile app varied screens |
// Hot Chocolate — Program.cs
builder.Services.AddGraphQLServer()
.AddQueryType<Query>()
.AddMutationType<Mutation>()
.AddSubscriptionType<Subscription>();Hands-on build guide — ShopNest Multi-Protocol API Gateway
- GraphQL /graphql endpoint for products + categories.
- gRPC InventoryService from Article 53 side-by-side.
- YARP gateway routes /api → REST, /graphql → GraphQL.
Common pitfalls
- GraphQL N+1 queries — use DataLoader.
- Exposing GraphQL without auth — depth/complexity limits required.
Interview & portfolio questions
Q: When GraphQL?
A: Many clients need different field sets — one endpoint, client specifies shape.
Summary
- Not every API must be REST — match protocol to client
- ShopNest uses REST public + gRPC internal
- GraphQL optional for mobile flexibility
Previous: Blazor Complete Guide
Next: Rate Limiting
FAQ
OData still used?
Yes for enterprise REST clients wanting $filter/$expand.
GraphQL subscriptions?
WebSocket transport — similar plumbing to SignalR.