checkpoint-labs / checkpoint

Checkpoint is a library for indexing data of Starknet contracts.
https://checkpoint.box
MIT License
55 stars 22 forks source link

feat: add support for non-derived one-to-many relations #287

Closed Sekhmet closed 5 months ago

Sekhmet commented 5 months ago

Currently you can define one-to-many relations using @derivedFrom directive. Using it the field on the entity is just virtual field that gets filled in at query time using lookup on the derived entity's column.

This PR adds support for non-derived one-to-many relations - this field needs to be filled in by writers to be usable. You specify ID's of referenced entity and those will be filled in with full object at query time.

bonustrack commented 5 months ago

Would that make it possible to query a subquery like this?


query {
  space(id: "0x123") {
      id
      proposals (where: { vote_count_gt: 10 }}) {
        id
      }
  }
}
Sekhmet commented 5 months ago

Not at the moment, although I could add that I think. This was added to support executions on Starknet which didn't require filters like this.

This is unrelated to this PR though.