Top X queries are mainly used for performing queries and analysis on data. They help visualize how resources and tools are being used and provide a more detailed analysis of certain conditions that are either more or less commonly used.
Then, on Postman’s GraphQL request code box, add the following Top X Query, modifying the
tsRange to fit the time interval you want:
The example queries the Events app for raw data with the HTTP dataset. In addition, the count operator requests data aggregation with information from the requestUri field during a set period of time, informed through the tsRange field. The API response was also limited to 5 registers by using the limit field.
Lastly, data were aggregated (groupBy) by the requestUri field and sorted (orderBy) by the return of the count operator in a descending (DESC) order. That way, the largest amount of aggregation responses is shown first.
To query aggregating data, it’s mandatory to inform:
- A time range interval for queries, using either tsRange or tsGt + tsLt.
- The fields whose information you want to group, using groupBy.
- Which consulted data should be exhibited. On the presented example, the requestUri and count fields were used, in which count represents the response of the requestUri aggregation.
Send your request. You’ll receive a response similar to this:
The GraphQL API returned the Top RequestUri query data according to the query informed in the request.
For more information on aggregating data with the GraphQL API, visit the datasets documentation page.