Hasura instantly generates a GraphQL API from your PostgreSQL database. Full CRUD, real-time subscriptions, and authorization — zero backend code.
Setup
docker compose up -d
# Console at http://localhost:8080
Auto-Generated Queries
Once you connect your database, every table gets GraphQL operations:
# List with filtering and pagination
query {
users(where: {active: {_eq: true}}, order_by: {created_at: desc}, limit: 10) {
id
name
email
posts(where: {published: {_eq: true}}) {
title
views
}
}
}
# Insert
mutation {
insert_users_one(object: {name: "Alice", email: "alice@example.com"}) {
id
created_at
}
}
# Update
mutation {
update_users_by_pk(pk_columns: {id: 1}, _set: {name: "Bob"}) {
id
name
}
}
Real-Time Subscriptions
subscription {
messages(order_by: {created_at: desc}, limit: 10) {
id
text
user {
name
}
created_at
}
}
Actions (Custom Business Logic)
# Define in Hasura console
type Mutation {
processPayment(amount: Float!, userId: Int!): PaymentResult
}
// Your webhook handler
app.post('/api/process-payment', async (req, res) => {
const { amount, userId } = req.body.input;
const result = await stripe.charges.create({ amount: amount * 100 });
res.json({ transactionId: result.id, status: 'success' });
});
REST API (from GraphQL)
# Hasura also exposes REST endpoints
curl http://localhost:8080/api/rest/users \
-H "x-hasura-admin-secret: your-secret"
Why This Matters
- Instant API: Connect database, get GraphQL in seconds
- Real-time: WebSocket subscriptions on any table
- Authorization: Row-level permissions per role
- Performance: Compiles GraphQL to single SQL query
Need custom GraphQL APIs or database tooling? I build developer tools. Check out my web scraping actors on Apify or reach out at spinov001@gmail.com for custom solutions.
Top comments (0)