MongoDB Unveils Managed GraphQL for MongoDB Atlas
NoSQL database provider MongoDB has launched support for the GraphQL API-based query language to its managed cloud database, MongoDB Atlas, as an integration with MongoDB Stitch, which acts as both the GraphQL client and server, sending, receiving, and processing requests.
GraphQL provides an alternative to the widely used REST API and differs by offering a declarative query ability via API as opposed to REST’s method, which responds to a query with a full payload of information, rather than specific data requested. As such, GraphQL allows for smaller payloads, faster responses, and more efficient code, something the company emphasizes in its blog post introducing the feature.
In talking about the launch, however, MongoDB Chief Technology Officer and co-founder Eliot Horowitz puts the focus on the developer experience and the end result, rather than the machinations.
“Developers want to not manage infrastructure. They want to have clean abstractions that make it easy to scale and easy to think about what’s going to happen in their application,” said Horowitz. “Services like this are a way to say, what can I offload entirely so I don’t have to think about it, maintain it, monitor it, do security patches for it — it just works. Everything developers care about is time to market, how fast they can build applications, how fast they can innovate. Everything’s about making this easier and easier as applications get more and more complicated. ”
Combined with the Realm mobile database and data synchronization technology that MongoDB acquired in 2019, the added GraphQL functionality will make it easier than ever for MongoDB users to build web applications that function across multiple devices, Horowitz says. GraphQL support is provided via Stitch, which handles back-end functionality such as user authentication and field-level security, while Realm handles mobile data synchronization, and MongoDB sits as the common denominator at the center of the data layer.
“Stitch is a very thin layer on top of MongoDB designed to make it really easy to build web applications. Most applications today are most web applications. The tendency is to do single-page React applications that have some sort of an API back to data and to third party services,” said Horowitz. “Stitch was all about putting a layer on top of MongoDB that handles things like authentication, field-level security, who can access what, complex rules around data authentication, all that kind of stuff. Realm is basically bringing in that same sort of functionality to mobile.”
In terms of building such an application using MongoDB, the company says that “it doesn’t take more than a few minutes to accomplish” the basic requirements, which it lists as:
- A database and at least one collection must be created in your MongoDB Atlas cluster.
- A MongoDB Stitch application must be created and linked to the cluster.
- User rules must be defined for the database and collection within Stitch.
- A Stitch schema must be defined.
With the above requirements fulfilled, GraphQL is provided as a managed service, removing the need to build and maintain a GraphQL backend on your own, a point that Horowitz emphasizes. One important point to note is that this managed GraphQL support is offered only in MongoDB Atlas, and not the community version.
“Typically, if using GraphQL without Stitch, you need to follow a few steps to set-up a GraphQL server. From there, a developer would need to create a schema from their data before being able to query it,” said Horowitz. “Stitch handles all of this, so that a developer really can get started with GraphQL with minimal effort. Stitch automatically generates the schema for you. From there, it really is as simple as clicking to enable the GraphQL service in Stitch, and then you’re ready to start querying on the service/against a single endpoint.”
With GraphQL support reduced to defining a data model and rules, Horowitz says he hopes to see GraphQL adoption continue its upward trend.
“I am particularly excited about more and more Mongo developers not having to write back ends. This could drive a fair amount of GraphQL adoption inside the Mongo community, which hopefully will drive a lot more GraphQL adoption in the wider community,” he said.
MongoDB is a sponsor of The New Stack.
Feature image by Dean Moriarty from Pixabay.