Get Details Of Deployed API’s Using GraphQL
Introduction:
- GraphQL is a query language for API’s and a runtime for executing those queries against our requested data.
- GraphQL provides a more efficient, powerful, and flexible alternative to the traditional REST API.
Advantages:
- With GraphQL, we can request only the data that we need, and nothing more. This helps in reducing over-fetching or under-fetching of data, which is a common issue with REST API’s.
- GraphQL queries are hierarchical and closely match the structure of the data they retrieve. This makes it easy to understand and predict the shape of the response.
- GraphQL typically uses a single endpoint for all queries and mutations.
- GraphQL API’s are defined by a schema that specifies the types of data that can be queried.
Functions:
- Functions have arguments that are passed in when a function is executed.
- Functions are implemented via HTTP Post of a text payload containing the function call to a server.
GraphQL has two primary Functions:
- Query – It is a function for reading the data from the server and displaying it. Like any database query, this will connect to the GraphQL API endpoint and retrieve the necessary data.
- Mutation – It is an update to server-side data, means that you can change values with new values. A Mutation can be used to insert, update, or delete data.
GraphQL Categories:
Metrics:
- API Management Metrics services collect the metadata of API calls through the API Gateway or the Web Services Server and allows you to retrieve the data using a GraphQL client.
- Metrics services return information such as the count of calls per API, successful API requests, popular authentication types for APIs, and the quota status of a subscribed API.
- Boomi retains metrics data for 540 days.
Pre-Requisites To Enable Metrics Data Collection:
- By default, metrics services are disabled. You can enable the services in two ways:
- Enable in Settings > Account > Features > API Metrics Access.
- Enable on the API Gateway, Molecules, and Clouds in Properties > Settings & Configuration > Properties > Advanced > Capture API Metrics.
- You must restart each Gateway after enabling or disabling API Metrics.
Practical Implementation in Boomi:
Let us see how to get details of deployed API’s using GraphQL.
Step 01: First we need to enable API Metrics. Click on Settings.
Enable in Settings > Account Information & Setup > Features > API Metrics Access.
Step 02: click on Account Information & Setup, a new tab will open.
Step 03: Click on features and scroll down. You will get to see a toggle API Metrics and Dashboard, turn ON the toggle so that the metrics will be captured.
Step 04: Go to services and select API Management.
Step 05: A new tab will open, click on Configure Server and select Gateways.
Step 06: Click on your gateway.
Step 07: A new tab will appear there we need to select properties and inside it advanced options check the checkbox of capture API metrics and save it. Then you need to restart your runtime.
Step 08: Once we restart the runtime engine we can see API Explorer in the Resources.
Step 09: Click on it, a new tab will appear as shown below.
Step 10: We will going to query the details of deployed API using “deployedApiCallDetail()” method where we pass the Start Date, End Date and Gateway ID.
query{
deployedApiCallDetail(input:
{
requestTsStart: “2023-12-16”
requestTsEnd: “2023-12-18”
filter: “gateway.id = ‘e2c92efa-1836-434d-b7e6-6f85f77620e9′”
}
)
{
data {
requestTs
atom { id }
gateway { id }
account { id }
deployedApi { id }
authType
status
method
requestUrl
client { remoteAddress }
client { userAgent }
user { username }
transactionId
quotaCount
rateReset
bytesReceived
responseDuration
backendDuration
bytesSent
rateCount
}
nextRequestTs
nextTransactionId
}
}
Step 11: Paste the above mentioned query on the left side of API Explorer.
Step 12: To get the Gateway ID, repeat the step 04, 05 & 06. Later click on Gateway Information, there we will get Gateway ID.
Step 13: After pasting the Gateway Id it looks as shown below. And click on Execute button to execute the specified query.
Step 14: You will get the response in right side of API Explorer as shown below.
In the response we can see GatewayID, AccountID, DeployedAPI Id, Auth Type, Status, method, URL, we can also see the username for the Auth type, we can also see the rate limit, message size and Quota Limit, Response time, etc,
Here in the first picture we can see an 503 error and in the second picture we can see the 200 response.
This is how we can see the details of deployed API’s based on the Gateway ID.
References:
- https://help.boomi.com/docs/Atomsphere/API%20Management/Topics/api-GraphQL_API_Management_APIs_18f1a55a-b3d7-4b9e-ab0a-162fc4a67686
- https://help.boomi.com/docs/Atomsphere/API%20Management/Topics/api-metrics_0e0f3adb-2fcb-4af5-bbd1-aee58d2e713f