Stream data access
The area streamData
allows access to stored time series data. Let's start with simple sample that requests the voltage value of all energy meters by their timestamp.
query {
streamData {
tsIndustryEnergyEnergyMeter {
items {
rtId
ckTypeId
timeStamp
voltage
}
}
}
}
A response to this query can look like the following:
{
"data": {
"streamData": {
"tsIndustryEnergyEnergyMeter": {
"items": [
{
"rtId": "65dc6d24cc529cdc46c84fcc",
"ckTypeId": "Industry.Energy/EnergyMeter",
"timeStamp": "2024-03-21T16:22:47.676Z",
"voltage": 4.04196210149963
},
{
"rtId": "65dc6d24cc529cdc46c84fcc",
"ckTypeId": "Industry.Energy/EnergyMeter",
"timeStamp": "2024-03-21T16:23:50.675Z",
"voltage": -9.00808094383129
}
]
}
}
}
}
Pagination
Both runtime and stream data can be paginated to manage large datasets effectively. Pagination is achieved through the use of the first
and after
arguments in GraphQL queries. The first
argument specifies the number of items to return, while the after
argument indicates the cursor position to start fetching data.
Example query with pagination:
query {
streamData {
tsIndustryEnergyEnergyMeter(first: 2, after: "YXJyYXljb25uZWN0aW9uOjE=") {
pageInfo {
endCursor
hasNextPage
}
items {
rtId
ckTypeId
timeStamp
voltage
}
}
}
}
This query returns the first two items after the cursor position specified by the after
argument. The response includes the endCursor
and hasNextPage
fields, which help manage pagination effectively.