Blog

Anypoint Datagraph - Link Datatypes

Anoop RamachandranWritten by Anoop Ramachandran



anypoint-datagraph-link-datatypes


Every organisation is trying to deliver more connected experiences to their customers, and to do that effectively, they’re looking for ways to increase the delivery speed. In this blog I have tried to showcase a step-by-step demo on how to link Datatypes with the Anypoint Datagraph in the MuleSoft Anypoint Platform.

Note:- This blog is a continuation of my previous blog Anypoint Datagraph - REST to GraphQL. If you have not done the walkthrough of the previous blog, it would be difficult to do and follow this one, so I would suggest going back and reading that first.

Prerequisites

  • Do the walkthrough of the previous blog.
  • Add the Orders API to the Anypoint Datagraph in the similar fashion we added for Customers API.

Basically we need the Customer's API and Orders API for this demo.

Once the prerequisites are done, follow the steps below to link the datatypes.

  • Make sure that you have both the Customers API and Orders API added to the Anypoint Datagraph Unified Schema.

anypoint-datagraph-link-datatypes

  • Open the Orders API and click on Order type and scroll down to the Link to another type section.

anypoint-datagraph-link-datatypes

  • Select Customer type from the target drop down and customerID(String!) from the current type to link.

anypoint-datagraph-link-datatypes

  • Click on Save changes. Let it update the changes.

anypoint-datagraph-link-datatypes

  • Now the Customer Type is Linked and a new Customer field would have been created for querying.

anypoint-datagraph-link-datatypes

  • You should now notice that the Order Type has a Link badge and Customer nested type is added, as shown in the image below.

anypoint-datagraph-link-datatypes

  • Navigate to the Datagraph home page and click on Run a Query

anypoint-datagraph-link-datatypes

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

You have now successfully created an Anypoint Datagraph API from the Orders REST API and Linked it with the Customer type. In the next blog, we will show you how to merge two types.

Stay tuned…