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

Subgrounds requests with arguments #11

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

Subgrounds requests with arguments #11

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

Comments

@cvauclair
Copy link
Contributor

Description

Subgrounds fieldpaths and requests creation whould allow developers to specify variables in their queries.

The requests containing variables would act as request templates which can be used to create actual requests.

Example

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

swaps = Query.swaps(
  orderBy=Swap.timestamp,
  orderDirection='desc',
  first=500,
  where=[
    Swap.pair == Variable('address')
  ]
)

req_template = sg.mk_request([
  swaps.timestamp, 
  swaps.pair.token0.symbol,
  swaps.pair.token1.symbol,
  swaps.amount0In,
  swaps.amount1In,
  swaps.amount0Out,
  swaps.amount1Out
])

actual_req = req_template(address='0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc')

data = sg.execute(actual_req)
@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