5. 5
Agenda
Agenda
Technical
challenges in
building a
project
structure
What is Maven
in MuleSoft
Leverage
Anypoint
Exchange for
API Template
MuleSoft API
Project
Template
content
following best
practices
Use Cases and
Live
Demonstrations
Maven
Archetypes
What is Maven
in MuleSoft
Implementing
GraphQL With
MuleSoft
7. 7
Over 9 years of IT experience
Multi-MuleSoft Certified Developer, API Designer,
Platform and Integration Architect
Wellington, New Zealand Meet-up Group Leader
Currently producing talented Mule Developers
Introduction – Mary Joy Sabal
Fun fact!
8. 8
Scenario:
● New client, needs to upskill Developers in MuleSoft
Impact:
● Training consumes A LOT of time
● Difficult to enforce standards
Use case
9. 9
Scenario:
● Building APIs within a short timeframe.
Impact:
● Inconsistent building of project structure.
Use case
10. 10
Technical challenges in building a Project
Structure
Unable to meet development
standards and to follow technical
governance in building API.
Consumes a lot of development
time
Inconsistent project
structures
11. 11
● Dependency management utility
● Projects created in Anypoint Studio 7 and later are configured Maven by default.
http://maven.apache.org/
https://docs.mulesoft.com/mule-runtime/4.3/using-maven-with-mule
What is Maven in MuleSoft?
POM
(Project Object Model)
File:
pom.xml
Archetype Descriptor
File:
archetype-metadata.xml
Archetype Properties
File:
archetype.properties
12. 12
Create a custom project
Upload custom project as a template to Anypoint Exchange
Maven archetype:create-from-project
Maven archetype:generate
Import newly generated project into Anypoint Studio
Steps to create MuleSoft API Project Template
using Maven Archetypes
16. Maven archetype:create-from-project
16
● Modify archetype-
metadata.xml (ArchetypeDescriptor)
○ Include/exclude files or folders
Creates a Maven archetype from a custom
or existing project.
A template on top of a template.
Command:
mvn archetype:create-from-project -
Darchetype.properties=../archetype.properties
17. 17
● Generate a new Maven project from the generated Maven archetype.
Maven archetype:generate
Command:
mvn archetype:generate
-DarchetypeGroupId=<Your Anypoint Platform Organization ID>
-DarchetypeArtifactId=api-template-archetype
-DarchetypeVersion=1.0.0
-Ddomain=<e.g. customers>
-DapiDescription=<"This API will retrieve customers details">
● It should run in interactive mode
18. 18
● Standardize project development
● Preconfigured dependencies
● Unified log4j format
● Safely hidden properties for sensitive properties
● Focus on implementing business specific requirements
● Speed up your development time
● Enable developers to easily follow best practices
Benefits of having an API Project Template
21. 21
GraphQL is an open-source query language for Rest API's and it is
developed by Facebook in 2012 before releasing publicly in 2015. GraphQL
allows you to send the query to your API and get the required data.
REST APIs are powerful and follow a resource-oriented and well-structured
approach. However, when the data is complex and it is not possible to fetch
all the data within a single request as it involved various operations and
routes get more complex. GraphQL is very useful in such cases and
structures data in the form of a graph with its powerful query syntax for
traversing, retrieving, and modifying data.
GraphQL is capable of aggregating the data, returns predictable data to the
clients. Let us help you understand with the below 2 use cases how powerful
is GraphQL and it can be easily implemented using MuleSoft.
What is GraphQL?
22. 22
Use Case 1
Let's consider the scenario, you have Rest API that returns 10 fields in response
but web application requires only 7 fields whereas mobile application requires
only 4 fields. In such cases, GraphQL is one of the most optimal options where
the client can pass whatever data required as an input request, and GraphQL
will return the required fields to the Web Application and Mobile Application.
GraphQL – Use Case 1
24. 24
Use Case 2
Let's consider the scenario where you have to call multiple Rest APIs or want to
fetch data from multiple rest API's and each APIs will respond with JSON
payload. GraphQL will aggregate all the responses and send back the required
data to the client.
GraphQL – Use Case 2