Skip to content

Commit b3a7ffc

Browse files
authored
Correct GraphQL scalars compliance for third-party crates (#1275)
- switch `LocalDateTime` scalars to `yyyy-MM-ddTHH:mm:ss` format in `chrono::NaiveDateTime` and `time::PrimitiveDateTime` types - switch from `Date` scalar to `LocalDate` scalar in `chrono::NaiveDate` and `time::Date` types - switch from `UtcDateTime` scalar to `DateTime` scalar in `bson::DateTime` type - correct `TimeZone` scalar in `chrono_tz::Tz` type - rename `Url` scalar to `URL` in `url::Url` type - rename `Uuid` scalar to `UUID` in `uuid::Uuid` type
1 parent 2756260 commit b3a7ffc

File tree

12 files changed

+538
-192
lines changed

12 files changed

+538
-192
lines changed

book/src/types/scalars.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -385,35 +385,35 @@ mod date_scalar {
385385

386386
[Juniper] provides out-of-the-box [GraphQL scalar][0] implementations for some very common [Rust] crates. The types from these crates will be usable in your schemas automatically after enabling the correspondent self-titled [Cargo feature].
387387

388-
| [Rust] type | [GraphQL] scalar | [Cargo feature] |
389-
|-----------------------------|------------------|------------------|
390-
| [`BigDecimal`] | `BigDecimal` | [`bigdecimal`] |
391-
| [`bson::oid::ObjectId`] | `ObjectId` | [`bson`] |
392-
| [`bson::DateTime`] | `UtcDateTime` | [`bson`] |
393-
| [`chrono::NaiveDate`] | [`Date`] | [`chrono`] |
394-
| [`chrono::NaiveTime`] | [`LocalTime`] | [`chrono`] |
395-
| [`chrono::NaiveDateTime`] | `LocalDateTime` | [`chrono`] |
396-
| [`chrono::DateTime`] | [`DateTime`] | [`chrono`] |
397-
| [`chrono_tz::Tz`] | `TimeZone` | [`chrono-tz`] |
398-
| [`Decimal`] | `Decimal` | [`rust_decimal`] |
399-
| [`jiff::civil::Date`] | [`LocalDate`] | [`jiff`] |
400-
| [`jiff::civil::Time`] | [`LocalTime`] | [`jiff`] |
401-
| [`jiff::civil::DateTime`] | `LocalDateTime` | [`jiff`] |
402-
| [`jiff::Timestamp`] | [`DateTime`] | [`jiff`] |
403-
| [`jiff::Span`] | [`Duration`] | [`jiff`] |
404-
| [`time::Date`] | [`Date`] | [`time`] |
405-
| [`time::Time`] | [`LocalTime`] | [`time`] |
406-
| [`time::PrimitiveDateTime`] | `LocalDateTime` | [`time`] |
407-
| [`time::OffsetDateTime`] | [`DateTime`] | [`time`] |
408-
| [`time::UtcOffset`] | [`UtcOffset`] | [`time`] |
409-
| [`Url`] | `Url` | [`url`] |
410-
| [`Uuid`] | `Uuid` | [`uuid`] |
388+
| [Rust] type | [GraphQL] scalar | [Cargo feature] |
389+
|-----------------------------|-------------------|------------------|
390+
| [`bigdecimal::BigDecimal`] | `BigDecimal` | [`bigdecimal`] |
391+
| [`bson::oid::ObjectId`] | `ObjectId` | [`bson`] |
392+
| [`bson::DateTime`] | [`DateTime`] | [`bson`] |
393+
| [`chrono::NaiveDate`] | [`LocalDate`] | [`chrono`] |
394+
| [`chrono::NaiveTime`] | [`LocalTime`] | [`chrono`] |
395+
| [`chrono::NaiveDateTime`] | [`LocalDateTime`] | [`chrono`] |
396+
| [`chrono::DateTime`] | [`DateTime`] | [`chrono`] |
397+
| [`chrono_tz::Tz`] | [`TimeZone`] | [`chrono-tz`] |
398+
| [`rust_decimal::Decimal`] | `Decimal` | [`rust_decimal`] |
399+
| [`jiff::civil::Date`] | [`LocalDate`] | [`jiff`] |
400+
| [`jiff::civil::Time`] | [`LocalTime`] | [`jiff`] |
401+
| [`jiff::civil::DateTime`] | [`LocalDateTime`] | [`jiff`] |
402+
| [`jiff::Timestamp`] | [`DateTime`] | [`jiff`] |
403+
| [`jiff::Span`] | [`Duration`] | [`jiff`] |
404+
| [`time::Date`] | [`LocalDate`] | [`time`] |
405+
| [`time::Time`] | [`LocalTime`] | [`time`] |
406+
| [`time::PrimitiveDateTime`] | [`LocalDateTime`] | [`time`] |
407+
| [`time::OffsetDateTime`] | [`DateTime`] | [`time`] |
408+
| [`time::UtcOffset`] | [`UtcOffset`] | [`time`] |
409+
| [`url::Url`] | [`URL`] | [`url`] |
410+
| [`uuid::Uuid`] | [`UUID`] | [`uuid`] |
411411

412412

413413

414414

415415
[`bigdecimal`]: https://docs.rs/bigdecimal
416-
[`BigDecimal`]: https://docs.rs/bigdecimal/latest/bigdecimal/struct.BigDecimal.html
416+
[`bigdecimal::BigDecimal`]: https://docs.rs/bigdecimal/latest/bigdecimal/struct.BigDecimal.html
417417
[`bson`]: https://docs.rs/bson
418418
[`bson::DateTime`]: https://docs.rs/bson/latest/bson/struct.DateTime.html
419419
[`bson::oid::ObjectId`]: https://docs.rs/bson/latest/bson/oid/struct.ObjectId.html
@@ -424,7 +424,6 @@ mod date_scalar {
424424
[`chrono::NaiveTime`]: https://docs.rs/chrono/latest/chrono/naive/struct.NaiveTime.html
425425
[`chrono-tz`]: https://docs.rs/chrono-tz
426426
[`chrono_tz::Tz`]: https://docs.rs/chrono-tz/latest/chrono_tz/enum.Tz.html
427-
[`Date`]: https://graphql-scalars.dev/docs/scalars/date
428427
[`DateTime`]: https://graphql-scalars.dev/docs/scalars/date-time
429428
[`Decimal`]: https://docs.rs/rust_decimal/latest/rust_decimal/struct.Decimal.html
430429
[`Duration`]: https://graphql-scalars.dev/docs/scalars/duration
@@ -436,6 +435,7 @@ mod date_scalar {
436435
[`jiff::Span`]: https://docs.rs/jiff/latest/jiff/struct.Span.html
437436
[`jiff::Timestamp`]: https://docs.rs/jiff/latest/jiff/struct.Timestamp.html
438437
[`LocalDate`]: https://graphql-scalars.dev/docs/scalars/local-date
438+
[`LocalDateTime`]: https://graphql-scalars.dev/docs/scalars/local-date-time
439439
[`LocalTime`]: https://graphql-scalars.dev/docs/scalars/local-time
440440
[`rust_decimal`]: https://docs.rs/rust_decimal
441441
[`ScalarValue`]: https://docs.rs/juniper/0.16.1/juniper/trait.ScalarValue.html
@@ -446,11 +446,14 @@ mod date_scalar {
446446
[`time::Time`]: https://docs.rs/time/latest/time/struct.Time.html
447447
[`time::UtcOffset`]: https://docs.rs/time/latest/time/struct.UtcOffset.html
448448
[`time::OffsetDateTime`]: https://docs.rs/time/latest/time/struct.OffsetDateTime.html
449+
[`TimeZone`]: https://graphql-scalars.dev/docs/scalars/time-zone
449450
[`url`]: https://docs.rs/url
450-
[`Url`]: https://docs.rs/url/latest/url/struct.Url.html
451+
[`url::Url`]: https://docs.rs/url/latest/url/struct.Url.html
452+
[`URL`]: https://graphql-scalars.dev/docs/scalars/url
451453
[`UtcOffset`]: https://graphql-scalars.dev/docs/scalars/utc-offset
452454
[`uuid`]: https://docs.rs/uuid
453-
[`Uuid`]: https://docs.rs/uuid/latest/uuid/struct.Uuid.html
455+
[`uuid::Uuid`]: https://docs.rs/uuid/latest/uuid/struct.Uuid.html
456+
[`UUID`]: https://graphql-scalars.dev/docs/scalars/uuid
454457
[Cargo feature]: https://doc.rust-lang.org/cargo/reference/features.html
455458
[GraphQL]: https://graphql.org
456459
[Juniper]: https://docs.rs/juniper

juniper/CHANGELOG.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,41 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
1414

1515
- Upgraded [`chrono-tz` crate] integration to [0.9 version](https://github.com/chronotope/chrono-tz/releases/tag/v0.9.0). ([#1252])
1616
- Bumped up [MSRV] to 1.75. ([#1272])
17+
- Corrected compliance with newer [graphql-scalars.dev] specs: ([#1275])
18+
- Switched `LocalDateTime` scalars to `yyyy-MM-ddTHH:mm:ss` format in types:
19+
- `chrono::NaiveDateTime`.
20+
- `time::PrimitiveDateTime`.
21+
- Switched from `Date` scalar to `LocalDate` scalar in types:
22+
- `chrono::NaiveDate`.
23+
- `time::Date`.
24+
- Switched from `UtcDateTime` scalar to `DateTime` scalar in types:
25+
- `bson::DateTime`.
26+
- Corrected `TimeZone` scalar in types:
27+
- `chrono_tz::Tz`.
28+
- Renamed `Url` scalar to `URL` in types:
29+
- `url::Url`.
30+
- Renamed `Uuid` scalar to `UUID` in types:
31+
- `uuid::Uuid`.
1732

1833
### Added
1934

20-
- [`jiff` crate] integration behind `jiff` [Cargo feature]. ([#1271])
35+
- [`jiff` crate] integration behind `jiff` [Cargo feature]: ([#1271], [#1270])
36+
- `jiff::civil::Date` as `LocalDate` scalar.
37+
- `jiff::civil::Time` as `LocalTime` scalar.
38+
- `jiff::civil::DateTime` as `LocalDateTime` scalar. ([#1275])
39+
- `jiff::Timestamp` as `DateTime` scalar.
40+
- `jiff::Span` as `Duration` scalar.
2141

2242
### Changed
2343

2444
- Updated [GraphiQL] to [3.5.0 version](https://github.com/graphql/graphiql/blob/graphiql%403.5.0/packages/graphiql/CHANGELOG.md#350). ([#1274])
2545

2646
[#1252]: /../../pull/1252
47+
[#1270]: /../../issues/1270
2748
[#1271]: /../../pull/1271
2849
[#1272]: /../../pull/1272
2950
[#1274]: /../../pull/1274
51+
[#1275]: /../../pull/1275
3052

3153

3254

juniper/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ anyhow = { version = "1.0.47", optional = true }
4646
async-trait = "0.1.39"
4747
auto_enums = "0.8"
4848
bigdecimal = { version = "0.4", optional = true }
49-
bson = { version = "2.4", features = ["chrono-0_4"], optional = true }
49+
bson = { version = "2.4", optional = true }
5050
chrono = { version = "0.4.30", features = ["alloc"], default-features = false, optional = true }
5151
chrono-tz = { version = "0.9", default-features = false, optional = true }
5252
fnv = "1.0.5"

juniper/src/executor_tests/interfaces_unions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod interface {
66
GraphQLObject,
77
};
88

9+
#[allow(dead_code)] // TODO: Consider this for the GraphQL interfaces in the expansion.
910
#[graphql_interface(for = [Cat, Dog])]
1011
trait Pet {
1112
fn name(&self) -> &str;

juniper/src/executor_tests/introspection/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ enum Sample {
2424
struct Scalar(i32);
2525

2626
/// A sample interface
27+
#[allow(dead_code)] // TODO: Consider this for the GraphQL interfaces in the expansion.
2728
#[graphql_interface(name = "SampleInterface", for = Root)]
2829
trait Interface {
2930
/// A sample field in the interface

0 commit comments

Comments
 (0)