Apisero is now part of NTT DATA - Learn more.

Close this search box.

Implementing DataGraph Collaboration In MuleSoft

Author: Nikhil Kumar & Pankuri Bansal

In this blog, we will explore the process of implementing collaboration in DataGraph within Mule 4. We’ll guide you through the setup and execution of this implementation, ensuring your applications run as expected.

An overview of DataGraph and its importance

Having a deep understanding of GraphQL is crucial for anyone utilizing Anypoint DataGraph. This potent technology is integrated within the platform, making it vital to possess a thorough comprehension of GraphQL in order to effectively harness Anypoint DataGraph’s capabilities.

GraphQL has revolutionized the way we interact with APIs. By adhering to this specification, you can streamline your API interactions and simplify your workflow. Instead of sending multiple requests to different endpoints, all that’s required is to POST a single “query” to an HTTP endpoint. This not only reduces unnecessary network traffic, but also enhances efficiency and makes API integration straightforward.

To truly understand the power of GraphQL, it’s crucial to acquaint yourself with its utilization within an HTTP client. This comprehension will offer valuable insights into its practical application and its significance in modern web development.

  • Regrettably, a trial version of DataGraph is presently unavailable. Nevertheless, to offer the utmost assistance, our developers kindly ask clients to share their credentials so they can efficiently collaborate on the project.
  • Set up a trial account on the Anypoint Platform.
  • The objective is to generate two RAML files that include particular fields along with their corresponding data types.
  • Unleash the potential of data with DataGraph by effortlessly implementing and executing your queries. Streamline your data analysis process and acquire valuable insights, all through one intuitive platform.
  • Collaboration is crucial when dealing with Raml queries. By establishing a connection between both APIs, we can ensure smooth communication and improve the overall functionality of your system. In this blog, we will guide you on how to achieve this and enjoy the advantages of a more integrated approach.
  • Thanks to collaboration in DataGraph, we can now execute multiple queries within a single query. This groundbreaking capability not only boosts efficiency and productivity but also enables us to achieve improved results in less time. So, let’s begin the implementation.
  • Set up a trial account on the Anypoint Platform.
  • Navigate to the Design Center and create two RAMLs (for demo purposes, we have created two RAMLs named “Accounts” and “Customers”) as shown in the screenshots below.
  • We need to pass the customerId (Primary Key of Customers API) in Accounts, as it will be utilized as a Foreign Key in Accounts to access the Customers API (Second API) through the Accounts API.
  • The key we are selecting as the Primary Key, in our case accountId and customerId, should always have a data type of “String”.
  • After creating and testing both RAMLs, proceed to publish both RAMLs on Exchange.
  • Now, open Anypoint Studio and create two new Mule projects. Import both RAMLs from Exchange. (For demo purposes, we’ve created “customers-app” and “accounts-app” Mule projects and imported the RAMLs) as illustrated in the screenshots below.
  • Deploy and test both applications.
  • Export the “account-app” project and deploy it on CloudHub 2.0.
  • Export the “customers-app” project and deploy it on CloudHub 2.0.
  • Both applications have been successfully deployed on CloudHub 2.0.
  • Now, navigate to DataGraph on the Anypoint Platform.
  • Click on “Add API” in the top right corner.
  • After clicking, choose the API you want to implement first. In this blog, we selected the Accounts API first. Afterward, click on “Next: Configuration URL”.
  • Now, ensure that the API and Assets Versions are the latest.
  • Now Click on Confirm selection.
  • After that, add implementation/ Base URL of deployed Accounts API and click on save.
  • Now, choose a policy for your API if it has one. If not, select “No Auth”. In our case, since we don’t have any security scheme, we’ve selected the “No Authentication” policy.
  • Likewise, if your API utilizes a Keystore or Truststore, click on the respective checkboxes. Otherwise, leave them unchecked and proceed by clicking “Next”.
  • Ultimately, the Accounts API endpoint is visible on DataGraph, as depicted in the screenshot below.
  • If you wish to rename this endpoint, you can click on the “Rename Method” button, and then click on “Confirm”.
  • Now, click on the blue link next to the “Accounts” endpoint, over which the cursor is hovering.
Collaboration in DataGraph
  • Now, the collaboration part has commenced.
  • Click on “Enable Collaboration.”
  • Choose the primary key for your API, as illustrated in the screenshot below. In our case, for the account API, it is accountId.
  • Next, click “Next” and choose your argument (primary key) from the dropdown.
  • Then Click on Confirm.
  • After clicking on “Confirm,” Collaboration will be enabled, as depicted below.
  • After clicking “Confirm,” Collaboration will be enabled, as shown below.
  • Afterward, the entire collaboration process will take approximately 15 minutes to complete, as depicted below.
  • Similar steps will be repeated for the Customers API, up to the collaboration part (which is the Customers API in this blog).
  • Once all the steps are followed for the other API, in our case, for the Customers API, collaboration will be enabled, and both APIs will be ready for the linking process.
  • Once both applications are successfully added to the Unified schema, they can be tested by running queries for each respective API.
  • Click on “AccountsDatatype” in the Unified schema to execute the query for the Accounts API.
  • Click on “CustomersDatatype” in the Unified schema to run the query for the Customers API.
Linking in DataGraph
  • Now, starting from here, the implementation for linking both APIs begins.
  • Click on “List” on the left side.
  • Click on the API to which you want to link another API.

In this blog, we are linking the Accounts API with the Customers API.

  • Click on the “Next” button, and from the dropdown, select the Second API, which in our case is the Customers API.
  • Now, in the first API (Accounts API in our case), select the Foreign Key. The foreign key for the Accounts API is “customerId,” which will be the Primary key for the second API (Customers API, our second API).

Example: customerId is the primary key for Customers API and the Foreign key for Accounts API.

  •  Now Click on save.
  • Then click on “Apply Changes.” It will take approximately 15 minutes to integrate the changes and implement the linking.
  • Now, after the linking process is completed, you will notice the link symbol on the Accounts API.
  • The linking field will also become visible, connecting both APIs. In our case, it is “customersdatatype.”
  • Once the linking is established between both APIs, click on the “Run Operation” button and execute the query accordingly.
  • You will require the linking field to call the second API from the first API. In our case, to retrieve data from the Customers API within the Accounts API, we are using the “customersdatatype” as the linking field connecting both APIs.
  • After constructing the query, you can click on the “Run” option to execute it, and the results will become visible to you.
  • Now, you can observe that by executing a single query, we are able to retrieve the data from both APIs in one go.

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.