ConfigsApr 10, 2026·3 min read

Hasura — Instant GraphQL & REST APIs on Your Database

Hasura generates instant, real-time GraphQL and REST APIs on PostgreSQL, MySQL, SQL Server, and MongoDB with fine-grained access control, event triggers, and remote schemas.

TL;DR
Hasura auto-generates real-time GraphQL and REST APIs from your database with fine-grained access.
§01

What it is

Hasura generates instant, real-time GraphQL and REST APIs on top of PostgreSQL, MySQL, SQL Server, and MongoDB. Point it at your database, and it creates a complete API with queries, mutations, subscriptions, and fine-grained access control. No backend code required for standard CRUD operations. Event triggers, remote schemas, and actions extend functionality when needed.

This tool is for backend developers who want to skip writing boilerplate API code. Frontend developers can use it to get a fully functional API without waiting for backend implementation.

§02

How it saves time or tokens

Hasura eliminates the need to write API endpoints, resolvers, and data-fetching code for standard database operations. What takes days with a custom backend takes minutes with Hasura. Real-time subscriptions are built in, avoiding WebSocket infrastructure setup. The permission system handles authorization at the API level.

§03

How to use

  1. Deploy Hasura via Docker.
  2. Connect your database.
  3. Track tables and relationships.
  4. Access the auto-generated API.
# Start Hasura with Docker
docker run -d -p 8080:8080 \
  -e HASURA_GRAPHQL_DATABASE_URL='postgresql://user:pass@host:5432/db' \
  -e HASURA_GRAPHQL_ENABLE_CONSOLE=true \
  -e HASURA_GRAPHQL_ADMIN_SECRET='mysecret' \
  hasura/graphql-engine:latest

# Access console at http://localhost:8080/console
§04

Example

After connecting a database with a users table:

# Auto-generated query
query {
  users(where: { active: { _eq: true } }, order_by: { created_at: desc }, limit: 10) {
    id
    name
    email
    created_at
    orders {
      id
      total
    }
  }
}

# Real-time subscription
subscription {
  users(where: { role: { _eq: "admin" } }) {
    id
    name
    last_seen
  }
}

# Mutation
mutation {
  insert_users_one(object: { name: "Alice", email: "alice@example.com" }) {
    id
  }
}

All generated from your database schema. No code written.

§05

Related on TokRepo

§06

Common pitfalls

  • Hasura exposes your database schema as an API. Design your database schema with the API surface in mind.
  • Complex business logic does not belong in Hasura permissions. Use actions or event triggers to call custom backend functions.
  • The permission system is powerful but complex. Test permissions thoroughly to avoid data exposure.
  • Real-time subscriptions create persistent connections. Plan for connection limits on your database.
  • Hasura adds a dependency between your database schema and API consumers. Schema migrations need coordination.
  • Review the official documentation before deploying to production to ensure compatibility with your specific environment and requirements.

Frequently Asked Questions

Does Hasura require writing backend code?+

No for standard CRUD operations. Hasura generates queries, mutations, and subscriptions automatically. For custom business logic, use Hasura Actions (call external APIs) or Event Triggers (react to database changes).

How does Hasura handle authorization?+

Hasura uses a role-based permission system. Define row-level and column-level permissions per role. Permissions are enforced at the database query level, ensuring they cannot be bypassed.

Does Hasura support REST APIs?+

Yes. Hasura can generate REST endpoints from your GraphQL queries. Define a REST endpoint that maps to a specific GraphQL query or mutation for teams that prefer REST.

Can I use Hasura with an existing database?+

Yes. Connect Hasura to your existing database and track the tables you want to expose. Hasura reads your schema and generates the API without modifying your data.

Is Hasura suitable for production?+

Yes. Hasura is used in production by many companies. The cloud offering provides high availability, monitoring, and support. Self-hosted deployments need proper scaling and security configuration.

Citations (3)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets