How to Build Advanced GraphQL-based APIs With MongoDB Atlas and AWS AppSync Merged APIs

Igor Alekseev (AWS) and Babu Srinivasan

When businesses develop their own IT systems, sooner or later, the complexity of managing APIs becomes a challenge. Breaking down monolithic architectures into multiple microservices often results in a proliferation of APIs associated with each microservice. Each API, in turn, has versioning, leading to further fragmentation of the APIs and driving up maintenance costs. If your microservices diagram looks like a hairball you know you are living in API Hell. Conway’s Law, which states that systems mirror the communication structure of the organization, also applies to API development. Different teams build separate and, sometimes, overlapping APIs, further contributing to the fragmentation.

While this is especially true for REST-based APIs, it's also a challenge for GraphQL-based APIs. GraphQL has emerged as a powerful tool for building flexible and efficient APIs that empower developers and elevate user experiences. AWS AppSync is the go-to service for customers looking to accelerate application development with serverless GraphQL and Pub/Sub APIs.

AWS AppSync offers a managed GraphQL service with additional features and capabilities. It simplifies the development of scalable, real-time applications by seamlessly integrating with various data sources, providing offline support, enabling fine-grained authorization and security, and automating infrastructure management. By embracing AppSync, you can harness the full potential of GraphQL while leveraging the benefits of a comprehensive portfolio of services and products provided by AWS.

MongoDB Atlas on Amazon Web Services (AWS) and AWS AppSync combined help developers build scalable, secure, and serverless applications. By seamlessly integrating MongoDB as a data source within AppSync, you're able to leverage MongoDB's flexible document model and AppSync's GraphQL-based querying to efficiently retrieve and manipulate data. And you can leverage AppSync's automatic scaling, ensuring optimal performance. This combined solution enables you to build high-performing serverless applications while simplifying application development.

AWS AppSync recently added a feature called Merged APIs that allows you to compose multiple GraphQL source APIs into a single GraphQL API. Merged APIs give developers the ability to compose distinct APIs developed by different teams into a single, combined GraphQL schema. The merged API resolver function contains the logic to consolidate the source details. The resulting single GraphQL API can be cached for better performance. You can then present the unified API to the clients as a single API endpoint.

AppSync Merged APIs combine MongoDB Atlas-backed APIs with other APIs, allowing you to enrich operational data residing in MongoDB Atlas with data coming from additional sources. You can serve data with a unified GraphQL schema across multiple data sources, including MongoDB.

If you're interested in learning more about this powerful integration, check out our new tutorial that demonstrates two ways to combine MongoDB Atlas with AWS AppSync: leveraging the Drivers and the Atlas Data API. Both approaches work with the AWS AppSync Merged API as well.

Checkout our tutorial on GitHub.

Try out MongoDB Atlas on AWS and AWS AppSync today.

Sign up for MongoDB Atlas on AWS Marketplace Today