Why and When to Use Hasura with Graph API and Hot Chocolate
Movie DB, SQL backend, REST actor API — one GraphQL layer on top. How I wired Hasura + Hot Chocolate without losing the plot.
Press Listen. A recorded voice reads the article, lights the current word, and keeps that word in view.
How listen mode works
The recording is a neural voice, not your browser's speech engine. The word being spoken lights up from the audio clock, including after you pause, drag the bar, or change speed. If you chose UK and only the US recording exists, you hear the US voice. Leaving the page stops playback.
When You Have Too Many Data Sources
You’ve got a SQL database (movie details), a REST API (actor bios), and a second REST API (showtimes). Your frontend wants a single endpoint that talks to all three. REST layering gets ugly fast. GraphQL fixes this — one query language, one endpoint, but you need to wire it right.
Hasura auto-generates GraphQL from databases. Hot Chocolate lets you build custom GraphQL resolvers in .NET. Use them together and you get the speed of auto-generation plus the flexibility to call external APIs. Here’s when and how.
Hasura is a powerful tool for generating GraphQL APIs from your existing databases. It automates much of the boilerplate code and provides real-time capabilities, making it an excellent choice for quickly building scalable and maintainable GraphQL backends.
Hot Chocolate is an open-source GraphQL server for the .NET platform. It simplifies the process of building GraphQL APIs by providing built-in features for queries, mutations, and subscriptions.
Use Case Example:
Imagine you are building a movie database application. You want to query data from multiple sources, such as a SQL database for movie details and a REST API for actor biographies. Here’s how you can use Hasura and Hot Chocolate together:
- Set Up Hasura: Connect Hasura to your SQL database to auto-generate a GraphQL API for your movie data.
- Create a GraphQL Server with Hot Chocolate: Use Hot Chocolate to build a custom GraphQL server that fetches actor biographies from the REST API.
- Integrate with Hasura: Use Hasura’s Remote Schema feature to merge the Hot Chocolate GraphQL server with the Hasura-generated schema, providing a unified GraphQL API.
Why Not Apollo or Another GraphQL Client?
Apollo is another popular GraphQL client and server solution. It offers a robust ecosystem for building and managing GraphQL APIs. However, there are some differences between Hasura and Apollo that might influence your choice:
| Feature | Hasura | Apollo |
|---|---|---|
| Setup Time | Quick setup with auto-generated APIs | Requires more manual setup and coding |
| Real-time Capabilities | Built-in real-time subscriptions | Requires additional setup for real-time |
| Data Source Integration | Direct integration with databases and REST APIs | Primarily focuses on schema-first approach |
| Authorization | Declarative, built-in authorization | Custom implementation needed |
| Performance | Optimized for high performance | Performance depends on custom implementation |
| Community Support | Growing community, strong support | Large, established community |
Why Choose Hasura?
- Speed: Quickly go from data source to production-ready GraphQL API without writing resolvers[^1^].
- Real-time: Built-in real-time capabilities without additional setup[^5^].
- Unified API: Easily merge multiple data sources into a single GraphQL endpoint[^1^].
Why Choose Apollo?
- Flexibility: Highly customizable and flexible for complex use cases[^7^].
- Ecosystem: Extensive tools and libraries for both client and server-side development[^7^].
Choosing between Hasura and Apollo depends on your specific needs and project requirements. If you need a quick, real-time, and database-integrated solution, Hasura is a great choice. If you require more customization and flexibility, Apollo might be more suitable.
The Real Win: Stop Rebuilding the Same Plumbing
The moment I used Hasura + Hot Chocolate together, I stopped writing boilerplate resolver code. Hasura handled the database queries. Hot Chocolate handled the external API calls. The result was a clean, unified GraphQL API in hours, not weeks. If your architecture has multiple data sources, this pattern is worth its weight.
Sources & Further Reading
- Getting Started with Hot Chocolate + Hasura Remote Schema
- GraphQL Server with .NET — Hasura Tutorial
- Hasura vs Apollo — platform comparison
- Hot Chocolate — .NET GraphQL server
See also: Why Choose Hasura Over Other Tools (Sep 2024) · Mastering GraphQL (Sep 2024)
Add a thought
The writing box stays shut until the code matches. A note you save shows up under this article on this browser. It is not emailed. Posting it for everyone opens GitHub, which asks you to sign in.