GraphQLInterpreter

trait GraphQLInterpreter[-R, +E]

A GraphQLInterpreter[-R, +E] represents a GraphQL interpreter whose execution requires a ZIO environment of type R and can fail with an E.

A GraphQLInterpreter[-R, +E] represents a GraphQL interpreter whose execution requires a ZIO environment of type R and can fail with an E.

It is a wrapper around a GraphQL API definition that allows adding some middleware around query execution, and possibly transform the environment or the error type.

Companion
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def check(query: String): IO[CalibanError, Unit]

Parses and validates the provided query against this API.

Parses and validates the provided query against this API.

Value Params
query

a string containing the GraphQL query.

Returns

an effect that either fails with a CalibanError or succeeds with Unit

def executeRequest(request: GraphQLRequest, skipValidation: Boolean, enableIntrospection: Boolean, queryExecution: QueryExecution): URIO[R, GraphQLResponse[E]]

Parses, validates and finally runs the provided request against this interpreter.

Parses, validates and finally runs the provided request against this interpreter.

Value Params
enableIntrospection

returns an error for introspection queries when false

queryExecution

a strategy for executing queries in parallel or not

request

a GraphQL request

skipValidation

skips the validation step if true

Returns

an effect that either fails with an E or succeeds with a ResponseValue

Concrete methods

def execute(query: String, operationName: Option[String], variables: Map[String, InputValue], extensions: Map[String, InputValue], skipValidation: Boolean, enableIntrospection: Boolean, queryExecution: QueryExecution): URIO[R, GraphQLResponse[E]]

Parses, validates and finally runs the provided query against this interpreter.

Parses, validates and finally runs the provided query against this interpreter.

Value Params
enableIntrospection

returns an error for introspection queries when false

extensions

a map of extensions

operationName

the operation to run in case the query contains multiple operations

query

a string containing the GraphQL query

queryExecution

a strategy for executing queries in parallel or not

skipValidation

skips the validation step if true

variables

a map of variables

Returns

an effect that either fails with an E or succeeds with a ResponseValue

final def mapError[E2](f: E => E2): GraphQLInterpreter[R, E2]

Changes the error channel of the execute method. This can be used to customize error messages.

Changes the error channel of the execute method. This can be used to customize error messages.

Value Params
f

a function from the current error type E to another type E2

Returns

a new GraphQL interpreter with error type E2

final def provide(r: R)(ev: NeedsEnv[R]): GraphQLInterpreter[Any, E]

Provides the interpreter with its required environment, which eliminates its dependency on R.

Provides the interpreter with its required environment, which eliminates its dependency on R.

final def provideCustomLayer[E1 >: E, R1 <: Has[_]](layer: ZLayer[ZEnv, E1, R1])(ev: ZEnv & R1 <:< R, tagged: Tag[R1]): GraphQLInterpreter[ZEnv, E1]

Provides the part of the environment that is not part of the ZEnv, leaving a query that only depends on the ZEnv.

Provides the part of the environment that is not part of the ZEnv, leaving a query that only depends on the ZEnv.

final def provideLayer[E1 >: E, R0, R1 <: Has[_]](layer: ZLayer[R0, E1, R1])(ev1: R1 <:< R, ev2: NeedsEnv[R]): GraphQLInterpreter[R0, E1]

Provides a layer to this interpreter, which translates it to another level.

Provides a layer to this interpreter, which translates it to another level.

final def provideSomeLayer[R0 <: Has[_]]: ProvideSomeLayer[R0, R, E]

Splits the environment into two parts, providing one part using the specified layer and leaving the remainder R0.

Splits the environment into two parts, providing one part using the specified layer and leaving the remainder R0.

final def wrapExecutionWith[R2, E2](f: URIO[R, GraphQLResponse[E]] => URIO[R2, GraphQLResponse[E2]]): GraphQLInterpreter[R2, E2]

Wraps the execute method of the interpreter with the given function. This can be used to customize errors, add global timeouts or logging functions.

Wraps the execute method of the interpreter with the given function. This can be used to customize errors, add global timeouts or logging functions.

Value Params
f

a function from URIO[R, GraphQLResponse[E]] to URIO[R2, GraphQLResponse[E2]]

Returns

a new GraphQL interpreter