Trait async_graphql::resolver_utils::ScalarType [−][src]
pub trait ScalarType: Sized + Send { fn parse(value: Value) -> InputValueResult<Self>; fn to_value(&self) -> Value; fn is_valid(_value: &Value) -> bool { ... } }
Expand description
A GraphQL scalar.
You can implement the trait to create a custom scalar.
Examples
use async_graphql::*; struct MyInt(i32); #[Scalar] impl ScalarType for MyInt { fn parse(value: Value) -> InputValueResult<Self> { if let Value::Number(n) = &value { if let Some(n) = n.as_i64() { return Ok(MyInt(n as i32)); } } Err(InputValueError::expected_type(value)) } fn to_value(&self) -> Value { Value::Number(self.0.into()) } }
Required methods
fn parse(value: Value) -> InputValueResult<Self>[src]
fn parse(value: Value) -> InputValueResult<Self>[src]Parse a scalar value.
Provided methods
Implementations on Foreign Types
impl ScalarType for Value[src]
impl ScalarType for Value[src]A scalar that can represent any JSON value.
impl ScalarType for bool[src]
impl ScalarType for bool[src]The Boolean scalar type represents true or false.
impl ScalarType for char[src]
impl ScalarType for char[src]The Char scalar type represents a unicode char.
The input and output values are a string, and there can only be one unicode character in this string.
impl ScalarType for f32[src]
impl ScalarType for f32[src]The Float scalar type represents signed double-precision fractional values as specified by IEEE 754.
impl ScalarType for f64[src]
impl ScalarType for f64[src]The Float scalar type represents signed double-precision fractional values as specified by IEEE 754.
impl ScalarType for i8[src]
impl ScalarType for i8[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for i16[src]
impl ScalarType for i16[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for i32[src]
impl ScalarType for i32[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for i64[src]
impl ScalarType for i64[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for u8[src]
impl ScalarType for u8[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for u16[src]
impl ScalarType for u16[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for u32[src]
impl ScalarType for u32[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for u64[src]
impl ScalarType for u64[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for usize[src]
impl ScalarType for usize[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for isize[src]
impl ScalarType for isize[src]The Int scalar type represents non-fractional whole numeric values.
impl<T> ScalarType for BTreeMap<String, T> where
T: OutputType + InputType, [src]
impl<T> ScalarType for BTreeMap<String, T> where
T: OutputType + InputType, [src]A scalar that can represent any JSON Object value.
impl<T> ScalarType for HashMap<String, T> where
T: OutputType + InputType, [src]
impl<T> ScalarType for HashMap<String, T> where
T: OutputType + InputType, [src]A scalar that can represent any JSON Object value.
impl ScalarType for NonZeroI8[src]
impl ScalarType for NonZeroI8[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for NonZeroI16[src]
impl ScalarType for NonZeroI16[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for NonZeroI32[src]
impl ScalarType for NonZeroI32[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for NonZeroI64[src]
impl ScalarType for NonZeroI64[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for NonZeroU8[src]
impl ScalarType for NonZeroU8[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for NonZeroU16[src]
impl ScalarType for NonZeroU16[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for NonZeroU32[src]
impl ScalarType for NonZeroU32[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for NonZeroU64[src]
impl ScalarType for NonZeroU64[src]The Int scalar type represents non-fractional whole numeric values.
impl ScalarType for String[src]
impl ScalarType for String[src]The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
impl ScalarType for ObjectId[src]
impl ScalarType for ObjectId[src]impl ScalarType for UtcDateTime[src]
impl ScalarType for UtcDateTime[src]impl ScalarType for Tz[src]
impl ScalarType for Tz[src]impl ScalarType for DateTime<FixedOffset>[src]
impl ScalarType for DateTime<FixedOffset>[src]Implement the DateTime
The input/output is a string in RFC3339 format.
impl ScalarType for DateTime<Local>[src]
impl ScalarType for DateTime<Local>[src]Implement the DateTime
The input/output is a string in RFC3339 format.
impl ScalarType for DateTime<Utc>[src]
impl ScalarType for DateTime<Utc>[src]Implement the DateTime
The input/output is a string in RFC3339 format.
impl ScalarType for NaiveDate[src]
impl ScalarType for NaiveDate[src]impl ScalarType for NaiveTime[src]
impl ScalarType for NaiveTime[src]impl ScalarType for NaiveDateTime[src]
impl ScalarType for NaiveDateTime[src]impl ScalarType for Url[src]
impl ScalarType for Url[src]impl ScalarType for Uuid[src]
impl ScalarType for Uuid[src]Implementors
impl ScalarType for Any[src]
impl ScalarType for Any[src]The _Any scalar is used to pass representations of entities from external services into the root _entities field for execution.
impl ScalarType for ID[src]
impl ScalarType for ID[src]impl<T: Num + Display + Send + Sync> ScalarType for StringNumber<T> where
<T as Num>::FromStrRadixErr: Display, [src]
impl<T: Num + Display + Send + Sync> ScalarType for StringNumber<T> where
<T as Num>::FromStrRadixErr: Display, [src]impl<T: DeserializeOwned + Serialize + Send + Sync> ScalarType for Json<T>[src]
impl<T: DeserializeOwned + Serialize + Send + Sync> ScalarType for Json<T>[src]A scalar that can represent any JSON value.