juniper icon indicating copy to clipboard operation
juniper copied to clipboard

return Result from to_output_with of a scalar

Open nigimaxx opened this issue 2 months ago • 3 comments

Is it possible to implement a scalar that returns a result from its to_output method?

In the end it should look something like this:

#[derive( GraphQLScalar)]
#[graphql(
    name = "Scalar",
    to_output_with = Self::to_output,
    from_input_with = Self::from_input,
   )]
pub struct Scalar(bool);

impl Scalar {
    fn to_output(value: &Scalar) -> Result<String, Err> { ... }

    fn from_input(input: &str) -> Result<Self, Err> { ... }
}

nigimaxx avatar Nov 03 '25 02:11 nigimaxx