
In this blog, I showcase a step-by-step demo on how to merge datatypes using Anypoint Datagraph in the MuleSoft Anypoint Platform. More importantly, this walkthrough helps you understand how unified schemas can be enhanced by consolidating related data models across APIs.
Note:- This blog is a continuation of my previous blogs Anypoint Datagraph – REST to GraphQL and Anypoint Datagraph – Link Datatypes. If you have not done the walkthrough of the previous blogs, it would be difficult to do and follow this one, so read the prevoius blog first.
Prerequisites and Required APIs
- Do the walkthrough of the previous blog.
- Add the Users API to the Anypoint Datagraph in the similar fashion we added for Customers API.
Basically we need the Customer’s API and Users API for this demo.
Merging Datatypes in Anypoint Datagraph
After completing the prerequisites, follow the steps below to merge the datatypes.
- Make sure that you have both the Customers API and Users API added to the Anypoint Datagraph Unified Schema.

- Begin by opening the Users API, then click on the User type. As you scroll down, you will notice the Merge with another type section, which is where the actual merging process begins.

- From the target dropdown, select the Customer type. However, once selected, you will immediately see a warning indicating a mismatched datatype across common fields. This occurs because the field names do not yet align between the two types.

- Click on Rename field to rename the UserID field.

- Type customerID in change to text box and click on Confirm.

Anypoint Datagraph Merge Datatypes in the Unified Schema
- By now, the Confirm Merge button is enabled—click Confirm Merge to proceed.

- Review the changes and click on the Confirm button.

- The system successfully merges the Customer and User types.

- Click Apply Changes and wait for the API to be updated.
- Navigate to the Datagraph home page and click on Run a Query
- Now the users method includes both user type fields as well as the customer type fields.
- You’ll also notice that fields such as email and phone merge into a single type. This works only when both fields contain the same data.


Validating the Merged Datatypes Using Queries
- Query
{
users{
customerID
firstName
lastName
lastLogin
phone
accountType
email
paymentType
profilePicture
address
}
}
You have now successfully created an Anypoint Datagraph API from the Users REST API and merged it with the Customer type.
Â