Skip to main content

cost

The purpose of the cost directive is to define a weight for GraphQL types, fields, and arguments. Static analysis can use these weights when calculating the overall cost of a query or response.

directive @cost(
weight: String!
) on
| SCALAR
| OBJECT
| FIELD_DEFINITION
| ARGUMENT_DEFINITION
| ENUM
| INPUT_FIELD_DEFINITION

Arguments

cost.weight ● String! non-null scalar

The weight argument defines what value to add to the overall cost for every appearance, or possible appearance, of a type, field, argument, etc.