mochi/executor

Types

pub type DebugContext {
  DebugContext(
    enabled: Bool,
    indent_level: Int,
    step_counter: Int,
  )
}

Constructors

  • DebugContext(enabled: Bool, indent_level: Int, step_counter: Int)
pub type DeferredPatch {
  DeferredPatch(
    path: List(String),
    data: option.Option(dynamic.Dynamic),
    errors: List(ExecutionError),
    label: option.Option(String),
  )
}

Constructors

pub type ExecutionError {
  ValidationError(
    message: String,
    path: List(String),
    location: option.Option(#(Int, Int)),
  )
  ResolverError(
    message: String,
    path: List(String),
    location: option.Option(#(Int, Int)),
  )
  TypeError(
    message: String,
    path: List(String),
    location: option.Option(#(Int, Int)),
  )
  NullValueError(
    message: String,
    path: List(String),
    location: option.Option(#(Int, Int)),
  )
  RichResolverError(
    graphql_error: error.GraphQLError,
    path: List(String),
    location: option.Option(#(Int, Int)),
  )
}

Constructors

  • ValidationError(
      message: String,
      path: List(String),
      location: option.Option(#(Int, Int)),
    )

    Arguments

    location

    Source location of the field in the query document (line, column)

  • ResolverError(
      message: String,
      path: List(String),
      location: option.Option(#(Int, Int)),
    )

    Arguments

    location

    Source location of the field in the query document (line, column)

  • TypeError(
      message: String,
      path: List(String),
      location: option.Option(#(Int, Int)),
    )

    Arguments

    location

    Source location of the field in the query document (line, column)

  • NullValueError(
      message: String,
      path: List(String),
      location: option.Option(#(Int, Int)),
    )

    Arguments

    location

    Source location of the field in the query document (line, column)

  • RichResolverError(
      graphql_error: error.GraphQLError,
      path: List(String),
      location: option.Option(#(Int, Int)),
    )
pub type ExecutionResult {
  ExecutionResult(
    data: option.Option(dynamic.Dynamic),
    errors: List(ExecutionError),
    deferred: List(DeferredPatch),
  )
}

Constructors

pub type FieldContext {
  FieldContext(
    parent_value: option.Option(dynamic.Dynamic),
    field_name: String,
    field_args: dict.Dict(String, dynamic.Dynamic),
    path: List(String),
  )
}

Constructors

pub type QueryExecutionContext {
  QueryExecutionContext(
    schema: schema.Schema,
    root_value: option.Option(dynamic.Dynamic),
    execution_context: schema.ExecutionContext,
    variable_values: dict.Dict(String, dynamic.Dynamic),
    fragments: dict.Dict(String, @internal Fragment),
  )
}

Constructors

Values

pub fn execute(
  schema_def: schema.Schema,
  document: @internal Document,
  root_value: option.Option(dynamic.Dynamic),
  execution_context: schema.ExecutionContext,
  variable_values: dict.Dict(String, dynamic.Dynamic),
) -> ExecutionResult
pub fn execute_query(
  schema_def: schema.Schema,
  query: String,
) -> ExecutionResult
pub fn execute_query_debug(
  schema_def: schema.Schema,
  query: String,
) -> ExecutionResult
pub fn execute_query_debug_with_variables(
  schema_def: schema.Schema,
  query: String,
  variables: dict.Dict(String, dynamic.Dynamic),
) -> ExecutionResult
pub fn execute_query_with_context(
  schema_def: schema.Schema,
  query: String,
  variables: dict.Dict(String, dynamic.Dynamic),
  ctx: schema.ExecutionContext,
) -> ExecutionResult

Execute a query with a custom execution context (enables full telemetry).

Use this function when you need telemetry for parsing and validation phases.

Example

let config = telemetry.with_handler(fn(event) { echo event })
let ctx = schema.execution_context(user_data)
  |> schema.with_telemetry_fn(telemetry.to_schema_fn(config))

let result = executor.execute_query_with_context(
  my_schema,
  "{ users { name } }",
  dict.new(),
  ctx,
)
pub fn execute_query_with_variables(
  schema_def: schema.Schema,
  query: String,
  variables: dict.Dict(String, dynamic.Dynamic),
) -> ExecutionResult
pub fn execute_with_operation_name(
  schema_def: schema.Schema,
  document: @internal Document,
  root_value: option.Option(dynamic.Dynamic),
  execution_context: schema.ExecutionContext,
  variable_values: dict.Dict(String, dynamic.Dynamic),
  operation_name: option.Option(String),
) -> ExecutionResult

Execute with a specific operation name selected This is useful for documents containing multiple operations

pub fn get_or_parse(
  schema_def: schema.Schema,
  query: String,
) -> Result(@internal Document, parser.ParseError)
Search Document