graphql-engine
Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
Top Related Projects
🌍 Spec-compliant and production ready JavaScript GraphQL server that lets you develop in a schema-first way. Built for Express, Connect, Hapi, Koa, and more.
A reference implementation of GraphQL for JavaScript
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
The high-performance database for modern applications
🔮 Graphile's Crystal Monorepo; home to Grafast, PostGraphile, pg-introspection, pg-sql2 and much more!
The open source Firebase alternative. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
Quick Overview
Hasura GraphQL Engine is an open-source tool that automatically creates a real-time GraphQL API for your existing databases. It supports PostgreSQL, MySQL, SQL Server, and BigQuery, offering instant GraphQL APIs with built-in authorization and real-time subscriptions.
Pros
- Instant GraphQL API generation without writing code
- Built-in authorization and access control
- Real-time subscriptions out of the box
- Support for multiple database types
Cons
- Learning curve for complex setups and custom business logic
- Limited customization options for generated APIs
- Potential performance issues with very large datasets
- Dependency on Hasura's ecosystem for certain advanced features
Code Examples
- Basic GraphQL query:
query {
users {
id
name
email
}
}
This query fetches all users with their id, name, and email.
- Mutation to insert data:
mutation {
insert_users(objects: {name: "John Doe", email: "john@example.com"}) {
returning {
id
name
}
}
}
This mutation inserts a new user and returns the id and name of the inserted user.
- Subscription for real-time updates:
subscription {
users {
id
name
email
}
}
This subscription will push updates whenever the users table changes.
Getting Started
- Install Hasura CLI:
curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash
- Initialize a Hasura project:
hasura init my-project
cd my-project
- Start Hasura with Docker:
docker-compose up -d
- Apply migrations and metadata:
hasura migrate apply
hasura metadata apply
- Open the Hasura console:
hasura console
You can now use the Hasura console to manage your GraphQL API and database schema.
Competitor Comparisons
🌍 Spec-compliant and production ready JavaScript GraphQL server that lets you develop in a schema-first way. Built for Express, Connect, Hapi, Koa, and more.
Pros of Apollo Server
- More flexible and customizable for complex GraphQL schemas and resolvers
- Better suited for microservices architectures and custom business logic
- Extensive ecosystem with tools like Apollo Client and Apollo Studio
Cons of Apollo Server
- Requires more manual setup and configuration compared to Hasura
- Less out-of-the-box database integration and automatic CRUD operations
- Steeper learning curve for developers new to GraphQL
Code Comparison
Apollo Server:
const resolvers = {
Query: {
books: () => books,
},
};
const server = new ApolloServer({
typeDefs,
resolvers,
});
Hasura:
tables:
- table:
schema: public
name: books
select_permissions:
- role: user
permission:
columns: [id, title, author]
filter: {}
Apollo Server requires manual definition of resolvers and schema, while Hasura automatically generates GraphQL APIs based on database schema. Apollo Server offers more flexibility for custom logic, but Hasura provides quicker setup for standard CRUD operations.
Apollo Server is better suited for complex, custom GraphQL implementations, while Hasura excels in rapid development of database-driven APIs. The choice between them depends on project requirements, team expertise, and desired level of customization.
A reference implementation of GraphQL for JavaScript
Pros of graphql-js
- More flexible and customizable for building GraphQL servers from scratch
- Lightweight and can be integrated into existing Node.js applications
- Extensive documentation and community support
Cons of graphql-js
- Requires more manual setup and configuration
- Less out-of-the-box features for database integration
- Steeper learning curve for developers new to GraphQL
Code Comparison
graphql-js
const { GraphQLObjectType, GraphQLString, GraphQLSchema } = require('graphql');
const QueryType = new GraphQLObjectType({
name: 'Query',
fields: {
hello: {
type: GraphQLString,
resolve: () => 'Hello, World!'
}
}
});
const schema = new GraphQLSchema({ query: QueryType });
graphql-engine
type: query
name: hello
schema: public
definition:
function: hello_world
output_type: String
graphql-js provides a more programmatic approach to defining GraphQL schemas, while graphql-engine uses a declarative YAML-based configuration. graphql-js offers greater flexibility but requires more code, whereas graphql-engine simplifies schema definition but may be less customizable for complex use cases.
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
Pros of Prisma
- More flexible ORM with support for multiple databases (PostgreSQL, MySQL, SQLite, MongoDB)
- Provides type-safe database access with auto-generated TypeScript types
- Offers a powerful migration system for database schema changes
Cons of Prisma
- Requires more setup and configuration compared to Hasura's instant GraphQL API
- Less built-in support for real-time subscriptions and live queries
- May have a steeper learning curve for developers new to ORMs
Code Comparison
Prisma query example:
const users = await prisma.user.findMany({
where: { age: { gte: 18 } },
include: { posts: true }
})
Hasura GraphQL query example:
query {
users(where: {age: {_gte: 18}}) {
id
name
posts {
title
}
}
}
Both Prisma and GraphQL Engine offer powerful data access capabilities, but Prisma focuses on providing a type-safe ORM experience, while Hasura excels at generating instant GraphQL APIs. Prisma offers more flexibility in terms of database support and migration tools, while Hasura provides a more streamlined setup process and built-in real-time capabilities. The choice between the two depends on specific project requirements and developer preferences.
The high-performance database for modern applications
Pros of Dgraph
- Native graph database with built-in GraphQL support
- Distributed and horizontally scalable architecture
- Supports complex graph queries and traversals
Cons of Dgraph
- Steeper learning curve for developers unfamiliar with graph databases
- Less extensive ecosystem and community support compared to Hasura
- May require more infrastructure management for large-scale deployments
Code Comparison
Dgraph query example:
{
me(func: eq(name, "Alice")) {
name
friend {
name
}
}
}
Hasura query example:
query {
users(where: {name: {_eq: "Alice"}}) {
name
friends {
name
}
}
}
Both examples demonstrate querying for a user named Alice and their friends. Dgraph uses a more graph-oriented syntax, while Hasura follows a traditional GraphQL structure with PostgreSQL-like filters.
Dgraph is better suited for complex graph relationships and traversals, while Hasura excels in scenarios where you need to quickly set up a GraphQL API on top of existing relational databases. The choice between the two depends on your specific use case, existing infrastructure, and team expertise.
🔮 Graphile's Crystal Monorepo; home to Grafast, PostGraphile, pg-introspection, pg-sql2 and much more!
Pros of Crystal
- More flexible and customizable schema generation
- Better support for complex PostgreSQL features
- Lighter weight and potentially faster performance
Cons of Crystal
- Smaller community and ecosystem compared to Graphql-engine
- Less comprehensive documentation and tutorials
- Steeper learning curve for beginners
Code Comparison
Crystal:
class Query < GraphQL::Schema::Object
field :users, [Types::User], null: false
def users
User.all
end
end
Graphql-engine:
- table:
schema: public
name: users
select_permissions:
- role: user
permission:
columns: '*'
filter: {}
Crystal offers more programmatic control over schema definition, while Graphql-engine uses a declarative YAML-based approach. Crystal's code is more verbose but provides greater flexibility, whereas Graphql-engine's configuration is more concise but potentially less customizable.
Both projects aim to simplify GraphQL API development, but they take different approaches. Crystal focuses on leveraging PostgreSQL features and providing a powerful toolkit for developers, while Graphql-engine emphasizes ease of use and rapid development through its auto-generated APIs and permissions system.
Ultimately, the choice between Crystal and Graphql-engine depends on project requirements, team expertise, and desired level of control over the GraphQL implementation.
The open source Firebase alternative. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
Pros of Supabase
- Offers a more comprehensive suite of features, including authentication, storage, and real-time subscriptions
- Provides a user-friendly interface for database management and API exploration
- Supports multiple programming languages and frameworks out of the box
Cons of Supabase
- Less mature and battle-tested compared to GraphQL Engine
- May have a steeper learning curve for developers new to the Supabase ecosystem
- Limited customization options for complex GraphQL schemas
Code Comparison
GraphQL Engine query:
query {
users(where: {is_active: {_eq: true}}) {
id
name
email
}
}
Supabase query:
const { data, error } = await supabase
.from('users')
.select('id, name, email')
.eq('is_active', true)
Both repositories provide powerful tools for building backend services, but they differ in their approach and feature set. GraphQL Engine focuses primarily on GraphQL API generation, while Supabase offers a broader range of features for building full-stack applications. The choice between the two depends on project requirements, team expertise, and desired level of customization.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Hasura GraphQL Engine
The Hasura engine is an open source project which supercharges the building of modern applications by providing access to data via a single, composable, secure API endpoint.
Hasura V3
The future of data delivery is GA: Supporting PostgreSQL (and its flavors), MongoDB, ClickHouse, and MS SQL Server. Also supports writing custom business logic using the Typescript, Python, and Go Connector SDKs. Here is the recommended Getting Started guide on DDN.
The Hasura v3 engine code, which powers Hasura DDN, is in the v3
folder of this repo. You can find more detailed
information about in this v3 README.
The Hasura DDN architecture includes Data Connectors to connect to data sources. All Hasura connectors are also available completely open source. Check out the Connector Hub which lists all available connectors.
Hasura V2
Hasura V2 is the current stable version of the Hasura GraphQL Engine. Please find more
detailed information about the V2 Hasura Graphql Engine in the v2
folder and this README.
Cloning repository
This repository is a large and active mono-repo containing many parts of the Hasura ecosystem and a long git history, that can make the first time cloning of the repository slow and consume a lot of disk space. We recommend following if you are facing cloning issues.
Shallow clone
This will only clone the latest commit and ignore all historical commits.
git clone https://github.com/hasura/graphql-engine.git --depth 1
Git checkout with only Hasura V3 engine code
git clone --no-checkout https://github.com/hasura/graphql-engine.git --depth 1
cd graphql-engine
git sparse-checkout init --cone
git sparse-checkout set v3
git checkout @
This checkouts the top level files and only the v3
folder which contains the Hasura V3 Engine code.
Support & Troubleshooting
To troubleshoot most issues, check out our documentation and community resources. If you have encountered a bug or need to get in touch with us, you can contact us using one of the following channels:
- Hasura DDN documentation: DDN docs
- Hasura V2 documentation: V2 docs
- Support & feedback: Discord
- Issue & bug tracking: GitHub issues
- Follow product updates: @HasuraHQ
- Talk to us on our website chat
Code of Conduct
We are committed to fostering an open and welcoming environment in the community. Please see the Code of Conduct.
Security
If you want to report a security issue, please read this.
Stay up to date
Join our communities to stay up to date on announcements, events, product updates, and technical blogs. https://hasura.io/community/
Contributing
Check out our contributing guide for more details.
Brand assets
Hasura brand assets (logos, the Hasura mascot, powered by badges etc.) can be found in the v2/assets/brand folder. Feel free to use them in your application/website etc. We'd be thrilled if you add the "Powered by Hasura" badge to your applications built using Hasura. â¤ï¸
Licenses
V3
All the Data Connectors are available under the Apache License 2.0.
The core V3 GraphQL Engine is intended to be licensed under the Apache License 2.0 (Apache-2.0).
V2
The V2 core GraphQL Engine is available under the Apache License 2.0 (Apache-2.0).
All other contents in the v2 folder (except those in server
, cli
and
console
directories) are available under the MIT License.
This includes everything in the docs
and community
directories.
Top Related Projects
🌍 Spec-compliant and production ready JavaScript GraphQL server that lets you develop in a schema-first way. Built for Express, Connect, Hapi, Koa, and more.
A reference implementation of GraphQL for JavaScript
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
The high-performance database for modern applications
🔮 Graphile's Crystal Monorepo; home to Grafast, PostGraphile, pg-introspection, pg-sql2 and much more!
The open source Firebase alternative. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot