You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/pages/en/subgraphs/developing/creating/advanced.mdx
+17-9Lines changed: 17 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -29,9 +29,13 @@ dataSources: ...
29
29
30
30
## Timeseries and Aggregations
31
31
32
-
Timeseries and aggregations enable your subgraph to track statistics like daily average price, hourly total transfers, etc.
32
+
Prerequisites:
33
33
34
-
This feature introduces two new types of subgraph entity. Timeseries entities record data points with timestamps. Aggregation entities perform pre-declared calculations on the Timeseries data points on an hourly or daily basis, then store the results for easy access via GraphQL.
34
+
- Subgraph specVersion must be ≥1.1.0.
35
+
36
+
Timeseries and aggregations enable your subgraph to track statistics like daily average price, hourly total transfers, and more.
37
+
38
+
This feature introduces two new types of subgraph entity. Timeseries entities record data points with timestamps. Aggregation entities perform pre-declared calculations on the timeseries data points on an hourly or daily basis, then store the results for easy access via GraphQL.
Timeseries entities are defined with `@entity(timeseries: true)` in the GraphQL schema. Every timeseries entity must:
59
+
60
+
- have a unique ID of the int8 type
61
+
- have a timestamp of the Timestamp type
62
+
- include data that will be used for calculation by aggregation entities.
53
63
54
-
Timeseries entities are defined with `@entity(timeseries: true)` in schema.graphql. Every timeseries entity must have a unique ID of the int8 type, a timestamp of the Timestamp type, and include data that will be used for calculation by aggregation entities. These Timeseries entities can be saved in regular trigger handlers, and act as the “raw data” for the Aggregation entities.
64
+
These Timeseries entities can be saved in regular trigger handlers, and act as the “raw data” for the aggregation entities.
55
65
56
-
Aggregation entities are defined with `@aggregation` in schema.graphql. Every aggregation entity defines the source from which it will gather data (which must be a Timeseries entity), sets the intervals (e.g., hour, day), and specifies the aggregation function it will use (e.g., sum, count, min, max, first, last). Aggregation entities are automatically calculated on the basis of the specified source at the end of the required interval.
66
+
Aggregation entities are defined with `@aggregation` in the GraphQL schema. Every aggregation entity defines the source from which it will gather data (which must be a timeseries entity), sets the intervals (e.g., hour, day), and specifies the aggregation function it will use (e.g., sum, count, min, max, first, last).
67
+
68
+
Aggregation entities are automatically calculated on the basis of the specified source at the end of the required interval.
57
69
58
70
#### Available Aggregation Intervals
59
71
@@ -81,10 +93,6 @@ Aggregation entities are defined with `@aggregation` in schema.graphql. Every ag
81
93
}
82
94
```
83
95
84
-
Note:
85
-
86
-
To use Timeseries and Aggregations, a subgraph must have a spec version ≥1.1.0. Note that this feature might undergo significant changes that could affect backward compatibility.
87
-
88
96
[Read more](https://github.com/graphprotocol/graph-node/blob/master/docs/aggregations.md) about Timeseries and Aggregations.
0 commit comments