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..a4205bb0 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,10 +8,13 @@ mod json; mod naive_date; mod naive_time; mod string; -mod url; #[cfg(feature = "bson")] mod bson; +#[cfg(feature = "chrono_tz")] +mod chrono_tz; +#[cfg(feature = "uuid")] +mod url; #[cfg(feature = "uuid")] mod uuid;