@@ -141,14 +141,20 @@ class ASTParser {
141141 }
142142 }
143143
144+ /**
145+ * Return true if:
146+ * 1. there is no directive
147+ * 2. there is a directive named inlcude and the value is true
148+ * 3. there is a directive named skip and the value is false
149+ */
144150 directiveCheck ( directive : DirectiveNode ) : boolean {
145- // let directive;
146- // if (directives) [directive] = directives;
147151 if ( directive ?. arguments ) {
152+ // get the first argument
148153 const argument = directive . arguments [ 0 ] ;
154+ // ensure the argument name is 'if'
149155 const argumentHasVariables =
150156 argument . value . kind === Kind . VARIABLE && argument . name . value === 'if' ;
151-
157+ // access the value of the argument depending on whether it is passed as a variable or not
152158 let directiveArgumentValue ;
153159 if ( argument . value . kind === Kind . BOOLEAN ) {
154160 directiveArgumentValue = Boolean ( argument . value . value ) ;
@@ -166,6 +172,12 @@ class ASTParser {
166172
167173 private selectionNode ( node : SelectionNode , parentName : string ) : number {
168174 let complexity = 0 ;
175+ /**
176+ * process this node if:
177+ * 1. there is no directive
178+ * 2. there is a directive named inlcude and the value is true
179+ * 3. there is a directive named skip and the value is false
180+ */
169181 const directive = node . directives ;
170182 if ( directive && this . directiveCheck ( directive [ 0 ] ) ) {
171183 this . depth += 1 ;
0 commit comments