mochi/args
Typed accessor for GraphQL field arguments.
Resolvers receive arguments as Args, an opaque wrapper around a
Dict(String, Dynamic). Use the get_* family to read fields with
type checking; to_dict is a back-compat escape hatch.
Types
Why an argument lookup failed. Resolvers normally translate this into
a mochi/error.GraphQLError at the boundary — kept structural here so
mochi/args doesn’t have to depend on the error module (which would
cycle through types and schema).
pub type ArgError {
Missing(key: String)
WrongType(key: String, expected: String)
InvalidInput(key: String)
}
Constructors
-
Missing(key: String) -
WrongType(key: String, expected: String) -
InvalidInput(key: String)
Values
pub fn decode_input(
a: Args,
key: String,
decoder: decode.Decoder(b),
) -> Result(b, ArgError)
pub fn error_message(err: ArgError) -> String
Render an ArgError as the same kind of message the legacy
query.get_* family produced, so downstream error reporting doesn’t
change.
pub fn from_dict(d: dict.Dict(String, dynamic.Dynamic)) -> Args
Wrap a raw dict as Args. The executor calls this at the resolver
boundary; user code rarely needs it directly.
pub fn get_optional_bool(
a: Args,
key: String,
) -> option.Option(Bool)
pub fn get_optional_float(
a: Args,
key: String,
) -> option.Option(Float)
pub fn get_optional_int(
a: Args,
key: String,
) -> option.Option(Int)
pub fn get_optional_string(
a: Args,
key: String,
) -> option.Option(String)
pub fn to_dict(a: Args) -> dict.Dict(String, dynamic.Dynamic)
Unwrap to the underlying dict — for code bridging to APIs that still
take Dict(String, Dynamic). Avoid in new code.