Announcing our MongoDB Data Connector (Beta)
Tags: dataconnector, mongodb, graphql
Published: 2023-07-27 11:04:36

---
title: Announcing our MongoDB Data Connector (Beta)
published: true
date: 2023-06-21 16:30:00 UTC
tags: DataConnector,MongoDB,GraphQL
canonical_url: https://hasura.io/blog/announcing-mongodb-data-connector-beta/
---

 ![Announcing our MongoDB Data Connector (Beta)](https://hasura.io/blog/content/images/2023/06/MongoDB-social.png)

Having trouble querying your data using MongoDB? Wrestling with the setup of your authentication and data authorization layer for your API? Need to query data from multiple sources?

We've got your back.

_Introducing MongoDB Data Connector support for Hasura_

## Introducing Hasura for NoSQL

We're thrilled to announce our first foray into NoSQL and GraphQL, starting with a beta launch of our MongoDB data connector. This marks a new chapter in our journey to streamline your work and boost developer efficiency.

Our initial focus is on performant reads. You can now track Collections as effortlessly as you would with Tables + Views from Postgres. Plus, we allow you to auto-generate your types using your MongoDB validation schema, simplifying your workflow even further.

We've even got a [request for comment](https://github.com/hasura/graphql-engine/tree/master/rfcs/nosql-schema-sampling) on how we can streamline this even further by using sampling to help you generate your API even quicker, and would love to hear more from you.

## First-class performance

In addition to auto-generating your API, we're dedicated to delivering quick and efficient service by embracing the pillars that made Hasura great for other data sources, **transferring less unnecessary data** and **reducing the number of roundtrip requests**.

This is made possible through field projection, which fetches only necessary fields, permission predicate pushdowns to the database, and we are soon introducing optimizations for cross-Collection relationships.   
We're talking about `$lookups` and more – stay tuned for these exciting updates.

## Getting started with Hasura and MongoDB
<!--kg-card-begin: html--><video controls="">
  <source src="https://graphql-engine-cdn.hasura.io/assets/blog/videos/mongodb-track-query.mp4" type="video/mp4">
Your browser does not support the video tag.
</source></video><!--kg-card-end: html-->
### Connecting your database

To connect your MongoDB database, you can follow the following steps:

<!--kg-card-begin: markdown-->
- Go to **Data > Manage** in your application.
- Check if your MongoDB data connector is pre-connected to your Hasura instance. You can do this by selecting the Data Connector Agents dropdown from the Data Manager.
- If the MongoDB data connector is not connected and you have used the docker-compose.yml file mentioned above, use the following details to connect to your agent:
  - **Agent Name:** mongodb
  - **URL:** [http://mongo-data-connector:3000](http://mongo-data-connector:3000)
<!--kg-card-end: markdown-->

![Announcing our MongoDB Data Connector (Beta)](https://lh3.googleusercontent.com/k--Jgqt4tcEo1tkOao_7OI1mlNexGUszNQ6cLGZdavDh6dMdrD7c3cVQ5usW_GRgrliGcL4mPp3umTRk9HDwq8tccfWjdIt535kgK74EaDlrseTfyhhgL9_gWSOsbPP9AmjTtEMU2EH9JvTO3hGJm88)

<!--kg-card-begin: markdown-->
- After that, you can click Connect Database to continue to the database connection screen.
- If you’re using the provided docker-compose.yml file you can connect your database using the following credentials:
  - **Database Name:** mongodb
  - **Connection:** mongodb://mongouser:mongopassword@mongodb:27017
  - **db:** demo
<!--kg-card-end: markdown-->
### Track your first Collection

We “Track” objects in Hasura in order to add them to your GraphQL API:

1. Once your database is connected, select the database name from the left-hand sidebar.
2. You will see your collections listed here. Choose a collection and click on "Track Selected."
3. Congratulations! Your selected collection is now added to your GraphQL API.

![Announcing our MongoDB Data Connector (Beta)](https://lh4.googleusercontent.com/HkeuzmXFfMWLH29gaTLtHxOMrHW_yf1U4yORz-PjpEU304z1ip6Pel7sSXsdizMLOkYSUsX-WgUl4t1tXY9CyqlmKNPldqPHz_pJcyjQfdlvlTHawXWFLrc4Z01qKI6TjZutBSYP3VCJ6JVGtMPuzFg)

### Run your first query

You can also test your GraphQL queries using the Hasura Console:

- In the header, select "API" to go to GraphiQL, our API testing utility.
- Utilize the explorer located on the left-hand sidebar to assist you in composing your query (the resulting query will be populated in the body area).
- When you’re ready, click on the play button to execute your GraphQL query.
- Your query’s result will be populated in the right-hand column of the interface.

![Announcing our MongoDB Data Connector (Beta)](https://lh5.googleusercontent.com/AEqUnff6TvHD5kzrGBqJp--XqfTBkn6nNBKXqsoz6_cIvXaw_xJO8tFjYYRMgxtRHcmHwCfv4Q8L_bRPtKxLqliccgsXzyVivTOWkgjz5KiD4ueGMxckVKpyhj8FXrq3xu-_htBOMfOVdhYxPwklCeA)

Congratulations! You have successfully run your first GraphQL query with Hasura and MongoDB.

## Current features

Our MongoDB integration introduces several features to enhance your database operations.

Here are the initial capabilities currently available:

- **Schema Generation:** We support tracking collections containing a validation schema. This schema serves as the backbone for generating your GraphQL schema.
- **Document Filtering:** Enjoy the convenience of filtering on top-level fields within your documents. This feature allows you to access and manage only the data you require.
- **Field-Level Permissions:** Security is paramount. We've incorporated permissions on the same top-level fields, reinforcing an additional layer of data protection.
- **Federated Relationships:** Experience the power of connecting your data sources. We enable federated relationships from MongoDB to other data sources such as PostgreSQL, enhancing the interconnectivity of your data.

## And, we're not done. There's more coming soon!

And we're just getting started.

We're committed to a cycle of continuous improvements, and we're excited to give you a sneak peek of what's coming soon:

- 🗂️ Enhanced querying and permissions for embedded documents
- 🔗 Improved cross-collection relationships
- 🔗 Improved cross-datasource relationships (inbound joins _to_ MongoDB, currently supporting _from_ MongoDB)
- 🤝 A customizable GraphQL schema, moving beyond the dependency on validation schemas
- and the freedom to create your own logical models, providing a powerful escape-hatch from any 🪄 auto-magic

**Curious to explore our Mongo support? Visit our [docs here](https://hasura.io/docs/latest/databases/mongodb/index/) to connect your first MongoDB data source.**