Business and Tech

Developing GraphQL in MuleSoft

Written by:
Published on March 15, 2021

Developing GraphQL in MuleSoft

GraphQL benefits and whether it trumps API or works alongside it is a discussion for another blog post. This blog post takes a very quick walk-through of the GraphQL router from MuleSoft – aimed at developers to quickly get things up and running and try it out for themselves.

GraphQL Mulesoft DevOps

Step 1: Install GraphQL Router

GraphQL router which started as a Hackathon entry for MuleSoft components is available at MuleSoft labs GitHub repository at

You need to have appropriate credentials to deploy to your Anypoint Platform in your .m2/settings.xml. Once downloaded, you can deploy the connector to your Exchange using the command:

mvn clean deploy

If the deployment is successful, you should be able to see the GraphQL router in your exchange like below:

GraphQL Mulesoft DevOps

Step 2: Configure a GraphQL demo project

There is an excellent article that covers MuleSoft and GraphQL available at

The linked project from it is a good place to get started with testing the GraphQL capabilities. The project is available at

Download and open the project in the Anypoint Studio and update the pom.xml to point the project to the connector deployed to your organization in Step 1.

For example, see below:

GraphQL Mulesoft DevOps

Step 3: Run and test the application

Run the application on Anypoint Studio and test it from http://localhost:8081/graphiql

GraphQL Mulesoft DevOps

Try with input to query multiple APIs:

GraphQL Mulesoft DevOps

Step 4: Understand the workings

There are three REST API implementation end points in the project (think of it like API calls) namely:

  1. /accounts/{accountId}
  2. /accounts/{accountId}/balances
  3. /accounts/{accountId}/transactions

There are two important pieces of configuration required for GraphQL router: Schema component which looks like below:

GraphQL Mulesoft DevOps
  1. Graphql field resolver components (which are similar to APIKit resource resolvers)

There are three main resolvers added in the project namely:

  1. Account
  2. Transactions
  3. Balances
GraphQL Mulesoft DevOps

This resolver flows help map the incoming GraphQL query fields to different API resources/API implementations. In other words, you can configure these field resolver flows to implement any logic you want to return back to the caller (not just APIs, use any connector/compute and return values…)

Parting thoughts

GraphQL implementation provides simple to use and powerful way to query multiple related data (based on schema/entity) in one call – which could span multiple APIs/implementations on the backend. This is simple to see and implement in one application/API as shown above.

But when the requirement is to span multiple APIs with security (especially authorization) factors and for mutation (or update) scenarios, more comprehensive implementation/design considerations will be required. With respect to MuleSoft implementation, even though it hasn’t solved all the major issues, it does make it extremely easy to enable GraphQL for a select number of use cases extremely easily and well!

Thanks for reading!

End Note

Hope you found this article interesting, do drop us a comment below with your inputs, views, and opinions regarding Developing GraphQL in MuleSoft

Also, if you are interested in learning more about an exciting new code quality product that reduces your Mule project costs by 79%, follow the below link :

Leave a Reply

Your email address will not be published. Required fields are marked *

Other Blog Posts

Other Blog Posts

MuleSoft Meet up at Reading (Virtual)

A Virtual meetup was organized by Integral Zone on 30th September, 2021. The meet up was attended by a number of participants across the globe. There were two keynote speakers who spoke on two different topics: Building asynchronous REST APIs at scale. By Kalidass M, Director of Engineering at Integral Zone Why automated code quality …

Read more

Mulesoft Development Fundamentals: Dataweave Best Practices

‘MuleSoft development fundamentals’ is a blog series that takes you through various aspects of MuleSoft development from “How to structure your Mule code” to “Things to cater to when you deploy to production”. We would love to share our expertise with the Community, having worked with several MuleSoft Enterprise clients. Please find all the blogs …

Read more

IZ Analyzer – Scanning API Projects

In an API and microservices world, the quality of the deliverable becomes paramount – since a weak link can break the whole chain. In the previous blog posts, we had seen how Mulesoft code implementations could be quality tested in an automated manner with IZ Analyzer. Now with API Analyzer plugin, APIs can be quality …

Read more