Add Any::parse_value method. #56
This commit is contained in:
parent
2e32da7528
commit
c1e0b8f4a7
|
@ -1,6 +1,7 @@
|
|||
use crate::{Result, ScalarType, Value};
|
||||
use async_graphql_derive::Scalar;
|
||||
use itertools::Itertools;
|
||||
use serde::de::DeserializeOwned;
|
||||
|
||||
/// Any scalar
|
||||
///
|
||||
|
@ -31,6 +32,13 @@ impl ScalarType for Any {
|
|||
}
|
||||
}
|
||||
|
||||
impl Any {
|
||||
/// Parse this `Any` value to T by `serde_json`.
|
||||
fn parse_value<T: DeserializeOwned>(&self) -> std::result::Result<T, serde_json::Error> {
|
||||
serde_json::from_value(self.to_json().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
fn gql_value_to_json_value(value: &Value) -> serde_json::Value {
|
||||
match value {
|
||||
Value::Null => serde_json::Value::Null,
|
||||
|
|
Loading…
Reference in New Issue
Block a user