What is Hasura?
The Hasura GraphQL Engine is a blazing-fast GraphQL server that gives you instant, realtime GraphQL APIs over Postgres, with webhook triggers on database events, and remote schemas for business logic.
Hasura helps you build GraphQL apps backed by Postgres or incrementally move to GraphQL for existing applications using Postgres.
The Hasura GraphQL Engine is open-source. You can check out the complete repo here.
Hasura comes with a lot of features that help you adopt GraphQL and a 3factor architecture quickly:
- Make powerful queries: Built-in filtering, pagination, pattern search, bulk insert, update, delete mutations
- Realtime: Convert any GraphQL query to a live query by using subscriptions
- Merge remote schemas: Access custom GraphQL schemas for business logic via a single GraphQL Engine endpoint. Read more.
- Trigger webhooks or serverless functions: On Postgres insert/update/delete events (read more)
- Works with existing, live databases: Point it to an existing Postgres database to instantly get a ready-to-use GraphQL API
- Fine-grained access control: Dynamic access control that integrates with your auth system (eg: auth0, firebase-auth)
- High-performance & low-footprint: ~15MB docker image; ~50MB RAM @ 1000 req/s; multi-core aware
- Admin UI & Migrations: Admin UI & Rails-inspired schema migrations
- Postgres ❤️: Supports Postgres types (PostGIS/geo-location, etc.), turns views to graphs, trigger stored functions or procedures with mutations
Architecture and performance
The Hasura GraphQL Engine fronts a Postgres database instance and can accept GraphQL requests from your client apps. It can be configured to work with your existing auth system and can handle access control using field-level rules with dynamic variables from your auth system.
You can also merge remote GraphQL schemas and provide a unified GraphQL API.
While designing Hasura, we had two objectives:
- Hasura should be able to run anywhere, from your local machine to the Heroku free tier to a server on Amazon, Google or Microsoft.
- You should be able to extract maximum performance/dollar.
Consequently, we optimised Hasura for low memory footprint & latency. On the Heroku free tier, it consumes ~50MB of RAM even while serving more than ~1000 requests/per second.
If you’re interested in the architecture decisions involved in building this, you can read about it here.
Our aim with the Hasura GraphQL engine is to help you setup a GraphQL server with the least amount of friction, so that you can start building applications without any setup.
With that in mind, here’s how you can deploy Hasura to Heroku in just 30 seconds.
You can also use the Docker container to run it anywhere.
Update: We now have a one-click deploy to DigitalOcean. Other cloud providers will be added soon!
And that’s it! Once you have deployed Hasura, (on Heroku or using Docker), you are now ready to start making GraphQL queries, as realtime GraphQL APIs are automatically generated for your databases. Go ahead, try it out :)
In case you wish to use Hasura as a self-hosted BaaS, we have a tutorial featuring Hasura integrations with an infra provider and an auth provider. Check it out here!
More tutorials, integrations and examples are available here.
In case you are ever stuck, you can reach out to us on Discord (we are extremely active) or by creating a Github issue. You can also follow our Twitter to keep up with updates on Hasura and the company.
We would love more such stories! If you do try Hasura out or use Hasura to build something awesome, let us know via the Discord — it would make our day!