Skip to content
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

[$3000 in SQT] Allow query historical data by block range #1887

Open
jiqiang90 opened this issue Jul 17, 2023 · 3 comments · May be fixed by #2540
Open

[$3000 in SQT] Allow query historical data by block range #1887

jiqiang90 opened this issue Jul 17, 2023 · 3 comments · May be fixed by #2540
Assignees
Labels
crucial Change worth spreading the news Documentation Required guild Tasks that are available via the guild New Feature Query Service

Comments

@jiqiang90
Copy link
Contributor

jiqiang90 commented Jul 17, 2023

Description

We currently allow pass a block height, and get any result less equal than this height

image

We now want to add a filter for block height, so it can filter data with in a specific block range

image

Single entities

To start with we should have the ability to query an entity by its id and specify a block range. We need to consider that we only return 100 results and there might be more in the block range.

Possible example query:

{
  # current single entity query
  example1: entity(id: 'foo') {
    id
    field1
    field2
  }
  # extend the current query
  example2: entity(id: 'foo', blockRange: [0, 100]) {
    id
    field1
    field2
  }
  # a new entity name
  example3: entityHistory(id: 'foo', blockRange: [0, 100]) {
    id
    field1
    field2
  }
}

Example response:

{
  example1: {
    id: 'foo',
    field1: 1,
    field2: 'bar',
  },
  example2: {
    // Keyed by block height
    5: {
      id: 'foo',
      field1: 1,
      field2: 'bar',
    },
    10: {
      id: 'foo',
      field1: 2,
      field2: 'bazz',
    },
    90: null, // indicates the entity was deleted
  },
  // example3 same result as example 2
}

Multiple entities

This is more complex and can come as another improvement at a later stage

Requirements

  • Tests which generate a schema and correctly show gql being converted to the appropriate sql
  • Documentation should be updated to include how to use this feature
  • Backwards compatible, i.e it should not change the behaviour of any current queries
  • Work with all other graphql plugins and features such as filtering, ordering, relations
@stwiname stwiname added Query Service Documentation Required crucial Change worth spreading the news guild Tasks that are available via the guild labels Jun 3, 2024
@stwiname stwiname changed the title Allow query historical data by block range [$2000 in SQT] Allow query historical data by block range Jun 3, 2024
@stwiname stwiname changed the title [$2000 in SQT] Allow query historical data by block range [$3000 in SQT] Allow query historical data by block range Jun 3, 2024
@abhishek818
Copy link
Contributor

Will take this up!

@stwiname
Copy link
Collaborator

Will take this up!

@abhishek818 i have assigned you to this. Let us know if you have any questions

@abhishek818
Copy link
Contributor

Will take this up!

@abhishek818 i have assigned you to this. Let us know if you have any questions

Added a query in draft PR, pls have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crucial Change worth spreading the news Documentation Required guild Tasks that are available via the guild New Feature Query Service
Projects
Status: Open Tasks!
Development

Successfully merging a pull request may close this issue.

4 participants