Current section
Files
Jump to
Current section
Files
src/dagger/dsl/error_value.gleam
// AUTO-GENERATED BY DAGGER_GLEAM - DO NOT EDIT
import dagger/types.{type Client, type Try} as types
import dagger/interpreter
import dagger/dsl/types as t
import gleam/dynamic/decode
import gleam/list
pub fn error_value(id id: t.ErrorValue) -> t.ErrorValue {
let field = types.Field(name: "loadErrorValueFromID", args: [#("id", types.GDeferred(id.op))], subfields: [])
t.ErrorValue(op: types.Pure([field]))
}
/// A unique identifier for this ErrorValue.
pub fn id(parent: t.ErrorValue) -> t.ErrorValue {
let field = types.Field(name: "id", args: [], subfields: [])
let new_op = {
use q <- types.bind(parent.op)
types.Pure(list.append(q, [field]))
}
t.ErrorValue(op: new_op)
}
/// The name of the value.
pub fn name(parent: t.ErrorValue, client client: Client, then handler: fn(Try(String)) -> a) -> a {
let field = types.Field(name: "name", args: [], subfields: [])
let op = {
use q <- types.bind(parent.op)
let full_query = list.append(q, [field])
types.Fetch(
fields: full_query,
decoder: decode.dynamic,
next: fn(dyn) {
let path = types.make_path(full_query)
case decode.run(dyn, decode.at(path, decode.string)) {
Ok(val) -> types.Pure(Ok(val))
Error(_) -> types.Pure(Error(types.DecodingError("name")))
}
}
)
}
handler(interpreter.run(op, client))
}
/// The value.
pub fn value(parent: t.ErrorValue, client client: Client, then handler: fn(Try(String)) -> a) -> a {
let field = types.Field(name: "value", args: [], subfields: [])
let op = {
use q <- types.bind(parent.op)
let full_query = list.append(q, [field])
types.Fetch(
fields: full_query,
decoder: decode.dynamic,
next: fn(dyn) {
let path = types.make_path(full_query)
case decode.run(dyn, decode.at(path, decode.string)) {
Ok(val) -> types.Pure(Ok(val))
Error(_) -> types.Pure(Error(types.DecodingError("value")))
}
}
)
}
handler(interpreter.run(op, client))
}