[Feature] Disable a graphql filter if the variable is not set

オープン
#4,964 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
postgresql, rust
領域
api, backend, databases

調査の方向性

まず、graph-node における省略された変数の GraphQL フィルター処理を追跡し、2 つの curl の例に示されている公開 API の動作と比較します。省略された変数によって null との等価条件が生成されるのではなく、そのフィルターが無効になり、例のクエリの動作がテストでカバーされれば完了です。

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

説明

enhancement question Stale
Description

Hi, I was running a graph-node of the latest stable version (v0.33.0), and an example-subgraph. After that, I was trying to request entities with GraphQL query like:

curl 'http://127.0.0.1:9000/subgraphs/name/example' \
  -H 'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8' \
  -H 'Connection: keep-alive' \
  -H 'Origin: http://127.0.0.1:9000' \
  -H 'Referer: http://127.0.0.1:9000/subgraphs/name/example/graphql' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' \
  -H 'accept: application/json, multipart/mixed' \
  -H 'content-type: application/json' \
  -H 'sec-ch-ua: "Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  --data-raw '{"query":"query MyQuery($id: ID) {\n  gravatars(first: 10, where: {id: $id}) {\n    id\n  }\n}","variables":{},"operationName":"MyQuery","extensions":{"headers":null}}' \
  --compressed

For more clarity, we define a filter variable id but leave it alone without setting any value.

query MyQuery($id: ID) {
  gravatars(first: 10, where: {id: $id}) {
    id
  }
}

In this case, the graph-node returns me nothing, looking like it takes the variable id as null, and queries the Postgres with the filter condition to check if id is equal to null.

Interestingly, while I was trying to simulate a similar action in our thegraph endpoint api.thegraph.com, even I didn't set any variables for id or symbol, the server would still response all entries regarding these filter variables as disabled.

curl 'https://api.thegraph.com/subgraphs/name/graphprotocol/compound-v2' \
  -H 'authority: api.thegraph.com' \
  -H 'accept: */*' \
  -H 'accept-language: zh-CN,zh;q=0.9,en;q=0.8' \
  -H 'content-type: application/json' \
  -H 'origin: https://api.thegraph.com' \
  -H 'referer: https://api.thegraph.com/subgraphs/name/graphprotocol/compound-v2' \
  -H 'sec-ch-ua: "Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-origin' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' \
  --data-raw '{"operationName":"markets","variables":{},"query":"query markets($id: ID, $symbol: String) {\n  markets(first: 7, where: {id: $id, symbol: $symbol}) {\n    id\n    symbol\n  }\n}\n"}' \
  --compressed

So, what is the main cause for this difference of GraphQL filter behavior between graph-node binary and our public api endpoint? Is it possible for graph-node to conform with the same behavior (disable a graphql filter if the variable is not set)?

This issue may also be relevant to #4112

Are you aware of any blockers that must be resolved before implementing this feature? If so, which? Link to any relevant GitHub issues.

No response

Some information to help us out
  • Tick this box if you plan on implementing this feature yourself.
  • I have searched the issue tracker to make sure this issue is not a duplicate.
主要言語
Rust
スター
3.2k
フォーク
1.1k
平均マージ
4日 1時間
マージ済み PR(30日)
1

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

graphprotocol/graph-node のほかの issue

graphprotocol/graph-node の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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