File tree Expand file tree Collapse file tree 4 files changed +14
-3
lines changed Expand file tree Collapse file tree 4 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -19,11 +19,17 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
19
19
20
20
# [ x.x.x] (unreleased) - 2024-mm-dd
21
21
22
+ ## BREAKING
23
+ - ** ` InputValueDefinition::is_required() ` returns false if it has a default value - [ goto-bus-stop] , [ pull/798] **
24
+ Now ` argument.is_required() == true ` only if the type is non-null and there is no
25
+ default value, meaning a value must be provided when it's used.
26
+
22
27
## Features
23
28
- ** Implement ` fmt::Display ` for ` ComponentName ` - [ goto-bus-stop] , [ pull/795] **
24
29
25
30
[ goto-bus-stop ] : https://github.com/goto-bus-stop]
26
31
[ pull/795 ] : https://github.com/apollographql/apollo-rs/pull/795
32
+ [ pull/798 ] : https://github.com/apollographql/apollo-rs/pull/798
27
33
28
34
# [ 1.0.0-beta.11] ( https://crates.io/crates/apollo-compiler/1.0.0-beta.11 ) - 2023-12-19
29
35
Original file line number Diff line number Diff line change @@ -840,8 +840,13 @@ impl FieldDefinition {
840
840
}
841
841
842
842
impl InputValueDefinition {
843
+ /// Returns true if usage sites are required to provide a value for this input value.
844
+ ///
845
+ /// That means:
846
+ /// - its type is non-null, and
847
+ /// - it does not have a default value
843
848
pub fn is_required ( & self ) -> bool {
844
- matches ! ( * self . ty, Type :: NonNullNamed ( _ ) | Type :: NonNullList ( _ ) )
849
+ self . ty . is_non_null ( ) && self . default_value . is_none ( )
845
850
}
846
851
847
852
serialize_method ! ( ) ;
Original file line number Diff line number Diff line change @@ -294,7 +294,7 @@ pub(crate) fn validate_directives<'dir>(
294
294
Some ( value) => value. is_null ( ) ,
295
295
} ;
296
296
297
- if arg_def. is_required ( ) && is_null && arg_def . default_value . is_none ( ) {
297
+ if arg_def. is_required ( ) && is_null {
298
298
diagnostics. push ( ValidationError :: new (
299
299
dir. location ( ) ,
300
300
DiagnosticData :: RequiredArgument {
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ pub(crate) fn validate_field(
87
87
Some ( value) => value. is_null ( ) ,
88
88
} ;
89
89
90
- if arg_definition. is_required ( ) && is_null && arg_definition . default_value . is_none ( ) {
90
+ if arg_definition. is_required ( ) && is_null {
91
91
diagnostics. push ( ValidationError :: new (
92
92
field. location ( ) ,
93
93
DiagnosticData :: RequiredArgument {
You can’t perform that action at this time.
0 commit comments