graphprotocol / graphprotocol/graph-node
[Feature] Query data from a fixed amount of blocks before latest
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 1.1k
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 1
Description
Description
A nice DevX improvement would be to allow querying for data in a way akin to this
query {
someEntity(block: {
number: -100
}) {
# fields ...
}
}
This query would fetch data at block latest - 100.
The rationale here is that a very common use case is to fetch data at a fixed amount of blocks prior to the tip to avoid data inconsistencies due to chain reorgs (or, in other words, to ensure data finality). AFAIK, right now the only way to do that is to first query the latest indexed block, and then perform the desired query at latest - n, which is cumbersome and repetitive.
Are you aware of any blockers that must be resolved before implementing this feature? If so, which? Link to any relevant GitHub issues.
No response
Some information to help us out
- Tick this box if you plan on implementing this feature yourself.
- I have searched the issue tracker to make sure this issue is not a duplicate.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start by tracing the existing GraphQL block argument handling and the mechanism used to obtain the latest indexed block. Confirm how a negative block number should resolve relative to the tip and how reorg finality is handled; done means the example query works without a separate latest-block request and is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, rust
- Domain
- api, blockchain
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100