Packages

o

caliban.wrappers

CostEstimation

object CostEstimation

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CostEstimation
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. case class GQLCost(cost: Double, multipliers: List[String] = Nil) extends GQLDirective with Product with Serializable

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final val COST_DIRECTIVE_NAME: String("cost")
  5. final val COST_EXTENSION_NAME: String("queryCost")
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  8. 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.

  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  11. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. 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

  15. 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

  16. 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

  17. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  19. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  20. 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

  21. 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

  22. 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

  23. 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

  24. 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

  25. 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

  26. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  27. def toString(): String
    Definition Classes
    AnyRef → Any
  28. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  29. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  30. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  31. 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

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped