如何检索 GitLab GraphQL 的查询复杂度?

How to retrieve a GitLab GraphQL's query complexity?

有什么方法可以检索 GitLab GraphQL 查询的查询复杂度吗?

作为比较,GitHub 的 GraphQL api 有一个 rateLimit 对象,returns 查询的“costhttps://docs.github.com/en/graphql/overview/resource-limitations. GitLab 有类似的东西吗?

如果不存在这种能力,如何计算查询的复杂性?

https://docs.gitlab.com/ee/api/graphql/index.html#max-query-complexity

除非超过限制,否则无法发现查询的复杂性。

如果查询超过复杂性限制,将返回错误消息响应。

一般来说,查询中的每个字段都会将复杂性分数加 1,尽管对于特定字段来说这可能更高或更低。有时添加某些参数也可能会增加查询的复杂性。

不确定这是何时实施的,但您现在可以查询复杂性和限制,如文档和参考资料中所述https://docs.gitlab.com/ee/api/graphql/reference/#queryquerycomplexity

示例查询:

{
  queryComplexity {
    limit
    score
  }
}

示例响应:

{
  "data": {
    "queryComplexity": {
      "limit": 300,
      "score": 3
    }
  }
}