linkedin

Anypoint Datagraph Link Datatypes

anypoint-datagraph-link-datatypes

Every organization aims to deliver more connected digital experiences. As a result, teams actively seek ways to accelerate API delivery while still maintaining consistency and scalability. In this context, Anypoint Datagraph link datatypes enables teams to expose related REST APIs as a unified GraphQL schema across the MuleSoft ecosystem.

In this walkthrough, you will learn how to link datatypes using Anypoint Datagraph in the MuleSoft Anypoint Platform, building on an existing REST-to-GraphQL setup.

Note: This blog is a continuation of Anypoint Datagraph – REST to GraphQL. If you have not completed that walkthrough, complete it before proceeding, because this guide assumes familiarity with the initial configuration.

Prerequisites

Before you link datatypes in Anypoint Datagraph, first complete the following steps:

  • Complete the walkthrough of the previous blog.
  • Add the Orders API to Anypoint Datagraph using the same approach as the Customers API.
  • Ensure both the Customers API and Orders API are available for this demo.

Once you complete these prerequisites, you can proceed to link the datatypes. As a result, these steps ensure the Datagraph unified schema is properly configured before you create relationships between APIs.

Step-by-Step: How to Link Datatypes in Anypoint Datagraph

Step 1: Verify APIs in the Unified Schema

Confirm that both the Customers API and Orders API are added to the Anypoint Datagraph Unified Schema. This allows Datagraph to understand and resolve relationships between the APIs.

This step confirms that both APIs are available in the Datagraph unified schema, which enables you to link datatypes.

Unified schema view showing customer and order data models

Step 2: Open the Orders API Type

Navigate to the Orders API within Anypoint Datagraph. Select the Order type and scroll to the Link to another type section.

Overview of connected APIs within the platform interface

Step 3: Configure the Datatype Link

From the Target type dropdown, select Customer.
Then, choose customerID (String!) from the current Order type as the linking field.

This configuration defines MuleSoft Datagraph relationships between Order and Customer data.

Configuration screen showing saved relationship settings

Step 4: Save and Apply Changes

Click Save changes and allow Datagraph to update the schema. After the update completes, Datagraph links the Customer type successfully.

Confirmation view after applying schema changes

Step 5: Validate the Linked Customer Type

After you save the changes, Datagraph automatically creates a new Customer field under the Order type.

anypoint-datagraph-link-datatypes
  • You should now see that the Order type displays a Link badge and includes the Customer nested type, as shown in the image below.
anypoint-datagraph-link-datatypes

Step 6: Run a GraphQL Query

Navigate back to the Datagraph home page and click Run a Query. Execute the following GraphQL query to validate the relationship:

anypoint-datagraph-link-datatypes

Query

The following query demonstrates how link datatypes in Anypoint Datagraph enable nested data retrieval across APIs.

        {
          ordersByID (ID: "O1") {
                orderID
            orderDate
            orderItems
            orderStatus
            customer {
              customerID
              firstName
              lastName
              phone
              email
            }
          }
          orders {
                orderID
            orderDate
            orderItems
            orderStatus
            customer {
              customerID
              firstName
              lastName
              phone
              email
            }
          }
        }

This query demonstrates how linked datatypes allow nested data retrieval across APIs using a single GraphQL request.

Conclusion

You have now successfully created an Anypoint Datagraph API from an Orders REST API and linked it with the Customer type. This approach enables seamless data traversal across services while preserving API ownership and autonomy.

In the next blog, we will explore how to merge two types within Anypoint Datagraph to further enhance schema flexibility.

Stay tuned…