0xPlaygrounds / 0xPlaygrounds/subgrounds

Last and first built-in synthetic fields on list fields

オープン
#6 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Python
スター
73
フォーク
12
PR マージ指標
30日以内にマージされた PR はありません

説明

**Is your feature request related to a problem? Please describe.**

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.

**Describe the solution you'd like**
```py
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
```

*Originally from: cvauclair*

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Look at the subgrounds codebase for where list fields and synthetic fields are defined. The issue suggests adding 'first' and 'last' methods to list fields that generate appropriate GraphQL queries with ordering. Start by examining the FieldPath class and how orderBy and orderDirection arguments are currently handled. Check existing tests for similar functionality to understand the pattern. The goal is to implement these methods to produce equivalent queries as shown in the examples.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
graphql, python
領域
api, backend-api-design
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
65/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。