Update parsing to support more formats, this includes the JS standard format that is not compatible with the %+
time format
This commit is contained in:
parent
ca4bd34207
commit
0a0fc03e8c
@ -1,6 +1,6 @@
|
|||||||
use crate::{InputValueError, InputValueResult, ScalarType, Value};
|
use crate::{InputValueError, InputValueResult, ScalarType, Value};
|
||||||
use async_graphql_derive::Scalar;
|
use async_graphql_derive::Scalar;
|
||||||
use chrono::{DateTime, TimeZone, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
|
||||||
/// Implement the DateTime<Utc> scalar
|
/// Implement the DateTime<Utc> scalar
|
||||||
///
|
///
|
||||||
@ -8,8 +8,10 @@ use chrono::{DateTime, TimeZone, Utc};
|
|||||||
#[Scalar(internal, name = "DateTimeUtc")]
|
#[Scalar(internal, name = "DateTimeUtc")]
|
||||||
impl ScalarType for DateTime<Utc> {
|
impl ScalarType for DateTime<Utc> {
|
||||||
fn parse(value: Value) -> InputValueResult<Self> {
|
fn parse(value: Value) -> InputValueResult<Self> {
|
||||||
match value {
|
match &value {
|
||||||
Value::String(s) => Ok(Utc.datetime_from_str(&s, "%+")?),
|
Value::String(s) => s
|
||||||
|
.parse::<DateTime<Utc>>()
|
||||||
|
.map_err(|_| InputValueError::ExpectedType(value)),
|
||||||
_ => Err(InputValueError::ExpectedType(value)),
|
_ => Err(InputValueError::ExpectedType(value)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user