Follow Datanami:
January 22, 2020

MongoDB Embraces GraphQL with Document Database

Alex Woodie

If GraphQL is the data-access API of the future, then MongoDB wants to be a part of it. That much is evident from today’s announcement that the popular document-style NoSQL database is now serving queries formatted using the upstart development language.

GraphQL, if you aren’t aware, is an emerging standard for accessing data over the Web. The technology, which was originally developed at Facebook, basically functions like a query language for APIs. By enabling developers to specify exactly what data they’re requesting, they no longer must write code to parse through larger payloads delivered from procedural REST and SOAP-based methods. It also reduces the need to hand-code custom APIs when existing ones don’t fit the bill.

According to Geoff Schmidt, the co-founder and CEO of GraphQL company Apollo, the software represents a higher abstraction level that simplifies the application or data access path and reduces the burden on the developer.

“This kind of sits on top of all your existing services and super-imposes a graph on all those cloud assets and resources so application developers can freely query that without the friction of having to create a new REST endpoint for every new use case,” Schmidt told Datanami for a 2018 story on GraphQL and the Apollo Server that serves GraphQL queries.

Now MongoDB is getting in on the act by enabling GraphQL queries to be served directly from the MongoDB database. This will reduce the burden on the developer, says MongoDB co-founder and CTO Eliot Horowitz.

“We’re seeing it gain a ton of traction with Web developers that are building modern applications,” Horowitz tells Datanami via email. “GraphQL has been embraced by developers because of its declarative query style, which is much cleaner than and less burden to build applications with versus using other query methods. Our main focus at MongoDB is making developers work easier so this was a natural development for us.”

By supporting GraphQL directly in its database, MongoDB is reducing the need for users to build out other GraphQL middleware layers to handle schema and to resolve functions with the database logic. MongoDB has adapted its cloud-based Stitch offering to handle authentication and GraphQL queries.

It’s all about simplifiying life for developer and speeding up the response times of applications, Horowitz says.

“As many of today’s applications being built are designed to be Web/mobile-first, there is a tendency to do single-page React applications with some sort of an API back to data and other third-party services,” the MongoDB CTO continues. “By generating a single schema off of multiple data sources, GraphQL allows developers to make requests against only one endpoint and get exactly the data they need, every time.”

That single endpoint results in faster page load times, since it removes the need for dozens or more API calls, Horowitz says. “Additionally, it helps developers iterate faster as they don’t need to build a new endpoint to call new or different data,” he says. “This simplifies the codebase and reduces developer effort as Docs don’t need to be updated to reflect new endpoints. Unlike REST, developers don’t need to spend time learning multiple endpoints. GraphQL truly lets you extend your API without impacting existing queries.”

GraphQL won’t replace existing MongoDB query options, but augment them, Horowitz says. There’s a bit of work to enabling GraphQL support via Stitch (its preconfigured MongoDB-based serverless platform) and Atlas (the company’s managed database as-a-service offering). Those configuration changes are relatively minor and can be gleamed from MongoDB’s blog post on the topic.

While it’s only available on the cloud at the moment, GraphQL will be made available to on-premise customer after it’s been battle-hardened on the cloud, Horowitz says.

Related Items:

Will GraphQL Become a Standard for the New Data Economy?

MongoDB Accelerates Cloud Shift

Q&A With MongoDB CTO

Do NOT follow this link or you will be banned from the site!