Skip to content

Conversation

@eduhenke
Copy link

Fixes #82

@ivome
Copy link
Collaborator

ivome commented Oct 14, 2022

Thanks for the PR! If you want to get the actual query complexity, I don't think this library is the right tool for the job. The actual query complexity always depends on the returned data which will only ever be available after it has been resolved. So you'd have to add something to the resolver. Maybe I would add a value to the GraphQL context that I'd increment inside of the resolvers (or simplify that process with a middleware).
I am not sure if only the path is really helpful. You can also request fields via aliases that don't match the schema, there can be union / interface types, you can query the same field multiple times with different aliases / different input arguments etc. That information would be gone and could also affect the complexity:

{
  posts1: posts(limit: 100000) {
    title
    relatedPosts(limit: 3) {
      title # Here you would have the path ["posts1", "relatedPosts", "title"] What could you do with this?
    }
  }
  posts2: posts(limit: 1) {
    title
    relatedPosts(limit: 3000000) {
      title
    }
  }
}

Not sure I fully understand the benefit.

@ivome
Copy link
Collaborator

ivome commented Dec 14, 2022

Closing this here as there was no activity for a while and I'm not sure this is something we want to add here.

@ivome ivome closed this Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: adding path to estimators args(for calculating actual query complexity)

2 participants