feat: support bson v2.0.0-beta
This commit is contained in:
parent
aa3bf842e0
commit
05edf40b39
|
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Bump upstream crate `bson` from `v1.2.0` to `v2.0.0-beta.1`. [#516](https://github.com/async-graphql/async-graphql/pull/516)
|
||||
|
||||
## [2.9.2] 2021-06-10
|
||||
|
||||
- Allow field guards to support paths. [#536](https://github.com/async-graphql/async-graphql/issues/536)
|
||||
|
|
|
@ -43,7 +43,7 @@ multer = "2.0.0"
|
|||
tempfile = "3.2.0"
|
||||
|
||||
# Feature optional dependencies
|
||||
bson = { version = "1.2.0", optional = true }
|
||||
bson = { version = "2.0.0-beta.1", optional = true, features = ["chrono-0_4"] }
|
||||
chrono = { version = "0.4.19", optional = true }
|
||||
chrono-tz = { version = "0.5.3", optional = true }
|
||||
log = { version = "0.4.14", optional = true }
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
|||
impl ScalarType for ObjectId {
|
||||
fn parse(value: Value) -> InputValueResult<Self> {
|
||||
match value {
|
||||
Value::String(s) => Ok(ObjectId::with_string(&s)?),
|
||||
Value::String(s) => Ok(ObjectId::parse_str(&s)?),
|
||||
_ => Err(InputValueError::expected_type(value)),
|
||||
}
|
||||
}
|
||||
|
@ -26,10 +26,10 @@ impl ScalarType for UtcDateTime {
|
|||
fn parse(value: Value) -> InputValueResult<Self> {
|
||||
<DateTime<Utc>>::parse(value)
|
||||
.map_err(InputValueError::propagate)
|
||||
.map(UtcDateTime::from)
|
||||
.map(UtcDateTime::from_chrono)
|
||||
}
|
||||
|
||||
fn to_value(&self) -> Value {
|
||||
(**self).to_value()
|
||||
self.to_chrono().to_value()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ impl TryFrom<ID> for ObjectId {
|
|||
type Error = oid::Error;
|
||||
|
||||
fn try_from(id: ID) -> std::result::Result<Self, oid::Error> {
|
||||
ObjectId::with_string(&id.0)
|
||||
ObjectId::parse_str(&id.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue