Mulesoft Anypoint Data Graph
MuleSoft Anypoint Datagraph is built on the top of GraphQL. GraphQL was initially developed by facebook and released publicly in year 2015.
With the MuleSoft Anypoint Datagraph, Organizations will be able to utilize capabilities of graphql and reuse multiple APIs into single request. GraphQL also allows customer to request limited data they need.

Anypoint Data Graph Use Case
- To get the aggregated response from the Multiple APIs.
e.g. Let’s consider we have 3 system APIs(Ledger, Customer and Account API) available on exchange and deployed. Now we wanted to send aggregated response from these API without writing any process/business orchestration layer. So basically, developer don’t have to write code for parsing the data from these API’s.
Here Anypoint Datagraph help us to send the aggregated response to the client application just through configuration only.

- Mobile and Web application needs separate response data.
e.g. Customer API response schema has 6 attributes (customerId,Name,Age,phone,email,pincode and address) and they want to send separate response to mobile and web application.

Getting Started with Anypoint DataGraph
Here are the steps below for enabling a datagraph endpoint in MuleSoft
- Assuming that following API’s deployed on sandbox environment with mentioned endpoint.
- Account API :- http://accounts-api-details.us-e2.cloudhub.io/api/accounts/
- Customer API:- http://customers-api-details.us-e2.cloudhub.io/api
- Ledger API :- http://ledgers-api-details.us-e2.cloudhub.io/api/ledgers/
- And mentioned APIs below are also published on exchange.
- Customer System API
- Account System API
- Ledger System API
- Go to the Anypoint Datagraph page using the main menu from the top left menu.

- Click on the Add API button. This page has displayed all the discoverable API available on exchange.

- Select Customer System API from the list and click “Next Configure URL”. Below page displayed in front of you. Click “Confirm Selection ” button with default selected API version and Asset Version.

- Add/Edit API URL section will be enabled with default selected values. Click “Next Configure Security” button now.
Note:- These values populated from the API manager configuration which we set during the API manager configuration. Please refer Snippet 2 for the reference.

Snippet 2 API Manager Config:-

- Click on Next. Since we have not applied any policies in API manager so we should select authentication policy as No Auth here and click “Next preview Schema” button.
Note:- Please refer the API Manager snippet for the reference in below section.

API Manager snippet:-

- Below page displays the schema details populated from the RAML specification. Click “Next:Edit Schema” button. Anypoint Datagraph is smart enough to populate the details from RAML.

- We can make visible/hidden query method here. Click Customer tab from left yellow highlighted panel.

- This Page has below yellow highlighted section. Click on the “Enable Collaboration” button.

- You will see option to define Primary key and Select Default Query method. Select and click next button

- Select customerId as primary key here and press confirm button.

- Press confirm button will display the updated detail here. Now click to “Next:Add to unified schema” button keeping other section as default selected.

- Now the Customer API is started to deploy on the Anypoint Datagraph. It will take around ~5 min to deploy.

- Once deployment done its status changed as Up to date. Now click the “Run Operation” button.

- Select 2nd radio button option from this window and click next.

- Enter the application name and keep rest field as blank and click the Next button. Next page will display GraphQL query language page.

- Write the GraphQL syntax into the middle section of page to fetch the data from the deployed customer API unified schema application. If all good, then we should get the valid response from the API.
Let’s validate the GraphQL response and actual API endpoint response. Both should have same response details data.
Anypoint GrapQL Response:-

Actual API endpoint response:-

- Now time to deploy Account System API into Anypoint Datagraph. Click on Add API button.

- Select the Account System API from the below listed API and click Next:Configure URL

- Configure URL page should have configured with default selected values and click “Next:Configure Security” button.

- Here we will set the authentication policy as Basic Auth because we have applied the same policies into this API at API manger section. Please note same client application must use here while applying the policy. Click next preview schema button.

API Manager policies page:-


- Click Next edit schema and select the Account tab from the left panel from next screen and perform the enable collaboration operation.


- Enable the accountId as primary key using this screen.

- Now configure link to another type. Here we will enabled the relation between Account and Customer API based on the customerId. Select customerId attribute as FK into Account schema which will bind with Customer schema using same attribute as PK. Click Save Changes button and then click Next to Add to unified Schema.

- Account API started to deploy on Anypoint Datagraph. Once it will deployed then click on the Run operation button.

- We can run query using account object that inherit customer object inside that. This happens due to we have created the link between account and customer object using the customerId as PK/FK.

- Let’s validate this data with actual endpoint response. We can see Anypoint Datagraph fetched the correct account and customer data based on the relation defined with customer schema.

- We can explore more option like share GraphQL query, Trace query, download schema, etc while clicking on the 3 dots.

- Using “Copy & Share query” option we can get the get the details about Anypoint Datagraph endpoint.

- Hit the anypoint data graph endpoint through postman.

- Click the code link in postman and get the graphQL request as converted JSON request and hit the API now.

Points to Note
- It supports GET method only.
- Support only RAML and OAS specification
- 250 API’s per unified schema.
- It is preferred to have primary keys of datatypes in string format.
- Maximum 5 MB response data per call.
- Anypoint Datagraph strongly typed and strictlly follow schema definition.
- API Manager policies and Anypoint Datagraph API policy should be in sync.
- Same client application should consider while designing the API through API Manager and Adding the API into Anypoint Datagraph.
- Recommended to fill all the optional details (API instance label, Implementation URL, Customer endpoints) while defining the API configuration.
References:
https://www.mulesoft.com/platform/anypoint-design-center/datagraph
https://blogs.mulesoft.com/learn-apis/comparing-datagraph-vs-graphql/
Post Submitted by:
![]() |
|

