You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Strip InputValue from from_input() function for GraphQL scalars (#1327)
- remove `as_float_value()`, `as_string_value()` and `as_scalar_value()` methods from `Value` enum
- remove `as_float_value()`, `as_int_value()`, `as_string_value()` and `as_scalar_value()` methods from `InputValue` enum
- `ScalarValue` trait:
- switch from `From` conversions to `TryScalarValueTo` conversions
- require `TryScalarValueTo` conversions for `bool`, `f64`, `i32`, `String` and `&str` types
- require `TryInto<String>` conversion
- make `is_type()` method required and accepting `Any` type
- rename `as_bool()` method as `try_to_bool()` and make it defined by default as `TryScalarValueTo<bool>` alias
- rename `as_float()` method as `try_to_float()` and make it defined by default as `TryScalarValueTo<f64>` alias
- rename `as_int()` method as `try_to_int()` and make it defined by default as `TryScalarValueTo<i32>` alias
- rename `as_string()` method as `try_to_string()` and make it defined by default as `TryScalarValueTo<String>` alias
- rename `as_str()` method as `try_as_str()` and make it defined by default as `TryScalarValueTo<&str>` alias
- rename `into_string()` method as `try_into_string()` and make it defined by default as `TryInto<String>` alias
- add `try_to::<T>()` method defined by default as `TryScalarValueTo<T>` alias
- add `TryScalarValueTo` conversion trait aiding `ScalarValue` trait
- `#[derive(ScalarValue)]` macro:
- rename `#[value(as_bool)]` attribute as `#[value(to_bool)]`
- rename `#[value(as_float)]` attribute as `#[value(to_float)]`
- rename `#[value(as_int)]` attribute as `#[value(to_int)]`
- rename `#[value(as_string)]` attribute as `#[value(to_string)]`
- remove `#[value(into_string)]` attribute
- remove `#[value(allow_missing_attributes)]` attribute (now attributes can always be omitted)
- `From` and `Display` implementations are not derived anymore
- `#[derive(GraphQLScalar)]` and `#[graphql_scalar]` macros:
- make provided `from_input()` function to accept `ScalarValue` (or anything `TryScalarValueTo`-convertible) directly instead of `InputValue`
- support non-`Result` return type in `from_input()` function
- add `Scalar` transparent wrapper for aiding type inference in `from_input()` function when input argument is generic `ScalarValue`
Copy file name to clipboardExpand all lines: juniper/CHANGELOG.md
+35-1Lines changed: 35 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,31 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
67
67
- Switched `ParseError::UnexpectedToken` to `compact_str::CompactString` instead of `smartstring::SmartString`. ([20609366])
68
68
- Replaced `Value`'s `From` implementations with `IntoValue` ones. ([#1324])
69
69
- Replaced `InputValue`'s `From` implementations with `IntoInputValue` ones. ([#1324])
70
+
-`Value` enum: ([#1327])
71
+
- Removed `as_float_value()`, `as_string_value()` and `as_scalar_value()` methods (use `as_scalar()` method and then `ScalarValue` methods instead).
72
+
-`InputValue` enum: ([#1327])
73
+
- Removed `as_float_value()`, `as_int_value()`, `as_string_value()` and `as_scalar_value()` methods (use `as_scalar()` method and then `ScalarValue` methods instead).
74
+
-`ScalarValue` trait: ([#1327])
75
+
- Switched from `From` conversions to `TryScalarValueTo` conversions.
76
+
- Made to require `TryScalarValueTo` conversions for `bool`, `f64`, `i32`, `String` and `&str` types (could be derived with `#[value(<conversion>)]` attributes of `#[derive(ScalarValue)]` macro).
77
+
- Made to require `TryInto<String>` conversion (could be derived with `derive_more::TryInto`).
78
+
- Made `is_type()` method required and to accept `Any` type.
79
+
- Renamed `as_bool()` method as `try_to_bool()` and made it defined by default as `TryScalarValueTo<bool>` alias.
80
+
- Renamed `as_float()` method as `try_to_float()` and made it defined by default as `TryScalarValueTo<f64>` alias.
81
+
- Renamed `as_int()` method as `try_to_int()` and made it defined by default as `TryScalarValueTo<i32>` alias.
82
+
- Renamed `as_string()` method as `try_to_string()` and made it defined by default as `TryScalarValueTo<String>` alias.
83
+
- Renamed `as_str()` method as `try_as_str()` and made it defined by default as `TryScalarValueTo<&str>` alias.
84
+
- Renamed `into_string()` method as `try_into_string()` and made it defined by default as `TryInto<String>` alias.
85
+
-`#[derive(ScalarValue)]` macro: ([#1327])
86
+
- Renamed `#[value(as_bool)]` attribute as `#[value(to_bool)]`.
87
+
- Renamed `#[value(as_float)]` attribute as `#[value(to_float)]`.
88
+
- Renamed `#[value(as_int)]` attribute as `#[value(to_int)]`.
89
+
- Renamed `#[value(as_string)]` attribute as `#[value(to_string)]`.
90
+
- Removed `#[value(into_string)]` attribute.
91
+
- Removed `#[value(allow_missing_attributes)]` attribute (now attributes can always be omitted).
92
+
-`From` and `Display` implementations are not derived anymore (recommended way is to use [`derive_more` crate] for this).
93
+
-`#[derive(GraphQLScalar)]` and `#[graphql_scalar]` macros: ([#1327])
94
+
- Made provided `from_input()` function to accept `ScalarValue` (or anything `TryScalarValueTo`-convertible) directly instead of `InputValue`.
70
95
71
96
### Added
72
97
@@ -82,8 +107,15 @@ All user visible changes to `juniper` crate will be documented in this file. Thi
0 commit comments