@@ -468,6 +468,13 @@ impl DirectiveDefinition {
468
468
self . arguments . iter ( ) . find ( |argument| argument. name == name)
469
469
}
470
470
471
+ /// Returns the definition of an argument by a given name.
472
+ pub fn argument_by_name_mut ( & mut self , name : & str ) -> Option < & mut Node < InputValueDefinition > > {
473
+ self . arguments
474
+ . iter_mut ( )
475
+ . find ( |argument| argument. name == name)
476
+ }
477
+
471
478
serialize_method ! ( ) ;
472
479
}
473
480
@@ -543,6 +550,17 @@ impl DirectiveList {
543
550
self . 0 . iter ( ) . filter ( move |dir| dir. name == name)
544
551
}
545
552
553
+ /// Returns an iterator of mutable directives with the given name.
554
+ ///
555
+ /// This method is best for repeatable directives.
556
+ /// See also [`get`][Self::get] for non-repeatable directives.
557
+ pub fn get_all_mut < ' def : ' name , ' name > (
558
+ & ' def mut self ,
559
+ name : & ' name str ,
560
+ ) -> impl Iterator < Item = & ' def mut Node < Directive > > + ' name {
561
+ self . 0 . iter_mut ( ) . filter ( move |dir| dir. name == name)
562
+ }
563
+
546
564
/// Returns the first directive with the given name, if any.
547
565
///
548
566
/// This method is best for non-repeatable directives.
@@ -661,6 +679,18 @@ impl Directive {
661
679
Argument :: specified_argument_by_name ( & self . arguments , name)
662
680
}
663
681
682
+ /// Returns the value of the argument named `name`, as specified in the directive application.
683
+ /// If there are other [`Node`] pointers to the same argument, this method will clone the
684
+ /// argument using [`Node::make_mut`].
685
+ ///
686
+ /// Returns `None` if the directive application does not specify this argument.
687
+ ///
688
+ /// If the directive definition makes this argument nullable or defines a default value,
689
+ /// consider using [`argument_by_name`][Self::argument_by_name] instead.
690
+ pub fn specified_argument_by_name_mut ( & mut self , name : & str ) -> Option < & mut Node < Value > > {
691
+ Argument :: specified_argument_by_name_mut ( & mut self . arguments , name)
692
+ }
693
+
664
694
serialize_method ! ( ) ;
665
695
}
666
696
@@ -692,6 +722,15 @@ impl Argument {
692
722
. iter ( )
693
723
. find_map ( |arg| ( arg. name == name) . then_some ( & arg. value ) )
694
724
}
725
+
726
+ pub ( crate ) fn specified_argument_by_name_mut < ' doc > (
727
+ arguments : & ' doc mut [ Node < Self > ] ,
728
+ name : & str ,
729
+ ) -> Option < & ' doc mut Node < Value > > {
730
+ arguments
731
+ . iter_mut ( )
732
+ . find_map ( |arg| ( arg. name == name) . then_some ( & mut arg. make_mut ( ) . value ) )
733
+ }
695
734
}
696
735
697
736
impl OperationType {
0 commit comments