slicknode/graphql-query-complexity

Feature Request: expose the node to estimators

noc7c9 opened this issue · 1 comments

Hiya, first off thanks for the amazing library.

I'm trying to implement a custom estimation that depends on which fields are selected under a type.

Here's an example:

query {
    a: someType { id } # Only id is selected, so calculation happens one way
    b: someType { id, some, fields } # More than id is selected so calculation happens another way
}

I don't believe that the exact behavior I want is achievable with childComplexity unfortunately, I need access to the selectionSet for the given node.

Hopefully that made some sense!

ivome commented

We could just pass the node as part of the estimator args. This would enable a whole bunch of additional functionality and ways to calculate the complexity of a field. Could potentially also be relevant for #41

Happy to merge a PR if you want to add this.