17 lines
431 B
Rust
17 lines
431 B
Rust
use crate::{GQLScalar, InputValueError, InputValueResult, ScalarType, Value};
|
|
use url::Url;
|
|
|
|
#[GQLScalar(internal)]
|
|
impl ScalarType for Url {
|
|
fn parse(value: Value) -> InputValueResult<Self> {
|
|
match value {
|
|
Value::String(s) => Ok(Url::parse(&s)?),
|
|
_ => Err(InputValueError::ExpectedType(value)),
|
|
}
|
|
}
|
|
|
|
fn to_value(&self) -> Value {
|
|
Value::String(self.to_string())
|
|
}
|
|
}
|