@@ -62,37 +62,39 @@ public Task<INodeVisitor> ValidateAsync(ValidationContext context)
6262 } ) ) ;
6363 }
6464
65- private bool SkipAuthCheck ( Field fieldAst , ValidationContext context )
65+ private bool SkipAuthCheck ( Field field , ValidationContext context )
6666 {
67- if ( fieldAst . Directives == null || ! fieldAst . Directives . Any ( ) ) return false ;
67+ if ( field . Directives == null || ! field . Directives . Any ( ) ) return false ;
6868
69- var includeField = GetDirectiveValue ( context , fieldAst . Directives , DirectiveGraphType . Include ) ;
69+ var operationName = context . OperationName ;
70+ var documentOperations = context . Document . Operations ;
71+ var operation = ! string . IsNullOrWhiteSpace ( operationName )
72+ ? documentOperations . WithName ( operationName )
73+ : documentOperations . FirstOrDefault ( ) ;
74+ var variables = ExecutionHelper . GetVariableValues ( context . Document , context . Schema ,
75+ operation ? . Variables , context . Inputs ) ;
76+
77+ var includeField = GetDirectiveValue ( context , field . Directives , DirectiveGraphType . Include , variables ) ;
7078 if ( includeField . HasValue ) return ! includeField . Value ;
7179
72- var skipField = GetDirectiveValue ( context , fieldAst . Directives , DirectiveGraphType . Skip ) ;
80+ var skipField = GetDirectiveValue ( context , field . Directives , DirectiveGraphType . Skip , variables ) ;
7381 if ( skipField . HasValue ) return skipField . Value ;
7482
7583 return false ;
7684 }
7785
78- private static bool ? GetDirectiveValue ( ValidationContext context , Directives directives , DirectiveGraphType directiveType )
86+ private static bool ? GetDirectiveValue ( ValidationContext context , Directives directives , DirectiveGraphType directiveType , Variables variables )
7987 {
8088 var directive = directives . Find ( directiveType . Name ) ;
8189 if ( directive == null ) return null ;
8290
83- var operationName = context . OperationName ;
84- var documentOperations = context . Document . Operations ;
85- var operation = ! string . IsNullOrWhiteSpace ( operationName )
86- ? documentOperations . WithName ( operationName )
87- : documentOperations . FirstOrDefault ( ) ;
88-
89- var values = ExecutionHelper . GetArgumentValues (
91+ var argumentValues = ExecutionHelper . GetArgumentValues (
9092 context . Schema ,
9193 directiveType . Arguments ,
9294 directive . Arguments ,
93- ExecutionHelper . GetVariableValues ( context . Document , context . Schema , operation ? . Variables , context . Inputs ) ) ;
95+ variables ) ;
9496
95- values . TryGetValue ( "if" , out object ifObj ) ;
97+ argumentValues . TryGetValue ( "if" , out object ifObj ) ;
9698 return bool . TryParse ( ifObj ? . ToString ( ) ?? string . Empty , out bool ifVal ) && ifVal ;
9799 }
98100
0 commit comments