Build a Query in MuleSoft With Optional Parameters

In this tutorial we will see how to:

  • Define a RAML API specification to search products in a catalog database
  • Establish and configure a database connection to query a MySQL database
  • Build a query to support multiple optional filters
  • Add optional sorting capabilities to our query at DB level

1. Define the RAML of a Search API

Imagine that you want to create a MuleSoft API to search products inside a catalog. This API will need to accept multiple filter parameters and an optional sorting parameter. All these parameters can be optional and will be used to generate a dynamic query to search products in your catalog database.