diff --git a/CHANGELOG.md b/CHANGELOG.md index b03a6f79..fa87cb4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/Cargo.toml b/Cargo.toml index f6a0de43..83d81502 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/src/types/external/bson.rs b/src/types/external/bson.rs index 7c8b9093..228cf52c 100644 --- a/src/types/external/bson.rs +++ b/src/types/external/bson.rs @@ -10,7 +10,7 @@ use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value}; impl ScalarType for ObjectId { fn parse(value: Value) -> InputValueResult { 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 { >::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() } } diff --git a/src/types/id.rs b/src/types/id.rs index 5f3ea611..f83150cb 100644 --- a/src/types/id.rs +++ b/src/types/id.rs @@ -71,7 +71,7 @@ impl TryFrom for ObjectId { type Error = oid::Error; fn try_from(id: ID) -> std::result::Result { - ObjectId::with_string(&id.0) + ObjectId::parse_str(&id.0) } }