graphql-query-complexity icon indicating copy to clipboard operation
graphql-query-complexity copied to clipboard

Feature request: Add directive estimation support for "initial complexity"

Open liam-jones-lucout opened this issue 2 years ago • 1 comments

Imagine we have an external service that we're calling out to in order to populate the foo array field.

I can request any number of elements for that, but the issue is that asking for any number drastically increases complexity, whereas the relative complexity between requesting 1 and 2 entries is much lower.

It would be good to have an "initial" field on the complexity directive, e.g.

@complexity(value: 1, multipliers: :["limit"], initial: 10)

in this example, requesting with a limit of 1 would be a complexity of 11, and requesting 2 would be a complexity if 12, etc.

If we like this suggestion I'm happy to take a crack at implementation

liam-jones-lucout avatar Feb 23 '23 15:02 liam-jones-lucout

This seems like a valuable addition to add. I'm happy to review / merge a PR if you are still interested in adding this.

ivome avatar Jun 10 '24 13:06 ivome