Announcing our MongoDB Data Connector (Beta)
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 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 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
Your browser does not support the video tag.
Connecting your database
To connect your MongoDB database, you can follow the following steps:
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:
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:[email protected]:27017
db: demo
Track your first Collection
We “Track” objects in Hasura in order to add them to your GraphQL API:
Once your database is connected, select the database name from the left-hand sidebar.
You will see your collections listed here. Choose a collection and click on “Track Selected.”
Congratulations! Your selected collection is now added to your GraphQL API.
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.
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 to connect your first MongoDB data source.
Originally published at https://hasura.io on June 21, 2023.
Subscribe to my newsletter
Read articles from Community Hasura directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by