GraphQLInterpreter

caliban.GraphQLInterpreter
See theGraphQLInterpreter companion object
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.

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.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Abstract methods

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

Parses and validates the provided query against this API.

Parses and validates the provided query against this API.

Value parameters

query

a string containing the GraphQL query.

Attributes

Returns

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

def executeRequest(request: GraphQLRequest)(implicit trace: Trace): 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 parameters

request

a GraphQL request

Attributes

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])(implicit trace: Trace): 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 parameters

extensions

a map of extensions

operationName

the operation to run in case the query contains multiple operations

query

a string containing the GraphQL query

variables

a map of variables

Attributes

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 parameters

f

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

Attributes

Returns

a new GraphQL interpreter with error type E2

final def provideEnvironment(r: => ZEnvironment[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.

Attributes

final def provideLayer[E1 >: E, R0](layer: => ZLayer[R0, E1, 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.

Attributes

final def provideSomeLayer[R0]: 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.

Attributes

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 parameters

f

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

Attributes

Returns

a new GraphQL interpreter