Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
<!-- ROUTER-384 --> # Overview Implements two new directives for demand control, based on the [IBM Cost Specification](https://ibm.github.io/graphql-specs/cost-spec.html). ``` directive @cost(weight: Int!) on | ARGUMENT_DEFINITION | ENUM | FIELD_DEFINITION | INPUT_FIELD_DEFINITION | OBJECT | SCALAR directive @listsize( assumedSize: Int, slicingArguments: [String!], sizedFields: [String!], requireOneSlicingArgument: Boolean = true ) on FIELD_DEFINITION ``` The `@cost` directive allows users to specify a custom weight for fields, enums, input objects, and arguments. The weight is used in the demand control cost calculation, both for static estimates as well as actual cost calculations. The `@listSize` directive allows users to specify expected sizes of list fields in their schema. This can be a static value set through `assumedSize` or a dynamic value using `slicingArguments` to get the value from some paging parameters. ## Differences from the spec The main difference from the IBM spec is that we use an `Int!` for weight argument of `@cost`. This allows the parser to enforce this is parameterized with proper numeric values instead of finding out at runtime that an invalid `String!` weight was passed. ## Caveats for shared fields When `@cost` or `@listSize` are used on a `@shareable` field with different values, the composed directive will use a merged value that takes the maximum weight or assumed size, when applicable.
- Loading branch information