Skip to content

Commit 8395f2d

Browse files
sioswtyranron
andauthored
Provide ruint crate integration (#1355, #1350)
- add `ruint` Cargo feature - implement `U8`, `U16`, `U32`, `U64`, `U128`, `U256` scalars - expose `integrations::ruint::uint_scalar` module for implementing custom-sized `ruint::Uint` scalars Co-authored-by: Kai Ren <tyranron@gmail.com>
1 parent fe3dfaa commit 8395f2d

File tree

7 files changed

+413
-0
lines changed

7 files changed

+413
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ jobs:
118118
- { feature: chrono-tz, crate: juniper }
119119
- { feature: expose-test-schema, crate: juniper }
120120
- { feature: jiff, crate: juniper }
121+
- { feature: ruint, crate: juniper }
121122
- { feature: rust_decimal, crate: juniper }
122123
- { feature: schema-language, crate: juniper }
123124
- { feature: time, crate: juniper }

book/src/types/scalars.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,12 @@ mod date_scalar {
439439
| [`chrono::NaiveDateTime`] | [`LocalDateTime`] | [`chrono`] |
440440
| [`chrono::DateTime`] | [`DateTime`] | [`chrono`] |
441441
| [`chrono_tz::Tz`] | [`TimeZone`] | [`chrono-tz`] |
442+
| [`ruint::aliases::U8`] | `U8` | [`ruint`] |
443+
| [`ruint::aliases::U16`] | `U16` | [`ruint`] |
444+
| [`ruint::aliases::U32`] | `U32` | [`ruint`] |
445+
| [`ruint::aliases::U64`] | `U64` | [`ruint`] |
446+
| [`ruint::aliases::U128`] | `U128` | [`ruint`] |
447+
| [`ruint::aliases::U256`] | `U256` | [`ruint`] |
442448
| [`rust_decimal::Decimal`] | `Decimal` | [`rust_decimal`] |
443449
| [`jiff::civil::Date`] | [`LocalDate`] | [`jiff`] |
444450
| [`jiff::civil::Time`] | [`LocalTime`] | [`jiff`] |
@@ -489,6 +495,13 @@ mod date_scalar {
489495
[`LocalDateTime`]: https://graphql-scalars.dev/docs/scalars/local-date-time
490496
[`LocalTime`]: https://graphql-scalars.dev/docs/scalars/local-time
491497
[`ObjectID`]: https://the-guild.dev/graphql/scalars/docs/scalars/object-id
498+
[`ruint`]: https://docs.rs/ruint
499+
[`ruint::aliases::U8`]: https://docs.rs/ruint/latest/ruint/aliases/type.U8.html
500+
[`ruint::aliases::U16`]: https://docs.rs/ruint/latest/ruint/aliases/type.U16.html
501+
[`ruint::aliases::U32`]: https://docs.rs/ruint/latest/ruint/aliases/type.U32.html
502+
[`ruint::aliases::U64`]: https://docs.rs/ruint/latest/ruint/aliases/type.U64.html
503+
[`ruint::aliases::U128`]: https://docs.rs/ruint/latest/ruint/aliases/type.U128.html
504+
[`ruint::aliases::U256`]: https://docs.rs/ruint/latest/ruint/aliases/type.U256.html
492505
[`rust_decimal`]: https://docs.rs/rust_decimal
493506
[`rust_decimal::Decimal`]: https://docs.rs/rust_decimal/latest/rust_decimal/struct.Decimal.html
494507
[`ScalarValue`]: https://docs.rs/juniper/0.17.0/juniper/trait.ScalarValue.html

juniper/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
4242
- Support parsing descriptions on operations, fragments and variable definitions. ([#1349], [graphql/graphql-spec#1170])
4343
- Support for [block strings][0180-1]. ([#1349])
4444
- Support of `#[graphql(rename_all = "snake_case")]` attribute in macros. ([#1354])
45+
- [`ruint` crate] integration behind `ruint` [Cargo feature]: ([#1355], [#1350])
46+
- `ruint::aliases::U8` as `U8` scalar.
47+
- `ruint::aliases::U16` as `U16` scalar.
48+
- `ruint::aliases::U32` as `U32` scalar.
49+
- `ruint::aliases::U64` as `U64` scalar.
50+
- `ruint::aliases::U128` as `U128` scalar.
51+
- `ruint::aliases::U256` as `U256` scalar.
52+
- `integrations::ruint::unit_scalar` module for declaring custom-sized `ruint::Unit` scalars.
4553

4654
### Changed
4755

@@ -60,8 +68,10 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
6068
[#1347]: /../../issues/1347
6169
[#1348]: /../../pull/1348
6270
[#1349]: /../../pull/1349
71+
[#1350]: /../../issues/1350
6372
[#1353]: /../../pull/1353
6473
[#1354]: /../../pull/1354
74+
[#1355]: /../../pull/1355
6575
[graphql/graphql-spec#525]: https://github.com/graphql/graphql-spec/pull/525
6676
[graphql/graphql-spec#687]: https://github.com/graphql/graphql-spec/issues/687
6777
[graphql/graphql-spec#805]: https://github.com/graphql/graphql-spec/pull/805

juniper/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ chrono-tz = ["dep:chrono-tz", "dep:regex"]
3535
expose-test-schema = ["dep:anyhow", "dep:serde_json"]
3636
jiff = ["dep:jiff"]
3737
js = ["chrono?/wasmbind", "time?/wasm-bindgen", "uuid?/js"]
38+
ruint = ["dep:ruint"]
3839
rust_decimal = ["dep:rust_decimal"]
3940
schema-language = ["dep:graphql-parser", "dep:void"]
4041
time = ["dep:time"]
@@ -60,6 +61,7 @@ itertools = "0.14"
6061
jiff = { version = "0.2", features = ["std"], default-features = false, optional = true }
6162
juniper_codegen = { version = "0.17.0", path = "../juniper_codegen" }
6263
ref-cast = "1.0"
64+
ruint = { version = "1.10", optional = true }
6365
rust_decimal = { version = "1.20", default-features = false, optional = true }
6466
ryu = { version = "1.0", optional = true }
6567
serde = { version = "1.0.122", features = ["derive"] }

juniper/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ As an exception to other [GraphQL] libraries for other languages, [Juniper] buil
4949
- [`bson`]
5050
- [`chrono`], [`chrono-tz`]
5151
- [`jiff`]
52+
- [`ruint`]
5253
- [`rust_decimal`]
5354
- [`time`]
5455
- [`url`]
@@ -94,6 +95,7 @@ This project is licensed under [BSD 2-Clause License](https://github.com/graphql
9495
[`juniper_warp`]: https://docs.rs/juniper_warp
9596
[`hyper`]: https://docs.rs/hyper
9697
[`rocket`]: https://docs.rs/rocket
98+
[`ruint`]: https://docs.rs/ruint
9799
[`rust_decimal`]: https://docs.rs/rust_decimal
98100
[`time`]: https://docs.rs/time
99101
[`url`]: https://docs.rs/url

juniper/src/integrations/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ pub mod chrono;
1212
pub mod chrono_tz;
1313
#[cfg(feature = "jiff")]
1414
pub mod jiff;
15+
#[cfg(feature = "ruint")]
16+
pub mod ruint;
1517
#[cfg(feature = "rust_decimal")]
1618
pub mod rust_decimal;
1719
#[doc(hidden)]

0 commit comments

Comments
 (0)