Exchange Graph
Querying the graph
The Exchange Graph API provides one root element called assets
. This means that every query made to the graph returns only Exchange assets. There are two different argument types that can be used in a query: query
and asset
. You can also use the latestVersionsOnly
flag in combination with both arguments.
- latestVersionsOnly (Boolean): Tells the graph to return only the latest version of each matched version.
Searching for assets with query
You can build a search query by specifying different fields within the query
argument. The available query fields are:
- organizationIds (String): A list of organization IDs to filter by. This lets you ask for assets belonging to specific business groups.
- public (Boolean): Fetch only assets that are publicly shared.
- tags ([TagSearchField]): A list of tags to filter by. Tags are objects with two fields,
key
andvalue
. Only thevalue
is a mandatory field. Some examples of keys aremin-mule-version
,has-mule3-connector
andproduct-api-version
. - runtimeVersion (String): A shorthand to filter by
min-mule-version
tag. - searchTerm (String): This field is used for free text searches.
- type (String): A type to filter by. Some types are:
template
,example
,rest-api
andsoap-api
. - types ([String]): A list of types to filter by. Some types are:
template
,example
,rest-api
andsoap-api
. - offset (Int): Pagination control. The number of assets to skip when returning the result. Defaults to 0.
- limit (Int): Pagination control. The number of assets to return in one page. Defaults to 20.
Examples of requests doing searches using the graph:
- Return the third 10 item page of Mule 4.0.0 extensions for MuleSoft organization.
curl -X POST \
https://anypoint.mulesoft.com/graph/api/v1/graphql \
-H 'content-type: application/json' \
-d '{"query":"{assets(query: {organizationIds: [\"68ef9520-24e9-4cf2-b2f5-620025690913\"], runtimeVersion: \"4.0.0\", type: \"extension\", offset: 20, limit: 10}) {groupId assetId version}}"}'
- Return the first 5 item page of REST APIs with Product API version named
v1
.
curl -X POST \
https://anypoint.mulesoft.com/graph/api/v1/graphql \
-H 'content-type: application/json' \
-d '{"query":"{assets(query: {type: \"rest-api\", tags: [{key: \"product-api-version\", value: \"v1\"}], offset: 0, limit: 5}) {groupId assetId version}}"}'
- Return the first 5 item page of REST APIs with Product API version named
v1
, returning only the latest versions.
curl -X POST \
https://anypoint.mulesoft.com/graph/api/v1/graphql \
-H 'content-type: application/json' \
-d '{"query":"{assets(query: {type: \"rest-api\", tags: [{key: \"product-api-version\", value: \"v1\"}], offset: 0, limit: 5}, latestVersionsOnly: true) {groupId assetId version}}"}'
Getting particular assets using asset
If you know the groupId, assetId, and/or version (GAV) of an asset, you can access it using the asset
argument. The available fields are:
- organizationId (String): The organization ID where to look for the asset.
- groupId (String): The group ID of the asset to retrieve.
- assetId (String): The asset ID of the asset to retrieve.
- version (String): The version of the asset to retrieve.
- public (Boolean): Fetch only assets that were publicly shared.
Examples of requests retrieving an asset using the graph:
- Returns the asset with the specified GAV.
curl -X POST \
https://anypoint.mulesoft.com/graph/api/v1/graphql \
-H 'content-type: application/json' \
-d '{"query":"{assets(asset:{groupId: \"org.mule.connectors\",assetId: \"mule-db-connector\",version: \"1.2.1\"}){groupId assetId version}}"}'
- Returns all the asset versions with the specified version.
curl -X POST \
https://anypoint.mulesoft.com/graph/api/v1/graphql \
-H 'content-type: application/json' \
-d '{"query":"{assets(asset:{groupId: \"org.mule.connectors\",assetId: \"mule-db-connector\"}){groupId assetId version}}"}'
- Returns the latest asset version with the specified version.
curl -X POST \
https://anypoint.mulesoft.com/graph/api/v1/graphql \
-H 'content-type: application/json' \
-d '{"query":"{assets(asset:{groupId: \"org.mule.connectors\",assetId: \"mule-db-connector\"}, latestVersionsOnly: true){groupId assetId version}}"}'