11use super :: prelude:: * ;
22use super :: {
33 ExecutableId ,
4+ descriptions:: Description ,
45 directive:: Directive ,
5- ids:: { DirectiveId , OperationDefinitionId , SelectionId , VariableDefinitionId } ,
6+ ids:: { DescriptionId , DirectiveId , OperationDefinitionId , SelectionId , VariableDefinitionId } ,
67 selections:: Selection ,
78 variable:: VariableDefinition ,
89} ;
910#[ allow( unused_imports) ]
1011use std:: fmt:: { self , Write } ;
1112
1213pub struct OperationDefinitionRecord {
14+ pub description : Option < DescriptionId > ,
1315 pub operation_type : OperationType ,
1416 pub operation_type_span : Option < Span > ,
1517 pub name : Option < StringId > ,
@@ -24,6 +26,13 @@ pub struct OperationDefinitionRecord {
2426pub struct OperationDefinition < ' a > ( pub ( in super :: super ) ReadContext < ' a , OperationDefinitionId > ) ;
2527
2628impl < ' a > OperationDefinition < ' a > {
29+ pub fn description ( & self ) -> Option < Description < ' a > > {
30+ let document = self . 0 . document ;
31+ document
32+ . lookup ( self . 0 . id )
33+ . description
34+ . map ( |id| document. read ( id) )
35+ }
2736 pub fn operation_type ( & self ) -> OperationType {
2837 let document = self . 0 . document ;
2938 document. lookup ( self . 0 . id ) . operation_type
@@ -70,6 +79,7 @@ impl OperationDefinition<'_> {
7079impl fmt:: Debug for OperationDefinition < ' _ > {
7180 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
7281 f. debug_struct ( "OperationDefinition" )
82+ . field ( "description" , & self . description ( ) )
7383 . field ( "operation_type" , & self . operation_type ( ) )
7484 . field ( "name" , & self . name ( ) )
7585 . field ( "variable_definitions" , & self . variable_definitions ( ) )
0 commit comments