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

Last and first built-in synthetic fields on list fields #9

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

Last and first built-in synthetic fields on list fields #9

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

Given a subgraph with a query field entities of type [Entity!]!, then entities.first and entities.last should produce a field path that represents the first and last of those entities ordered by timestamp (by default). If timestamp is not a valid field of entity Entity, then the field by which to order the entities can be specified using the orderBy argument.

Example

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

# These two are equivalent
last_swap_id = uniswapV2.Query.swaps.last().id

last_swap_id = uniswapV2.Query.swaps(
  orderBy=Swap.timestamp,
  orderDirection='desc',
  first=1
).id

# These two are also equivalent
last_pair_id = unsiwapV2.Query.pairs.last(orderBy='createdAtTimestamp').id

last_pair_id = uniswapV2.Query.pairs(
  orderBy=Pair.createdAtTimestamp,
  orderDirection='desc',
  first=1
).id
@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