object CostEstimation
- Alphabetic
- By Inheritance
- CostEstimation
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- case class GQLCost(cost: Double, multipliers: List[String] = Nil) extends GQLDirective with Product with Serializable
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final val COST_DIRECTIVE_NAME: String("cost")
- final val COST_EXTENSION_NAME: String("queryCost")
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- val costDirective: (Field) => Double
Computes field cost by examining the @cost directive.
Computes field cost by examining the @cost directive. This can be used in conjunction with
queryCost
or maxCost In order to compute the estimated cost of executing a query.- Note
This will be executed *before* the actual resolvers are called, which allows you to stop potentially expensive queries from being run, but may also require more work on the developer part to determine the correct heuristic for estimating field cost.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def maxCost(maxCost: Double)(f: (Field) => Double): ValidationWrapper[Any]
Computes the estimated cost of executing the query using the provided function and compares it to the
maxCost
parameter which determines the maximum allowable cost for a query.Computes the estimated cost of executing the query using the provided function and compares it to the
maxCost
parameter which determines the maximum allowable cost for a query.- maxCost
The maximum allowable cost for executing a query
- f
The field cost estimate function
- def maxCostOrError(maxCost: Double)(f: (Field) => Double)(error: (Double) => ValidationError): ValidationWrapper[Any]
More powerful version of maxCost which allow you to also specify the error that is returned when the cost exceeds the maximum cost.
More powerful version of maxCost which allow you to also specify the error that is returned when the cost exceeds the maximum cost.
- maxCost
The total cost allowed for any one query
- f
The function used to evaluate the cost of a single field
- error
A function that will be provided the total estimated cost and must return the error that will be returned
- def maxCostZIO[R](maxCost: Double)(f: (Field) => URIO[R, Double]): ValidationWrapper[R]
More powerful version of maxCost which allows the field computation function to specify a function which returns an effectful computation for the cost of a field.
More powerful version of maxCost which allows the field computation function to specify a function which returns an effectful computation for the cost of a field.
- maxCost
The total cost allowed for any one query
- f
The function used to evaluate the cost of a single field returning an effect which will result in the field cost as a double
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def queryCost(f: (Field) => Double): Wrapper[Any]
Computes the estimated cost of the query based on the provided field cost function and adds it as an extension to the GraphQLResponse.
Computes the estimated cost of the query based on the provided field cost function and adds it as an extension to the GraphQLResponse. This is useful for tracking the overall cost of a query either when you are trying to dial in a correct heuristic or when you want to inform users of your graph how expensive their queries are.
- See also
queryCostWith, queryCostZIO
- lazy val queryCost: Wrapper[Any]
Computes the estimated cost of the query based on the default cost estimation (backed by the @GQLCost directive) and adds it as an extension to the GraphQLResponse.
Computes the estimated cost of the query based on the default cost estimation (backed by the @GQLCost directive) and adds it as an extension to the GraphQLResponse. This is useful for tracking the overall cost of a query either when you are trying to dial in a correct heuristic or when you want to inform users of your graph how expensive their queries are.
- See also
queryCostWith, queryCostZIO
- def queryCostWith[R](f: (Field) => Double)(p: (Double) => URIO[R, Any]): Wrapper[R]
Computes the estimated cost of the query based on the provided field cost function and passes it to the second function which can run an arbitrary side effect with the result.
Computes the estimated cost of the query based on the provided field cost function and passes it to the second function which can run an arbitrary side effect with the result.
- See also
queryCost
- def queryCostZIO[R](f: (Field) => URIO[R, Double]): Wrapper[R]
A more powerful version of
queryCost
which allows the field cost computation to return an effect instead of a plain value when computing the cost estimate.A more powerful version of
queryCost
which allows the field cost computation to return an effect instead of a plain value when computing the cost estimate.- f
The field cost estimate function
- See also
queryCostZIOWith for a more powerful version
- def queryCostZIOWith[R](f: (Field) => URIO[R, Double])(p: (Double) => URIO[R, Any]): Wrapper[R]
A more powerful version of queryCostZIO that allows the total result of the query to be pushed into a separate effect.
A more powerful version of queryCostZIO that allows the total result of the query to be pushed into a separate effect. This is useful when you want to compute the cost of the query but you already have your own system for recording the cost.
- f
The field cost estimate function
- p
A function which receives the total estimated cost of executing the query and can
- def queryCostZIOWrapperState[R](costWrapper: (Ref[Double]) => Wrapper[R])(p: (Double, GraphQLResponse[CalibanError]) => URIO[R, GraphQLResponse[CalibanError]]): Wrapper[R]
The most powerful version of
queryCost
that allows maximum freedom in how the wrapper is defined.The most powerful version of
queryCost
that allows maximum freedom in how the wrapper is defined. The function accepts a function that will take a Ref that can be used for book keeping to track the current cost of the query, and returns a wrapper. Normally this wrapper is a validation wrapper because it should be run before execution for the purposes of cost estimation. However, the API provides the flexibility to redefine that. The second parameter of the function will receive the final cost estimate of the query as well as the current graphql response, it returns an effect that produces a potentially modified response.- costWrapper
User provided function that will result in a wrapper that may be used when computing the cost of a query
- p
The response transforming function which receives the cost estimate as well as the response value.
- See also
queryCostZIOWith, queryCostZIO, queryCost
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- object CostDirective
A directive that can be applied to both fields and types to flag them as targets for cost analysis.
A directive that can be applied to both fields and types to flag them as targets for cost analysis. This allows a simple estimation to be applied which can be used to prevent overly expensive queries from being executed
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated