Skip to content

Commit 2091e54

Browse files
Updates
1 parent 7464e75 commit 2091e54

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

website/pages/en/subgraphs/developing/creating/advanced.mdx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ dataSources: ...
2929
3030
## Timeseries and Aggregations
3131
32+
Prerequisites:
33+
34+
- Subgraph specVersion must be ≥1.1.0.
35+
3236
Timeseries and aggregations enable your subgraph to track statistics like daily average price, hourly total transfers, etc.
3337
3438
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.
@@ -49,11 +53,18 @@ type Stats @aggregation(intervals: ["hour", "day"], source: "Data") {
4953
}
5054
```
5155

52-
### Defining Timeseries and Aggregations
56+
### How to Define Timeseries and Aggregations
57+
58+
Timeseries entities are defined with `@entity(timeseries: true)` in the GraphQL schema. Every timeseries entity must:
59+
- have a unique ID of the int8 type
60+
- have a timestamp of the Timestamp type
61+
- include data that will be used for calculation by aggregation entities.
5362

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.
63+
These Timeseries entities can be saved in regular trigger handlers, and act as the “raw data” for the aggregation entities.
5564

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.
65+
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).
66+
67+
Aggregation entities are automatically calculated on the basis of the specified source at the end of the required interval.
5768

5869
#### Available Aggregation Intervals
5970

@@ -81,10 +92,6 @@ Aggregation entities are defined with `@aggregation` in schema.graphql. Every ag
8192
}
8293
```
8394

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-
8895
[Read more](https://github.com/graphprotocol/graph-node/blob/master/docs/aggregations.md) about Timeseries and Aggregations.
8996

9097
## Non-fatal errors

0 commit comments

Comments
 (0)