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

add support for calculating cost based on args

Open chirag04 opened this issue 8 years ago • 3 comments
trafficstars

chirag04 avatar Jun 26 '17 19:06 chirag04

I tried to add that to this package here but ended up building my own validator that has support for args, variables and custom settings per field, similar to the implementation of the sangria library: https://github.com/ivome/graphql-query-complexity

ivome avatar Aug 02 '17 11:08 ivome

neat!

chirag04 avatar Aug 02 '17 12:08 chirag04

With Apollo Server, creating a new validation rule per request is tricky. In general, it's also not easy to get the relevant variables for a batch request.

I'm going to instead build this as a per-request (in batch) extension that sets variables onto a singleton before and after the validation phase.

This should be okay, given that validation is synchronous anyway.

taion avatar Apr 12 '19 20:04 taion