From bd8fa6ca0ed65624808602a41ea20b83e1f70031 Mon Sep 17 00:00:00 2001 From: tyranron Date: Thu, 15 Aug 2024 18:01:14 +0300 Subject: [PATCH] `TimeZone` compliance [skip ci] --- book/src/types/scalars.md | 3 ++- juniper/CHANGELOG.md | 2 ++ juniper/src/integrations/chrono_tz.rs | 28 +++++++++++++++++---------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/book/src/types/scalars.md b/book/src/types/scalars.md index 5fac586da..847f14067 100644 --- a/book/src/types/scalars.md +++ b/book/src/types/scalars.md @@ -394,7 +394,7 @@ mod date_scalar { | [`chrono::NaiveTime`] | [`LocalTime`] | [`chrono`] | | [`chrono::NaiveDateTime`] | [`LocalDateTime`] | [`chrono`] | | [`chrono::DateTime`] | [`DateTime`] | [`chrono`] | -| [`chrono_tz::Tz`] | `TimeZone` | [`chrono-tz`] | +| [`chrono_tz::Tz`] | [`TimeZone`] | [`chrono-tz`] | | [`rust_decimal::Decimal`] | `Decimal` | [`rust_decimal`] | | [`jiff::civil::Date`] | [`LocalDate`] | [`jiff`] | | [`jiff::civil::Time`] | [`LocalTime`] | [`jiff`] | @@ -446,6 +446,7 @@ mod date_scalar { [`time::Time`]: https://docs.rs/time/latest/time/struct.Time.html [`time::UtcOffset`]: https://docs.rs/time/latest/time/struct.UtcOffset.html [`time::OffsetDateTime`]: https://docs.rs/time/latest/time/struct.OffsetDateTime.html +[`TimeZone`]: https://graphql-scalars.dev/docs/scalars/time-zone [`url`]: https://docs.rs/url [`url::Url`]: https://docs.rs/url/latest/url/struct.Url.html [`URL`]: https://graphql-scalars.dev/docs/scalars/url diff --git a/juniper/CHANGELOG.md b/juniper/CHANGELOG.md index 705effe33..74298b242 100644 --- a/juniper/CHANGELOG.md +++ b/juniper/CHANGELOG.md @@ -21,6 +21,8 @@ All user visible changes to `juniper` crate will be documented in this file. Thi - Switched from `Date` scalar to `LocalDate` scalar in types: - `chrono::NaiveDate`. - `time::Date`. + - Corrected `TimeZone` scalar in types: + - `chrono_tz::Tz`. - Renamed `Url` scalar to `URL` in types: - `url::Url`. - Renamed `Uuid` scalar to `UUID` in types: diff --git a/juniper/src/integrations/chrono_tz.rs b/juniper/src/integrations/chrono_tz.rs index 5c30b211b..bac4b5e5d 100644 --- a/juniper/src/integrations/chrono_tz.rs +++ b/juniper/src/integrations/chrono_tz.rs @@ -2,27 +2,35 @@ //! //! # Supported types //! -//! | Rust type | Format | GraphQL scalar | -//! |-----------|--------------------|----------------| -//! | [`Tz`] | [IANA database][1] | `TimeZone` | +//! | Rust type | Format | GraphQL scalar | +//! |-----------|--------------------|------------------| +//! | [`Tz`] | [IANA database][1] | [`TimeZone`][s1] | //! //! [`chrono-tz`]: chrono_tz //! [`Tz`]: chrono_tz::Tz //! [1]: http://www.iana.org/time-zones +//! [s1]: https://graphql-scalars.dev/docs/scalars/time-zone use crate::{graphql_scalar, InputValue, ScalarValue, Value}; -/// Timezone based on [`IANA` database][1]. +/// Timezone based on [`IANA` database][0]. /// -/// See ["List of tz database time zones"][2] `TZ database name` column for +/// See ["List of tz database time zones"][3] `TZ database name` column for /// available names. /// -/// See also [`chrono_tz::Tz`][3] for detals. +/// [`TimeZone` scalar][1] compliant. /// -/// [1]: https://www.iana.org/time-zones -/// [2]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones -/// [3]: https://docs.rs/chrono-tz/latest/chrono_tz/enum.Tz.html -#[graphql_scalar(with = tz, parse_token(String))] +/// See also [`chrono_tz::Tz`][2] for details. +/// +/// [0]: https://www.iana.org/time-zones +/// [1]: https://graphql-scalars.dev/docs/scalars/time-zone +/// [2]: https://docs.rs/chrono-tz/*/chrono_tz/enum.Tz.html +/// [3]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones +#[graphql_scalar( + with = tz, + parse_token(String), + specified_by_url = "https://graphql-scalars.dev/docs/scalars/time-zone", +)] pub type TimeZone = chrono_tz::Tz; mod tz {