Create REST APIs on MongoDB in 2 minutes

Connect Hasura to your new or existing MongoDB database and generate high-quality, secure, and performant REST APIs.
Instant GraphQL APIs

Build high-quality GraphQL APIs on MongoDB, instantly

Connect to a new or existing MongoDB database and get standardized, highly composable GraphQL APIs. The Hasura GraphQL Engine introspects the database and automatically generates GraphQL schemas and resolvers based on the MongoDB collections and documents.

GraphQL queries on MongoDB

Leverage the full power of GraphQL API to interact with your MongoDB database for all your read use cases.

Query exactly what you want from your MongoDB collections and documents.

Relationships and nesting

The GraphQL API on MongoDB handles relationships between models, and queries can be nested to any depth if required.

Pagination

Easily manage large datasets with built-in pagination capabilities. Cursor-based, Relay-style, and offset-based pagination is supported natively.

Filtering

Filter query results on Mongo collections / fields using advanced WHERE clauses and Boolean / logical operators like _and / _or, etc.

Sorting

Sort data based on multiple fields in MongoDB collections and specify the sort direction (ascending or descending), making it easy to present your data.

Aggregation

Perform various aggregations to get detailed statistics about your MongoDB data directly within your GraphQL queries. Leverage aggregate functions in MongoDB like count, sum, min, max, avg, etc.

Vector search

Perform similarity, nearest neighbor vector search using native queries.

query fetchUsersAndPosts {
  users(where: { age: { _gt: 18 } }) {
    id
    name
    posts {
      title
      comments {
        text
      }
    }
  }
}
Fetch users' data like the `id` and `name` where the age is > 18, and fetch the `posts` written by them along with the `comments` for each post.

GraphQL mutations on MongoDB

Perform robust data manipulation operations on your MongoDB database with GraphQL mutations. Insert, update, or delete data in MongoDB via Hasura’s native mutations.

mutation {
 insert_artist(id: 100, name: "New Artist") {
   ArtistId
   Name
 }
}
Insert into the artist collection in MongoDB with values for `id` and `name` fields.

High-performance GraphQL APIs, at scale

Hasura takes a domain-driven approach to GraphQL, where a GraphQL query is compiled to a query on a domain model (a database query or existing APIs) resulting in superior API performance.

Hasura leverages the goodness of MongoDB to create efficient GraphQL queries.

Compile vs. resolve

Hasura avoids the GraphQL N+1 query problem by compiling a query instead of resolving. This compiler-based approach allows Hasura to form a single MongoDB aggregation pipeline query for a GraphQL query of any depth and avoids the N+1 problem in GraphQL.

Aggregation pipelines in MongoDB

The MongoDB connector builds efficient query plans using MongoDB aggregation pipelines.

Predicate pushdown database query to MongoDB

Hasura filters data at the source with a predicate pushdown of queries to MongoDB. Hasura can push down a majority of queries like projection, permissions, relationships and joins, arguments, and filtering.

High-performance GraphQL APIs, at scale
Performance benchmarks

Hasura’s GraphQL APIs are faster than handwritten subgraphs on top of MongoDB

Scaling MongoDB with read replicas (coming soon!)

Maximize your MongoDB database performance and scalability with Hasura’s read replicas support.

Easily configure MongoDB read replica set in Hasura to offload read-intensive operations, achieve seamless load balancing, and perform real-time analytics without impacting your primary database.

Configure routing, connection pooling, and load balancing.

Add caching to existing MongoDB APIs for faster response times

Get up to 10x faster API performance on MongoDB with end-to-end caching, scaling vertically and horizontally.

Hasura has metadata about the data models across data sources, and the authorization rules at the application level, which helps provide end-to-end caching.

Production-ready APIs on MongoDB, from day one

Observability

Monitor for known issues by debugging and analyzing metrics from your Hasura instance.

API security

Secure your APIs with tools including allow list, multiple JWT secrets, API rate limits, and more.

Authorization

Make granular read and write access control easy to configure on your MongoDB database with a built-in authorization engine.

Frequently Asked Questions

Can’t find the answer you are looking for? Reach out to our team, and we can help you select the Hasura plan that’s right for you.

Can I use GraphQL with MongoDB Atlas?

How can I secure my GraphQL API for MongoDB?

Can I combine data from MongoDB and other sources in a single GraphQL query?

Can I use GraphQL with existing MongoDB databases?

How does Hasura optimize GraphQL performance for MongoDB?

Contact Us

If you have any more questions about pricing, we’re here to help.

2024 Edition

The GraphQL Handbook

A GraphQL Handbook for developers and architects to help plan your GraphQL adoption journey.
The GraphQL Handbook