From 27e5c94731f31060a636595c3a5b4ffe45a86a81 Mon Sep 17 00:00:00 2001 From: Caio Date: Sat, 16 May 2020 13:08:03 -0300 Subject: [PATCH 1/2] Fix compilation errors --- .github/workflows/ci.yml | 2 ++ src/scalars/id.rs | 8 +++++--- src/scalars/mod.rs | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0108751..ec7736fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,8 @@ jobs: run: cargo fmt --all -- --check - name: Check with clippy run: cargo clippy --all + - name: Build without features + run: cargo build --no-default-features - name: Build run: cargo build --all --verbose - name: Run tests diff --git a/src/scalars/id.rs b/src/scalars/id.rs index 911b2e5b..14ce2229 100644 --- a/src/scalars/id.rs +++ b/src/scalars/id.rs @@ -1,10 +1,10 @@ use crate::{InputValueError, InputValueResult, Result, ScalarType, Value}; use async_graphql_derive::Scalar; +#[cfg(feature = "bson")] use bson::oid::{self, ObjectId}; use std::convert::TryFrom; use std::num::ParseIntError; use std::ops::{Deref, DerefMut}; -use uuid::Uuid; /// ID scalar /// @@ -49,14 +49,16 @@ impl TryFrom for usize { } } -impl TryFrom for Uuid { +#[cfg(feature = "uuid")] +impl TryFrom for uuid::Uuid { type Error = uuid::Error; fn try_from(id: ID) -> std::result::Result { - Uuid::parse_str(&id.0) + uuid::Uuid::parse_str(&id.0) } } +#[cfg(feature = "bson")] impl TryFrom for ObjectId { type Error = oid::Error; diff --git a/src/scalars/mod.rs b/src/scalars/mod.rs index 30220f24..4512f79c 100644 --- a/src/scalars/mod.rs +++ b/src/scalars/mod.rs @@ -1,6 +1,5 @@ mod any; mod bool; -mod chrono_tz; mod datetime; mod floats; mod id; @@ -9,8 +8,11 @@ mod json; mod naive_date; mod naive_time; mod string; -mod url; +#[cfg(feature = "chrono_tz")] +mod chrono_tz; +#[cfg(feature = "uuid")] +mod url; #[cfg(feature = "bson")] mod bson; #[cfg(feature = "uuid")] From 8c14c6c675ecabb4551fa8e9ce85dcc3a84308f9 Mon Sep 17 00:00:00 2001 From: Caio Date: Sat, 16 May 2020 13:12:37 -0300 Subject: [PATCH 2/2] Rustfmt --- src/scalars/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scalars/mod.rs b/src/scalars/mod.rs index 4512f79c..a4205bb0 100644 --- a/src/scalars/mod.rs +++ b/src/scalars/mod.rs @@ -9,12 +9,12 @@ mod naive_date; mod naive_time; mod string; +#[cfg(feature = "bson")] +mod bson; #[cfg(feature = "chrono_tz")] mod chrono_tz; #[cfg(feature = "uuid")] mod url; -#[cfg(feature = "bson")] -mod bson; #[cfg(feature = "uuid")] mod uuid;