Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Immediate single entity query #8

Open
cvauclair opened this issue Jan 23, 2022 · 0 comments
Open

Immediate single entity query #8

cvauclair opened this issue Jan 23, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@cvauclair
Copy link
Contributor

cvauclair commented Jan 23, 2022

Description

Subgrounds should allow developers to query a single entity from an id. The query (and returned object) should only have scalar, non-list values.

For nested fields returning non-scalar (i.e.: other entities) or list values, they should be queried at read time.

Example

sg = Subgrounds()
uniswapV2 = sg.load_subgraph('https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2')

# Fetch the pair and all its non-list scalar values with the id '0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc' 
some_pair = uniswapV2.Pair('0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc')

# Since txCount is a non-list scalar, the field's value would be prefetched 
# and reading it would not send a new query 
num_tx = some_pair.txCount

# Since token0 is not a scalar value, then it would be fetched at read 
# time and reading it would imply sengin a new query (all handled in the background)
token0_symbol = some_pair.token0.symbol
@cvauclair cvauclair added the enhancement New feature or request label Jan 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant