-
Notifications
You must be signed in to change notification settings - Fork 981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Queries for aggregations #5184
Queries for aggregations #5184
Conversation
f20c521
to
0cdfd97
Compare
graph/src/schema/input_schema.rs
Outdated
} | ||
|
||
/// Return an `EntityType` that either references the object type `name` | ||
/// or, if `name` refernces an aggregation, return the object type of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// or, if `name` refernces an aggregation, return the object type of | |
/// or, if `name` references an aggregation, return the object type of |
Small typo
graphql/src/store/mod.rs
Outdated
@@ -2,5 +2,5 @@ mod prefetch; | |||
mod query; | |||
mod resolver; | |||
|
|||
pub use self::query::parse_subgraph_id; | |||
//pub use self::query::parse_subgraph_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//pub use self::query::parse_subgraph_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woops .. forgot to remove that. Done
@lutter i was unable to test the aggregation-example subgraph, im getting graph-cli error, how did you get over it?
|
I totally forgot that I have this PR against |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was able to test it out with the example subgraph with the CLI alpha version
0.68.0-alpha-20240208230340-9ea4027
LGTM
f018c57
to
a8d204f
Compare
We use 'order by timestamp' on the raw data to make sure that first and last work correctly. But the name 'timestamp' was ambiguous as we select a timestamp and the data table has one. The selected timestamp is the same for all data points in the interval, whereas the timestamp from the data table is the block's timestamp, which is what we need to sort by. This change makes sure we sort by the timestamp from the data table as intended.
…tion We don't add it in the first place
Change the block time for test blocks to 45 minutes so that block 2 is in a different hour from block 0. In addition, make the query tests process block 2 with no changes. There's no other changes to the tests other than adapting them to the additional processed block.
Previously, we missed adding the filters etc. to query fields that were collections of aggregations
This required a major rework of the GraphQL query infrastructure as prefetch now needs to translate from types in the API schema to types in the InputSchema as the concrete types for the aggregations do not exist in the API schema. Before, we relied a lot on the fact that the API schema contained the same types as the input schema with the exact same names and structure. But conceptually, prefetch and query building deals with types from the input schema as that describes how data is ultimately stored in the database.
The meaning of that is very murky, but it changes API schema and has been there for a long time
a8d204f
to
9c154cc
Compare
I just finished testing queries against the hosted service. The biggest changes this introduces for existing queries are:
|
This PR enables querying of aggregations through the GraphQL interface. It required a major rework of the GraphQL query infrastructure as prefetch now needs to translate from types in the API schema to types in the InputSchema as the concrete types for the aggregations do not exist in the API schema.
Before, we relied a lot on the fact that the API schema contained the same types as the input schema with the exact same names and structure. But conceptually, prefetch and query building deals with types from the input schema as that describes how data is ultimately stored in the database.
To try this out, deploy the
aggregation-example
subgraph that builds aggregations over ethereum block numbers as those are easy to check.