Skip to content

Unify multiple APIs into a single data service using MuleSoft Anypoint DataGraph

In this article, we will discuss the interesting component introduced by MuleSoft as a part of Anypoint Platform (i.e. Anypoint DataGraph).

With Anypoint DataGraph, you can reuse multiple APIs in a single request. Enterprise architects can easily unify APIs into one data service all without writing more code. Developers can consume multiple APIs from the data service in a single GraphQL request.

Introduction to Anypoint DataGraph

Anypoint DataGraph is a component of Anypoint Platform that allows you to unify the multiple APIs into a single data service.

Anypoint DataGraph is the unified platform for APIs to design, develop and manage. It allows discovering, manage or serve the data from multiple APIs using a single datagraph request. This reduces a lot of effort for developers to call multiple APIs and aggregate the response. With Anypoint DataGraph, you can request only data you want, no more or no less.

It is built on top of GraphQL. GraphQL is an open-source query language for Rest APIs and it was developed by Facebook in 2012 before releasing publicly in 2015. GraphQL allows you to send the query to your API and get the required data. 

REST APIs are powerful and follow a resource-oriented and well-structured approach. However, when the data is complex it is not possible to fetch all the data within a single request as it involves various operations and routes get more complex. GraphQL is very useful in such cases and structures data in the form of a graph with its powerful query syntax for traversing, retrieving, and modifying data. 

GraphQL is capable of aggregating the data and returns predictable data to the clients.

https://nl.devoteam.com/event/the-hagues-first-meetup-an-introduction-to-anypoint-datagraph/

Advantages of Anypoint DataGraph

  • Unify the multiple APIs into the single data service. With Anypoint DataGraph, you can serve data from multiple underlying APIs within a single request without writing any code.
  • Consume the data from multiple APIs using a single request.
  • Developer doesn’t have to write the code to parse the data from multiple APIs.
  • Anypoint DataGraph is managed service, no maintenance or patching for IT. 
  • Request the data you want, no more no less.
  • Reduce development and maintenance efforts.
  • Anypoint DataGraph is a managed service and no need to worry about underlying infrastructure and maintenance.

Use cases: Where can we apply Anypoint DataGraph?

Use case 1

Let’s consider the scenario, you have a Rest API that returns 10 fields in response but web application requires only 7 fields whereas mobile application requires only 4 fields. In such cases, DataGraph is one of the most optimal options where the client can pass whatever data is required as an input request, and DataGraph will return the required fields to the Web Application and Mobile Application. Below is the illustration of Use Case 1.

Use case 2

Let’s consider the scenario where you have to call multiple rest endpoints or want to fetch data from multiple rest endpoints and each APIs will respond with JSON payload. GraphQL will aggregate all the responses and send back the required data to the client. Below is the illustration of Use Case 2.

Use case 3

Let’s consider the scenario where you have to call multiple Rest APIs to fetch account details and related customer details. Customer details and Account details exist in different APIs. Customer ID is the primary key in customers API and account ID is the primary key in accounts API. Also, the customer ID is a foreign key in accounts API. Below is the illustration of Use Case 3.

Monitor, Trace or Measure the API Performance

With a single UI, it is possible to trace the query response time and logs, ensuring to measure the performance of query or API request and meets expected SLA’s.

Authentication Mechanism

DataGraph supports the list below of Authentication mechanism while calling underlying APIs:

  • Basic Authentication
  • Client Id Enforcement via Headers
  • Client Id Enforcement via Query Params
  • Custom (Add Custom headers or Query Params)
Restrictions

Anypoint DataGraph supports:

  • REST APIs with RAML and OAS specifications
  • Only GET methods
  • 250 APIs per unified schema
  • 16,000 fields per unified schema

Anypoint DataGraph restricts downstream REST API calls to:

  • A maximum of 150 concurrent or ongoing calls per unified schema
  • A 5 second timeout per call
  • A maximum of 5 MB of response data per call

Anypoint DataGraph limits the query service to:

  • A 30 second timeout per query
  • A maximum of 100 selected fields per query. 

Conclusion

Anypoint DataGraph is an excellent feature and it helps customers to innovate faster and unify the APIs without writing a single line of code. It comes with many advantages like data aggregation, tracing and monitoring, calling multiple APIs with a single datagraph query, etc.

At Devoteam, we can help you to enable Anypoint DataGraph with best practices and guidelines. Click on the button below to get in touch.