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

未关闭
#4,964 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
postgresql, rust
领域
api, backend, databases

调研方向

首先跟踪 graph-node 对省略变量的 GraphQL 过滤器处理,并将其与两个 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 小时
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

graphprotocol/graph-node 的其他 Issue

查看 graphprotocol/graph-node 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。